From 09a2c484f0a3d9711fcc6321f0cb31f08ed148e3 Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:21:32 +0530 Subject: [PATCH 01/24] CommentMgtTestHelper Dummy data for comments Testing. --- .../services/util/CommentMgtTestHelper.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java new file mode 100644 index 0000000000..bb019a0e1f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java @@ -0,0 +1,59 @@ +package org.wso2.carbon.device.application.mgt.store.api.services.util; +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * you may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.wso2.carbon.device.application.mgt.common.Comment; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import static org.wso2.carbon.registry.core.jdbc.DumpConstants.UUID; + +/** + * Helper class for Comment Management API test cases. + */ + +public class CommentMgtTestHelper { + + private static final String COMMENT_TEXT = "Dummy Comment"; + private static final String CREATED_BY = "TEST_CREATED_BY"; + private static final String MODIFIED_BY="TEST_MODIFIED_BY"; + private static final int PARENT_ID=123; + private static final int COMMENT_ID=1; + + /** + * Creates a Comment with given text and given uuid. + * If the text is null, the COMMENT_TEXT will be used as the Dummy Comment. + * + * @param commentText : Text of the Comment + * @return Comment + */ + public static Comment getDummyComment(String commentText, String uuid) { + Comment comment = new Comment(); + comment.setId(COMMENT_ID); + comment.setCreatedBy(CREATED_BY); + comment.setModifiedBy(MODIFIED_BY); + comment.setParent(PARENT_ID); + comment.setComment(commentText != null ? commentText : COMMENT_TEXT); + + return comment; + } +} + + From c216048b576ffd23ed9cb39fbb7560e97180eea6 Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:25:48 +0530 Subject: [PATCH 02/24] Test Resources log4j.properties and testng.xml files added. --- .../src/test/resources/log4j.properties | 34 +++++++++++++++++++ .../src/test/resources/testng.xml | 30 ++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/log4j.properties create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/testng.xml diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/log4j.properties b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/log4j.properties new file mode 100644 index 0000000000..1dbcc0f635 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/log4j.properties @@ -0,0 +1,34 @@ + +# Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# +# This is the log4j configuration file used by WSO2 Carbon +# +# IMPORTANT : Please do not remove or change the names of any +# of the Appender defined here. The layout pattern & log file +# can be changed using the WSO2 Carbon Management Console, and those +# settings will override the settings in this file. +# + +log4j.rootLogger=DEBUG, STD_OUT + +# Redirect log messages to console +log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender +log4j.appender.STD_OUT.Target=System.out +log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout +log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/testng.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/testng.xml new file mode 100644 index 0000000000..ed1275edab --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/testng.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + From b60f3f0a9e23a34289c30c5c93dd667460f31fa3 Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:28:13 +0530 Subject: [PATCH 03/24] CommentManagementApi CommentManagementApi class moved to store/api/services directory. --- .../mgt/store}/api/services/CommentManagementAPI.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename components/application-mgt/{org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt => org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store}/api/services/CommentManagementAPI.java (99%) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/CommentManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPI.java similarity index 99% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/CommentManagementAPI.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPI.java index 87a391758a..8fda8cd31d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/CommentManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPI.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.api.services; +package org.wso2.carbon.device.application.mgt.store.api.services; import io.swagger.annotations.ApiParam; import io.swagger.annotations.Api; @@ -30,7 +30,7 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; -import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse; +import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse; import org.wso2.carbon.device.application.mgt.common.Comment; import javax.validation.Valid; import javax.ws.rs.Path; From ef059800e2f479f8522e2ea19d95cb806755aff6 Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:29:31 +0530 Subject: [PATCH 04/24] CommentManagementAPIImpl CommentManagementAPIImpl class moved to store/api/services/impl directory. --- .../api/services/impl/CommentManagementAPIImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename components/application-mgt/{org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt => org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store}/api/services/impl/CommentManagementAPIImpl.java (95%) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/CommentManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java similarity index 95% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/CommentManagementAPIImpl.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java index be1a7cfe85..73f1d5b177 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/CommentManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java @@ -16,14 +16,15 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.api.services.impl; +package org.wso2.carbon.device.application.mgt.store.api.services.impl; import io.swagger.annotations.ApiParam; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.application.mgt.api.APIUtil; -import org.wso2.carbon.device.application.mgt.api.services.CommentManagementAPI; +import org.wso2.carbon.device.application.mgt.store.api.APIUtil; +import org.wso2.carbon.device.application.mgt.store.api.services.CommentManagementAPI; import org.wso2.carbon.device.application.mgt.common.Comment; import org.wso2.carbon.device.application.mgt.common.PaginationRequest; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; @@ -77,7 +78,7 @@ public class CommentManagementAPIImpl implements CommentManagementAPI { return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(" Internal server error occurs").build(); } - return Response.status(Response.Status.OK).entity(comments).build(); + return null; } @Override @@ -89,9 +90,8 @@ public class CommentManagementAPIImpl implements CommentManagementAPI { @PathParam("uuid") String uuid) { CommentsManager commentsManager = APIUtil.getCommentsManager(); - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { - Comment newComment = commentsManager.addComment(comment, uuid, tenantId); + Comment newComment = commentsManager.addComment(comment, uuid); if (comment != null) { return Response.status(Response.Status.CREATED).entity(newComment).build(); } else { From c3f8d15910d8bf94c2f834c509d1abdfcbaa34dd Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:31:10 +0530 Subject: [PATCH 05/24] CommentManagementAPIImpl newStar variable changed. --- .../mgt/store/api/services/impl/CommentManagementAPIImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java index 73f1d5b177..75b80b0dab 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java @@ -208,7 +208,7 @@ public class CommentManagementAPIImpl implements CommentManagementAPI { @PathParam("uuid") String uuid) { CommentsManager commentsManager = APIUtil.getCommentsManager(); - int newStars = 0; + int newStars; try { newStars = commentsManager.updateStars(stars, uuid); From c26903c446166afc0b30a3b8d6caceea2117e3e7 Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:32:33 +0530 Subject: [PATCH 06/24] CommentManagementAPIImpl variable redundant reduced. --- .../mgt/store/api/services/impl/CommentManagementAPIImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java index 75b80b0dab..42cb4895f1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java @@ -21,8 +21,6 @@ package org.wso2.carbon.device.application.mgt.store.api.services.impl; import io.swagger.annotations.ApiParam; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.store.api.APIUtil; import org.wso2.carbon.device.application.mgt.store.api.services.CommentManagementAPI; import org.wso2.carbon.device.application.mgt.common.Comment; @@ -164,7 +162,7 @@ public class CommentManagementAPIImpl implements CommentManagementAPI { @PathParam("uuid") String uuid) { CommentsManager commentsManager = APIUtil.getCommentsManager(); - int Stars = 0; + int Stars; try { Stars = commentsManager.getStars(uuid); } catch (CommentManagementException e) { From 7d22c45636023d4b938c59f9b1a083ebe4ab1fd3 Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:33:38 +0530 Subject: [PATCH 07/24] CommentManagementAPIImpl --- .../device/application/mgt/core/impl/CommentsManagerImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java index 4a5ab8b1c9..68f519de7e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java @@ -56,11 +56,12 @@ public class CommentsManagerImpl implements CommentsManager { } @Override - public Comment addComment(Comment comment, String uuid, int tenantId) throws CommentManagementException { + public Comment addComment(Comment comment, String uuid) throws CommentManagementException { if (log.isDebugEnabled()) { log.debug("Request for comment is received for uuid" + uuid); } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); comment.setCreatedAt(Timestamp.from(Instant.now())); try { ConnectionManagerUtil.beginDBTransaction(); From 072d8b645559d6ec1000cf2130577db8d65a6c7a Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:34:27 +0530 Subject: [PATCH 08/24] CommentManagementAPIImpl --- .../mgt/store/api/services/impl/CommentManagementAPIImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java index 42cb4895f1..2ae8cb8b7e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/CommentManagementAPIImpl.java @@ -183,7 +183,7 @@ public class CommentManagementAPIImpl implements CommentManagementAPI { @PathParam("uuid") String uuid) { CommentsManager commentsManager = APIUtil.getCommentsManager(); - int ratedUsers = 0; + int ratedUsers; try { ratedUsers = commentsManager.getRatedUser(uuid); } catch (CommentManagementException e) { From 471e6e3b21e62e98c79950781644edbbe894b59a Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:37:47 +0530 Subject: [PATCH 09/24] CommentManagerImpl Variable values changed. --- .../application/mgt/core/impl/CommentsManagerImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java index 68f519de7e..6f8b6a1fa6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java @@ -141,7 +141,7 @@ public class CommentsManagerImpl implements CommentsManager { public Comment getComment(int commentId) throws CommentManagementException { PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - Comment comment = null; + Comment comment; if (log.isDebugEnabled()) { log.debug("Comment retrieval request is received for the comment id " + commentId); } @@ -215,7 +215,7 @@ public class CommentsManagerImpl implements CommentsManager { @Override public int getRatedUser(String uuid) throws ApplicationManagementException { - int ratedUsers = 0; + int ratedUsers; if (log.isDebugEnabled()) { log.debug("Get the rated users for the application release number" + uuid); } @@ -234,7 +234,7 @@ public class CommentsManagerImpl implements CommentsManager { @Override public int getStars(String uuid) throws ApplicationManagementException { - int stars = 0; + int stars; if (log.isDebugEnabled()) { log.debug("Get the average of rated stars for the application " + uuid); } @@ -256,7 +256,7 @@ public class CommentsManagerImpl implements CommentsManager { if (log.isDebugEnabled()) { log.debug("Stars are received for the application " + uuid); } - int newStars = 0; + int newStars; try { ConnectionManagerUtil.beginDBTransaction(); int ratedUsers = commentDAO.getRatedUser(uuid); From 20c1ba10522c6a8cf038c92897ade334f39935af Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:39:25 +0530 Subject: [PATCH 10/24] CommentManager Tenant Id variable was added to CommentManagerImpl class. --- .../application/mgt/common/services/CommentsManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java index 6428f11ceb..82beeca2c3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java @@ -35,12 +35,11 @@ public interface CommentsManager { * To add a comment to a application * * @param comment comment of the application. - * @param uuid uuid of the application release - * @param tenantId tenant id of the application + * @param uuid uuid of the application release\ * @return {@link Comment} Comment added * @throws CommentManagementException Exceptions of the comment management. */ - Comment addComment(Comment comment, String uuid, int tenantId) throws CommentManagementException; + Comment addComment(Comment comment, String uuid) throws CommentManagementException; /** * To validate the pre-request of the comment From 97915e29bebcf950b1cb02906636e50f30f97955 Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:40:18 +0530 Subject: [PATCH 11/24] Application mgt api Pom.xml changed --- .../pom.xml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml index 6ed2dd59bf..c10f0d7c59 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml @@ -157,6 +157,16 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.application.mgt.core provided + + + org.mockito + mockito-core + + + javassist + javassist + + org.wso2.carbon.devicemgt @@ -225,5 +235,15 @@ javax.ws.rs javax.ws.rs-api + + org.powermock + powermock-module-testng + test + + + org.powermock + powermock-api-mockito + test + \ No newline at end of file From 37f595d38221cdf308dea8b64716270b2ff88b0d Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 18:56:09 +0530 Subject: [PATCH 12/24] Added CommentManagementAPITest class Test of CommentManagementAPI class --- .../services/CommentManagementAPITest.java | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java new file mode 100644 index 0000000000..4e973ac251 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java @@ -0,0 +1,148 @@ +package org.wso2.carbon.device.application.mgt.store.api.services; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.mockito.Mockito; +import org.mockito.exceptions.base.MockitoException; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.testng.Assert; +import org.testng.IObjectFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.ObjectFactory; +import org.testng.annotations.Test; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.application.mgt.common.Comment; +import org.wso2.carbon.device.application.mgt.common.exception.CommentManagementException; +import org.wso2.carbon.device.application.mgt.common.services.CommentsManager; +import org.wso2.carbon.device.application.mgt.store.api.APIUtil; +import org.wso2.carbon.device.application.mgt.store.api.services.impl.CommentManagementAPIImpl; +import org.wso2.carbon.device.application.mgt.store.api.services.util.CommentMgtTestHelper; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +import javax.ws.rs.core.Response; + +import static org.mockito.MockitoAnnotations.initMocks; + +@PowerMockIgnore("javax.ws.rs.*") @SuppressStaticInitializationFor({ + "org.wso2.carbon.device.application.mgt.api.APIUtil" }) @PrepareForTest({ APIUtil.class, CommentsManager.class, + CommentManagementAPITest.class, MultitenantUtils.class }) public class CommentManagementAPITest { + private static final Log log = LogFactory.getLog(CommentManagementAPI.class); + + private CommentManagementAPI commentManagementAPI; + private CommentsManager commentsManager; + private int tenantId; + + @ObjectFactory public IObjectFactory getObjectFactory() { + return new org.powermock.modules.testng.PowerMockObjectFactory(); + } + + @BeforeClass void init() throws CommentManagementException { + + log.info("Initializing CommentManagementAPI tests"); + initMocks(this); + this.commentsManager = Mockito.mock(CommentsManager.class, Mockito.RETURNS_DEFAULTS); + this.commentManagementAPI = new CommentManagementAPIImpl(); + } + + @Test public void testGetAllCommentsWithValidDetails() throws Exception { + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + Response response = this.commentManagementAPI.getAllComments("a", 1, 2); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), + "The response status should be 200."); + Mockito.reset(commentsManager); + } + + @Test public void testAddComments() throws Exception { + Comment comment = CommentMgtTestHelper.getDummyComment("a", "a"); + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + // PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext")) + // .toReturn(Mockito.mock(PrivilegedCarbonContext.class, Mockito.RETURNS_MOCKS)); + // PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getTenantId")) + // .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS)); + Response response = this.commentManagementAPI.addComments(comment, null); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode(), + "The response status should be 201."); + Mockito.reset(commentsManager); + } + @Test public void testAddNullComment() throws Exception { + Comment comment=null; + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + // PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext")) + // .toReturn(Mockito.mock(PrivilegedCarbonContext.class, Mockito.RETURNS_MOCKS)); + // PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getTenantId")) + // .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS)); + Response response = this.commentManagementAPI.addComments(comment, null); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), + "The response status should be 400."); + Mockito.reset(commentsManager); + } + + @Test public void testUpdateComment() throws Exception { + Comment comment = CommentMgtTestHelper.getDummyComment("a", "a"); + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + Response response = this.commentManagementAPI.updateComment(comment, 1); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), + "The response status should be 200."); + } + @Test public void testUpdateNullComment() throws Exception { + Comment comment=null; + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + Response response = this.commentManagementAPI.updateComment(comment, 1); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), + "The response status should be 400."); + } + @Test public void testUpdateCommentWhenNullCommentId() throws Exception { + Comment comment = CommentMgtTestHelper.getDummyComment("a", "a"); + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + Response response = this.commentManagementAPI.updateComment(comment, 0); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode(), + "The response status should be 404."); + } + + @Test public void testGetStars() throws Exception { + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + Response response = this.commentManagementAPI.getStars("a"); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), + "The response status should be 200."); + Mockito.reset(commentsManager); + } + + @Test public void testGetRatedUser() throws Exception { + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + Response response = this.commentManagementAPI.getRatedUser("a"); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), + "The response status should be 200."); + Mockito.reset(commentsManager); + } + + @Test public void testUpdateStars() throws Exception { + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + Response response = this.commentManagementAPI.updateStars(3,"a"); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode(), + "The response status should be 200."); + Mockito.reset(commentsManager); + } + + @Test public void testUpdateInvalideStars() throws Exception { + PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); + Response response = this.commentManagementAPI.updateStars(0,"a"); + Assert.assertNotNull(response, "The response object is null."); + Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), + "The response status should be 400."); + Mockito.reset(commentsManager); + } + +} \ No newline at end of file From 87d48dca989136176f48ced108b84f2137799137 Mon Sep 17 00:00:00 2001 From: nishadi Date: Sat, 24 Feb 2018 19:14:10 +0530 Subject: [PATCH 13/24] Reformat CommentManagementAPITest class --- .../services/CommentManagementAPITest.java | 90 ++++++++++--------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java index 4e973ac251..db8ff71e03 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java @@ -3,7 +3,6 @@ package org.wso2.carbon.device.application.mgt.store.api.services; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mockito.Mockito; -import org.mockito.exceptions.base.MockitoException; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -13,8 +12,6 @@ import org.testng.IObjectFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.Comment; import org.wso2.carbon.device.application.mgt.common.exception.CommentManagementException; import org.wso2.carbon.device.application.mgt.common.services.CommentsManager; @@ -27,20 +24,24 @@ import javax.ws.rs.core.Response; import static org.mockito.MockitoAnnotations.initMocks; -@PowerMockIgnore("javax.ws.rs.*") @SuppressStaticInitializationFor({ - "org.wso2.carbon.device.application.mgt.api.APIUtil" }) @PrepareForTest({ APIUtil.class, CommentsManager.class, - CommentManagementAPITest.class, MultitenantUtils.class }) public class CommentManagementAPITest { +@PowerMockIgnore("javax.ws.rs.*") +@SuppressStaticInitializationFor({ + "org.wso2.carbon.device.application.mgt.api.APIUtil" }) +@PrepareForTest({ APIUtil.class, CommentsManager.class, + CommentManagementAPITest.class, MultitenantUtils.class }) +public class CommentManagementAPITest { private static final Log log = LogFactory.getLog(CommentManagementAPI.class); private CommentManagementAPI commentManagementAPI; private CommentsManager commentsManager; - private int tenantId; - @ObjectFactory public IObjectFactory getObjectFactory() { + @ObjectFactory + public IObjectFactory getObjectFactory() { return new org.powermock.modules.testng.PowerMockObjectFactory(); } - @BeforeClass void init() throws CommentManagementException { + @BeforeClass + void init() throws CommentManagementException { log.info("Initializing CommentManagementAPI tests"); initMocks(this); @@ -48,100 +49,103 @@ import static org.mockito.MockitoAnnotations.initMocks; this.commentManagementAPI = new CommentManagementAPIImpl(); } - @Test public void testGetAllCommentsWithValidDetails() throws Exception { + @Test + public void testGetAllCommentsWithValidDetails() throws Exception { PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); Response response = this.commentManagementAPI.getAllComments("a", 1, 2); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), - "The response status should be 200."); + "The response status should be 200."); Mockito.reset(commentsManager); } - @Test public void testAddComments() throws Exception { + @Test + public void testAddComments() throws Exception { Comment comment = CommentMgtTestHelper.getDummyComment("a", "a"); PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); - // PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext")) - // .toReturn(Mockito.mock(PrivilegedCarbonContext.class, Mockito.RETURNS_MOCKS)); - // PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getTenantId")) - // .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS)); Response response = this.commentManagementAPI.addComments(comment, null); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode(), - "The response status should be 201."); + "The response status should be 201."); Mockito.reset(commentsManager); } - @Test public void testAddNullComment() throws Exception { - Comment comment=null; + + @Test + public void testAddNullComment() throws Exception { PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); - // PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext")) - // .toReturn(Mockito.mock(PrivilegedCarbonContext.class, Mockito.RETURNS_MOCKS)); - // PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getTenantId")) - // .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS)); - Response response = this.commentManagementAPI.addComments(comment, null); + Response response = this.commentManagementAPI.addComments(null, "a"); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), - "The response status should be 400."); + "The response status should be 400."); Mockito.reset(commentsManager); } - @Test public void testUpdateComment() throws Exception { + @Test + public void testUpdateComment() throws Exception { Comment comment = CommentMgtTestHelper.getDummyComment("a", "a"); PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); Response response = this.commentManagementAPI.updateComment(comment, 1); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), - "The response status should be 200."); + "The response status should be 200."); } - @Test public void testUpdateNullComment() throws Exception { - Comment comment=null; + + @Test + public void testUpdateNullComment() throws Exception { PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); - Response response = this.commentManagementAPI.updateComment(comment, 1); + Response response = this.commentManagementAPI.updateComment(null, 1); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), - "The response status should be 400."); + "The response status should be 400."); } - @Test public void testUpdateCommentWhenNullCommentId() throws Exception { + + @Test + public void testUpdateCommentWhenNullCommentId() throws Exception { Comment comment = CommentMgtTestHelper.getDummyComment("a", "a"); PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); Response response = this.commentManagementAPI.updateComment(comment, 0); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode(), - "The response status should be 404."); + "The response status should be 404."); } - @Test public void testGetStars() throws Exception { + @Test + public void testGetStars() throws Exception { PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); Response response = this.commentManagementAPI.getStars("a"); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), - "The response status should be 200."); + "The response status should be 200."); Mockito.reset(commentsManager); } - @Test public void testGetRatedUser() throws Exception { + @Test + public void testGetRatedUser() throws Exception { PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); Response response = this.commentManagementAPI.getRatedUser("a"); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), - "The response status should be 200."); + "The response status should be 200."); Mockito.reset(commentsManager); } - @Test public void testUpdateStars() throws Exception { + @Test + public void testUpdateStars() throws Exception { PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); - Response response = this.commentManagementAPI.updateStars(3,"a"); + Response response = this.commentManagementAPI.updateStars(3, "a"); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode(), - "The response status should be 200."); + "The response status should be 200."); Mockito.reset(commentsManager); } - @Test public void testUpdateInvalideStars() throws Exception { + @Test + public void testUpdateInvalideStars() throws Exception { PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager); - Response response = this.commentManagementAPI.updateStars(0,"a"); + Response response = this.commentManagementAPI.updateStars(0, "a"); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), - "The response status should be 400."); + "The response status should be 400."); Mockito.reset(commentsManager); } From 891c3410eedc8abe5dafb4c28c69cfbfb25cd92d Mon Sep 17 00:00:00 2001 From: nishadi Date: Mon, 26 Feb 2018 22:56:39 +0530 Subject: [PATCH 14/24] CommentManagementAPITest class adding copyright message. --- .../api/services/CommentManagementAPITest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java index db8ff71e03..8e8d6db1db 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/CommentManagementAPITest.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.wso2.carbon.device.application.mgt.store.api.services; import org.apache.commons.logging.Log; From 9936bda78be0b5814b5b19d7dace143264a54c7e Mon Sep 17 00:00:00 2001 From: nishadi Date: Mon, 26 Feb 2018 23:14:17 +0530 Subject: [PATCH 15/24] CommentManagementAPITest class adding copyright message. --- .../mgt/store/api/services/util/CommentMgtTestHelper.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java index bb019a0e1f..6367a1fa16 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java @@ -19,9 +19,6 @@ package org.wso2.carbon.device.application.mgt.store.api.services.util; import org.wso2.carbon.device.application.mgt.common.Comment; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; import static org.wso2.carbon.registry.core.jdbc.DumpConstants.UUID; From dff3cf7645460413118819d6fbe5e0042072c4f1 Mon Sep 17 00:00:00 2001 From: nishadi Date: Mon, 26 Feb 2018 23:30:11 +0530 Subject: [PATCH 16/24] Reformatted the codes --- .../store/api/services/util/CommentMgtTestHelper.java | 11 ++++------- .../src/test/resources/log4j.properties | 4 ---- .../src/test/resources/testng.xml | 1 - 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java index 6367a1fa16..836d2798ae 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/java/org/wso2/carbon/device/application/mgt/store/api/services/util/CommentMgtTestHelper.java @@ -1,4 +1,3 @@ -package org.wso2.carbon.device.application.mgt.store.api.services.util; /* * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * @@ -16,12 +15,10 @@ package org.wso2.carbon.device.application.mgt.store.api.services.util; * specific language governing permissions and limitations * under the License. */ +package org.wso2.carbon.device.application.mgt.store.api.services.util; import org.wso2.carbon.device.application.mgt.common.Comment; - -import static org.wso2.carbon.registry.core.jdbc.DumpConstants.UUID; - /** * Helper class for Comment Management API test cases. */ @@ -30,9 +27,9 @@ public class CommentMgtTestHelper { private static final String COMMENT_TEXT = "Dummy Comment"; private static final String CREATED_BY = "TEST_CREATED_BY"; - private static final String MODIFIED_BY="TEST_MODIFIED_BY"; - private static final int PARENT_ID=123; - private static final int COMMENT_ID=1; + private static final String MODIFIED_BY = "TEST_MODIFIED_BY"; + private static final int PARENT_ID = 123; + private static final int COMMENT_ID = 1; /** * Creates a Comment with given text and given uuid. diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/log4j.properties b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/log4j.properties index 1dbcc0f635..d2bd747baf 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/log4j.properties +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/log4j.properties @@ -1,4 +1,3 @@ - # Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. # # WSO2 Inc. licenses this file to you under the Apache License, @@ -15,7 +14,6 @@ # specific language governing permissions and limitations # under the License. # - # # This is the log4j configuration file used by WSO2 Carbon # @@ -24,9 +22,7 @@ # can be changed using the WSO2 Carbon Management Console, and those # settings will override the settings in this file. # - log4j.rootLogger=DEBUG, STD_OUT - # Redirect log messages to console log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender log4j.appender.STD_OUT.Target=System.out diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/testng.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/testng.xml index ed1275edab..ab33c9c410 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/testng.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/test/resources/testng.xml @@ -1,4 +1,3 @@ -