aboutsummaryrefslogtreecommitdiffstats
path: root/workflow-designer-be/src/test/java
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2018-08-12 11:53:00 +0300
committertalig <talig@amdocs.com>2018-08-12 11:53:00 +0300
commita158feee847d1c591f1089fbb75c0fba8f1a3e27 (patch)
tree1437aabff0f60ddb0fb84f6b5c1e07d33f39397f /workflow-designer-be/src/test/java
parent2b2107ebdb0defc9f87e474995b09bb96463e593 (diff)
Add JsonUtil and use it
Get rid of org.openecomp.core.utilities.json.JsonUtil Change-Id: I1dff97931dd76dde80c383baca9ff9e28e23d8ad Issue-ID: SDC-1606 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'workflow-designer-be/src/test/java')
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java15
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java11
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java2
3 files changed, 13 insertions, 15 deletions
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java
index 3438093d..a748dd5f 100644
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java
+++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java
@@ -19,7 +19,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.item.Item;
-import com.google.gson.Gson;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -32,12 +31,13 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.sdc.workflow.RestPath;
-import org.onap.sdc.workflow.services.types.Workflow;
import org.onap.sdc.workflow.services.WorkflowManager;
import org.onap.sdc.workflow.services.types.Page;
import org.onap.sdc.workflow.services.types.PagingRequest;
import org.onap.sdc.workflow.services.types.RequestSpec;
import org.onap.sdc.workflow.services.types.Sort;
+import org.onap.sdc.workflow.services.types.Workflow;
+import org.onap.sdc.workflow.services.utilities.JsonUtil;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
@@ -49,7 +49,6 @@ public class WorkflowControllerTest {
private static final String USER_ID = "userId";
private static final String MISSING_USER_HEADER_ERROR =
"Missing request header 'USER_ID' for method parameter of type String";
- private static final Gson GSON = new Gson();
private static final String DEFAULT_SORT_VALUE = "name:asc";
private MockMvc mockMvc;
@@ -187,8 +186,8 @@ public class WorkflowControllerTest {
item.setId(new Id("abc"));
Workflow reqWorkflow = createWorkflow(1, false);
mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)
- .content(GSON.toJson(reqWorkflow))).andDo(print())
- .andExpect(status().isCreated());
+ .content(JsonUtil.object2Json(reqWorkflow))).andDo(print())
+ .andExpect(status().isCreated());
verify(workflowManagerMock).create(reqWorkflow);
}
@@ -197,9 +196,9 @@ public class WorkflowControllerTest {
Workflow reqWorkflow = new Workflow();
reqWorkflow.setName("Invalid workflow name %");
mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)
- .content(GSON.toJson(reqWorkflow))).andDo(print())
- .andExpect(status().isBadRequest())
- .andExpect(jsonPath("$.message", is("Workflow name must contain only letters, digits and underscores")));
+ .content(JsonUtil.object2Json(reqWorkflow))).andDo(print())
+ .andExpect(status().isBadRequest()).andExpect(
+ jsonPath("$.message", is("Workflow name must contain only letters, digits and underscores")));
}
private void mockManagerList3() {
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java
index 2b3c49c1..2ed1cc16 100644
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java
+++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java
@@ -14,7 +14,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import com.google.gson.Gson;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Before;
@@ -28,6 +27,7 @@ import org.onap.sdc.workflow.persistence.types.ParameterEntity;
import org.onap.sdc.workflow.persistence.types.ParameterType;
import org.onap.sdc.workflow.services.WorkflowVersionManager;
import org.onap.sdc.workflow.services.types.WorkflowVersion;
+import org.onap.sdc.workflow.services.utilities.JsonUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.springframework.http.HttpStatus;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -42,8 +42,6 @@ public class WorkflowVersionControllerTest {
private static final String VERSION1_ID = "version_id_1";
private static final String VERSION2_ID = "version_id_2";
- private static final Gson GSON = new Gson();
-
private MockMvc mockMvc;
@Mock
@@ -76,7 +74,7 @@ public class WorkflowVersionControllerTest {
WorkflowVersion version = new WorkflowVersion();
version.setDescription("VersionDescription");
mockMvc.perform(post(RestPath.getWorkflowVersions(ITEM1_ID)).header(RestParams.USER_ID_HEADER, USER_ID)
- .contentType(APPLICATION_JSON).content(GSON.toJson(version)))
+ .contentType(APPLICATION_JSON).content(JsonUtil.object2Json(version)))
.andExpect(status().isCreated());
verify(workflowVersionManagerMock, times(1)).create(ITEM1_ID, null, version);
@@ -91,7 +89,7 @@ public class WorkflowVersionControllerTest {
version.setInputs(inputs);
version.setDescription("VersionDescription");
mockMvc.perform(post(RestPath.getWorkflowVersions(ITEM1_ID)).header(RestParams.USER_ID_HEADER, USER_ID)
- .contentType(APPLICATION_JSON).content(GSON.toJson(version)))
+ .contentType(APPLICATION_JSON).content(JsonUtil.object2Json(version)))
.andExpect(status().isBadRequest());
}
@@ -115,7 +113,8 @@ public class WorkflowVersionControllerTest {
MockHttpServletResponse result = mockMvc.perform(
put(RestPath.getWorkflowVersion(ITEM1_ID, VERSION1_ID)).header(RestParams.USER_ID_HEADER, USER_ID)
- .contentType(APPLICATION_JSON).content(GSON.toJson(version))).andReturn().getResponse();
+ .contentType(APPLICATION_JSON).content(JsonUtil.object2Json(version))).andReturn()
+ .getResponse();
assertEquals(HttpStatus.OK.value(), result.getStatus());
version.setId(VERSION1_ID);
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java
index 999097c2..bbae56e3 100644
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java
+++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java
@@ -55,7 +55,7 @@ import org.onap.sdc.workflow.persistence.impl.types.ActivitySpecData;
import org.onap.sdc.workflow.persistence.impl.types.ActivitySpecElementType;
import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity;
import org.onap.sdc.workflow.persistence.types.ActivitySpecParameter;
-import org.openecomp.core.utilities.json.JsonUtil;
+import org.onap.sdc.workflow.services.utilities.JsonUtil;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.versioning.dao.types.Version;