diff options
author | YuanHu <yuan.hu1@zte.com.cn> | 2018-03-21 09:49:49 +0800 |
---|---|---|
committer | YuanHu <yuan.hu1@zte.com.cn> | 2018-03-21 09:49:49 +0800 |
commit | 9fa39e6651f1a7b0bea252cab6c72cc81304a132 (patch) | |
tree | 8a4ebdf762433e573d5cd9423d0e55491d736a41 | |
parent | 70410b3ef0fd4c2325431436365be82c2663a5ed (diff) |
Refactor.
Code Optimization
Issue-ID: SDC-1079
Change-Id: I8e44498a762ab9072861b0258765efe8eb0ad9fe
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
2 files changed, 10 insertions, 11 deletions
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java index 600ec8ca..d5bbdd4a 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java @@ -46,12 +46,12 @@ import io.swagger.annotations.ApiResponses; @Path("/ext-activities") @Api(tags = {"Workflow Modeler"}) public class ExtendActivityResource { + private static final Logger LOGGER = LoggerFactory.getLogger(ExtendActivityResource.class); + /** */ private static final String EXT_ACTIVITIES_DISPLAY_INFO_FILE_NAME = "ext-activities-display-info.json"; - private static final Logger LOGGER = LoggerFactory.getLogger(ExtendActivityResource.class); - - private static final String EXT_ACTIVITIES_FILE_NAME = "..\\distribution\\src\\main\\assembly\\ext-activities.json"; + private static final String EXT_ACTIVITIES_FILE_NAME = "ext-activities.json"; /** * test function. @@ -88,7 +88,7 @@ public class ExtendActivityResource { * @return * @throws IOException */ - private ExtendActivity[] retriveExtActivites(String sence) throws IOException { + protected ExtendActivity[] retriveExtActivites(String sence) throws IOException { String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME); return JsonUtils.fromJson(json, ExtendActivity[].class); } diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java index 18a8597a..060008b3 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java @@ -13,8 +13,6 @@ package org.onap.sdc.workflowdesigner.resources; import static org.junit.Assert.assertEquals;
-import javax.ws.rs.core.Response;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -26,6 +24,7 @@ import org.onap.sdc.workflowdesigner.utils.JsonUtils; *
*/
public class ExtendActivityResourceTest {
+ private static final String EXT_ACTIVITIES_FILE_NAME = "..\\distribution\\src\\main\\assembly\\ext-activities.json";
/**
* @throws java.lang.Exception
@@ -40,14 +39,14 @@ public class ExtendActivityResourceTest { public void tearDown() throws Exception {}
/**
- * Test method for {@link org.onap.sdc.workflowdesigner.resources.ExtendActivityResource#getExtActivities(java.lang.String)}.
+ * Test method for {@link org.onap.sdc.workflowdesigner.resources.ExtendActivityResource#retriveExtActivites(java.lang.String)}.
*/
@Test
- public void testGetExtActivities() {
- ExtendActivityResource resource = new ExtendActivityResource();
+ public void testRetriveExtActivites() {
try {
- Response response = resource.getExtActivities("test");
- ExtendActivity[] extActivities = (ExtendActivity[]) response.getEntity();
+ String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME);
+ ExtendActivity[] extActivities = JsonUtils.fromJson(json, ExtendActivity[].class);
+
FileCommonUtils.write("test.json", JsonUtils.toJson(extActivities));
assertEquals(extActivities.length == 0, false);
} catch (Exception e) {
|