diff options
author | avigaffa <avi.gaffa@amdocs.com> | 2018-11-28 11:57:09 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-11-28 12:57:01 +0000 |
commit | 069997b0692f69c8870718edf63f5703e848948d (patch) | |
tree | 0d4a7948228a6d2d9188f36642c4f8079176c4d9 /workflow-designer-be/src/test | |
parent | 958f25139cd0743c30fdc1b519be67ef9238f39e (diff) |
Workflow Deprecation - Archive Workflow
returning workflow archiving status in a field called "archiving" instead of "status" when listing workflows
Change-Id: Ib75696257ecef0ef0646c0465e0bf6cb6d0533c1
Issue-ID: SDC-1866
Signed-off-by: avigaffa <avi.gaffa@amdocs.com>
Diffstat (limited to 'workflow-designer-be/src/test')
-rw-r--r-- | workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java | 8 | ||||
-rw-r--r-- | workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java | 63 | ||||
-rw-r--r-- | workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidatorTest.java (renamed from workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/WorkflowStatusVelidatorTest.java) | 10 | ||||
-rw-r--r-- | workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java | 67 | ||||
-rw-r--r-- | workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java | 13 |
5 files changed, 84 insertions, 77 deletions
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java index 0a8355c9..0eb5ee77 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java @@ -3,22 +3,25 @@ package org.onap.sdc.workflow; import static org.onap.sdc.workflow.services.impl.ItemType.WORKFLOW; import org.onap.sdc.workflow.services.types.Workflow; +import org.onap.sdc.workflow.services.types.ArchivingStatus; import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdc.versioning.types.ItemStatus; public class TestUtil { - public static Workflow createWorkflow(int workflowNum, boolean createId) { + public static Workflow createWorkflow(int workflowNum, boolean createId, ArchivingStatus archivingStatus) { Workflow workflow = new Workflow(); if (createId) { workflow.setId(String.valueOf(workflowNum)); } workflow.setName("Workflow_" + workflowNum); workflow.setDescription("Description_" + workflowNum); + workflow.setArchiving(archivingStatus); return workflow; } - public static Item createItem(int itemNum, boolean setType, boolean setId) { + public static Item createItem(int itemNum, boolean setType, boolean setId, ItemStatus archivingStatus) { Item item = new Item(); if (setId) { item.setId(String.valueOf(itemNum)); @@ -28,6 +31,7 @@ public class TestUtil { if (setType) { item.setType(WORKFLOW.name()); } + item.setStatus(archivingStatus); return item; } 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 0c48fd64..51e60726 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 @@ -35,12 +35,12 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdc.workflow.RestPath; import org.onap.sdc.workflow.server.resolvers.UserIdResolver; import org.onap.sdc.workflow.services.WorkflowManager; +import org.onap.sdc.workflow.services.types.ArchivingStatus; 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.types.WorkflowStatus; import org.onap.sdc.workflow.services.utilities.JsonUtil; import org.springframework.data.web.PageableHandlerMethodArgumentResolver; import org.springframework.test.web.servlet.MockMvc; @@ -73,15 +73,14 @@ public class WorkflowControllerTest { @Test public void shouldReturnErrorWhenMissingUserIdInGetReqHeader() throws Exception { - Workflow workflowMock = createWorkflow(1, true); + Workflow workflowMock = createWorkflow(1, true, ArchivingStatus.ACTIVE); mockMvc.perform(get(RestPath.getWorkflowPath(workflowMock.getId())).contentType(APPLICATION_JSON)) - .andExpect(status().isBadRequest()) - .andExpect(jsonPath("$.message", is(MISSING_USER_HEADER_ERROR))); + .andExpect(status().isBadRequest()).andExpect(jsonPath("$.message", is(MISSING_USER_HEADER_ERROR))); } @Test public void shouldReturnWorkflowDataWhenRequestPathIsOk() throws Exception { - Workflow workflowMock = createWorkflow(1, true); + Workflow workflowMock = createWorkflow(1, true, ArchivingStatus.ACTIVE); doReturn(workflowMock).when(workflowManagerMock).get(any(Workflow.class)); mockMvc.perform(get(RestPath.getWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER, USER_ID) .contentType(APPLICATION_JSON)) @@ -97,18 +96,23 @@ public class WorkflowControllerTest { @Test public void shouldReturnOkWhenArchivingWorkflow() throws Exception { - Workflow workflowMock = createWorkflow(1, true); + Workflow workflowMock = createWorkflow(1, true, ArchivingStatus.ACTIVE); mockMvc.perform(post(RestPath.getArchiveWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER, USER_ID) - .contentType(APPLICATION_JSON).content("{\"status\": \"ARCHIVED\"}")).andExpect(status().isOk()); - verify(workflowManagerMock).updateStatus(workflowMock.getId(),WorkflowStatus.ARCHIVED); + .contentType(APPLICATION_JSON) + .content( + "{\"status\": \"ARCHIVED\"}")) + .andExpect(status().isOk()); + verify(workflowManagerMock).updateStatus(workflowMock.getId(), ArchivingStatus.ARCHIVED); } @Test public void shouldReturnOkWhenRestoringWorkflow() throws Exception { - Workflow workflowMock = createWorkflow(1, true); + Workflow workflowMock = createWorkflow(1, true, ArchivingStatus.ACTIVE); mockMvc.perform(post(RestPath.getArchiveWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER, USER_ID) - .contentType(APPLICATION_JSON).content("{\"status\": \"ACTIVE\"}")).andExpect(status().isOk()); - verify(workflowManagerMock).updateStatus(workflowMock.getId(),WorkflowStatus.ACTIVE); + .contentType(APPLICATION_JSON) + .content("{\"status\": \"ACTIVE\"}")) + .andExpect(status().isOk()); + verify(workflowManagerMock).updateStatus(workflowMock.getId(), ArchivingStatus.ACTIVE); } @Test @@ -116,8 +120,7 @@ public class WorkflowControllerTest { mockManagerList3(); ResultActions result = mockMvc.perform( get(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.items", hasSize(3))); + .andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3))); for (int i = 0; i < 3; i++) { result.andExpect(jsonPath(String.format("$.items[%s].id", i), is(String.valueOf(i + 1)))); } @@ -133,7 +136,8 @@ public class WorkflowControllerTest { .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3))); verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture()); - assertRequestSpec(requestSpecArg.getValue(), 1, 2, Collections.singletonList(new Sort("name", true))); + assertRequestSpec(requestSpecArg.getValue(), 1, 2, + Collections.singletonList(new Sort("name", true))); } @Test @@ -204,10 +208,10 @@ public class WorkflowControllerTest { public void shouldCreateWorkflowWhenCallingPostRestRequest() throws Exception { Item item = new Item(); item.setId(new Id("abc")); - Workflow reqWorkflow = createWorkflow(1, false); + Workflow reqWorkflow = createWorkflow(1, false, any()); mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) - .content(JsonUtil.object2Json(reqWorkflow))) - .andExpect(status().isCreated()); + .content(JsonUtil.object2Json(reqWorkflow))) + .andExpect(status().isCreated()); verify(workflowManagerMock).create(reqWorkflow); } @@ -216,8 +220,8 @@ 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(JsonUtil.object2Json(reqWorkflow))) - .andExpect(status().isBadRequest()).andExpect( + .content(JsonUtil.object2Json(reqWorkflow))) + .andExpect(status().isBadRequest()).andExpect( jsonPath("$.message", is("Workflow name must contain only letters, digits and underscores."))); } @@ -253,11 +257,10 @@ public class WorkflowControllerTest { Workflow reqWorkflow = new Workflow(); reqWorkflow.setName("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) - .content(JsonUtil.object2Json(reqWorkflow))).andExpect( - status().isBadRequest()).andExpect(jsonPath("$.message", is( - "Workflow name must be at least " + MIN_LENGTH - + " characters, and no more than " + MAX_LENGTH - + " characters."))); + .content(JsonUtil.object2Json(reqWorkflow))) + .andExpect(status().isBadRequest()).andExpect(jsonPath("$.message", + is("Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH + + " characters."))); } @Test @@ -265,15 +268,15 @@ public class WorkflowControllerTest { Workflow reqWorkflow = new Workflow(); reqWorkflow.setName("AAA"); mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) - .content(JsonUtil.object2Json(reqWorkflow))).andExpect( - status().isBadRequest()).andExpect(jsonPath("$.message", - is("Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " - + MAX_LENGTH + " characters."))); + .content(JsonUtil.object2Json(reqWorkflow))) + .andExpect(status().isBadRequest()).andExpect(jsonPath("$.message", + is("Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH + + " characters."))); } private void mockManagerList3() { - doReturn(new Page<>(Arrays.asList(createWorkflow(1, true), - createWorkflow(2, true), createWorkflow(3, true)), + doReturn(new Page<>(Arrays.asList(createWorkflow(1, true, ArchivingStatus.ACTIVE), + createWorkflow(2, true, ArchivingStatus.ACTIVE), createWorkflow(3, true, ArchivingStatus.ACTIVE)), new PagingRequest(DEFAULT_OFFSET, DEFAULT_LIMIT), 3)).when(workflowManagerMock) .list(any(), any(), any(), any()); } diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/WorkflowStatusVelidatorTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidatorTest.java index 289c9353..d5e5f20d 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/WorkflowStatusVelidatorTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidatorTest.java @@ -31,7 +31,7 @@ import org.mockito.MockitoAnnotations; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -public class WorkflowStatusVelidatorTest { +public class ArchivingStatusValidatorTest { class AnnotationWrapper { @@ -46,14 +46,14 @@ public class WorkflowStatusVelidatorTest { @Mock private ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext nodeBuilderCustomizableContext; - private WorkflowStatusValidator validator; + private ArchivingStatusValidator validator; @Before public void setup() throws NoSuchFieldException { MockitoAnnotations.initMocks(this); when(context.buildConstraintViolationWithTemplate(anyString())).thenReturn(constraintViolationBuilder); when(constraintViolationBuilder.addPropertyNode(anyString())).thenReturn(nodeBuilderCustomizableContext); - validator = initializeValidator(WorkflowStatusVelidatorTest.AnnotationWrapper.class); + validator = initializeValidator(ArchivingStatusValidatorTest.AnnotationWrapper.class); } @Test @@ -79,10 +79,10 @@ public class WorkflowStatusVelidatorTest { - private WorkflowStatusValidator initializeValidator(Class<?> classWithAnnotation) + private ArchivingStatusValidator initializeValidator(Class<?> classWithAnnotation) throws NoSuchFieldException { ValidStatus constraint = classWithAnnotation.getField("status").getAnnotation(ValidStatus.class); - WorkflowStatusValidator validator = new WorkflowStatusValidator(); + ArchivingStatusValidator validator = new ArchivingStatusValidator(); validator.initialize(constraint); return validator; } diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java index 702da4c8..7016ebdb 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java @@ -31,6 +31,7 @@ import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException; import org.onap.sdc.workflow.services.exceptions.WorkflowStatusModificationException; import org.onap.sdc.workflow.services.impl.mappers.VersionStateMapper; import org.onap.sdc.workflow.services.impl.mappers.WorkflowMapper; +import org.onap.sdc.workflow.services.types.ArchivingStatus; import org.onap.sdc.workflow.services.types.Page; import org.onap.sdc.workflow.services.types.Paging; import org.onap.sdc.workflow.services.types.PagingRequest; @@ -38,10 +39,8 @@ import org.onap.sdc.workflow.services.types.RequestSpec; import org.onap.sdc.workflow.services.types.Sort; import org.onap.sdc.workflow.services.types.SortingRequest; import org.onap.sdc.workflow.services.types.Workflow; -import org.onap.sdc.workflow.services.types.WorkflowStatus; import org.onap.sdc.workflow.services.types.WorkflowVersionState; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.versioning.ItemManager; import org.openecomp.sdc.versioning.types.Item; @@ -63,8 +62,8 @@ public class WorkflowManagerImplTest { List<Item> items = new ArrayList<>(); List<Workflow> mappedWorkflows = new ArrayList<>(); for (int i = 0; i < 5; i++) { - items.add(createItem(i, true, true)); - mappedWorkflows.add(createWorkflow(i, true)); + items.add(createItem(i, true, true, ItemStatus.ACTIVE)); + mappedWorkflows.add(createWorkflow(i, true, ArchivingStatus.ACTIVE)); } ITEMS = Collections.unmodifiableList(items); MAPPED_WORKFLOWS = Collections.unmodifiableList(mappedWorkflows); @@ -86,7 +85,7 @@ public class WorkflowManagerImplTest { doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); RequestSpec requestSpec = createRequestSpec(0, 20, true); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); Map<String, Workflow> workflowById = workflows.getItems().stream().collect(Collectors.toMap(Workflow::getId, Function.identity())); @@ -108,7 +107,7 @@ public class WorkflowManagerImplTest { RequestSpec requestSpec = createRequestSpec(0, 20, true); Page<Workflow> workflows = - workflowManager.list(null,null,Collections.singleton(WorkflowVersionState.CERTIFIED), requestSpec); + workflowManager.list(null, null, Collections.singleton(WorkflowVersionState.CERTIFIED), requestSpec); Map<String, Workflow> workflowById = workflows.getItems().stream().collect(Collectors.toMap(Workflow::getId, Function.identity())); @@ -122,7 +121,7 @@ public class WorkflowManagerImplTest { @Test(expected = EntityNotFoundException.class) public void shouldThrowExceptionWhenWorkflowDontExistTryingToUpdateStatus() { doReturn(null).when(itemManagerMock).get(ITEM1_ID); - workflowManager.updateStatus(ITEM1_ID,WorkflowStatus.ARCHIVED); + workflowManager.updateStatus(ITEM1_ID, ArchivingStatus.ARCHIVED); } @Test(expected = WorkflowStatusModificationException.class) @@ -132,7 +131,7 @@ public class WorkflowManagerImplTest { mockItem.setStatus(ItemStatus.ARCHIVED); doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); doThrow(new CoreException(new ErrorCode.ErrorCodeBuilder().build())).when(itemManagerMock).archive(mockItem); - workflowManager.updateStatus(ITEM1_ID,WorkflowStatus.ARCHIVED); + workflowManager.updateStatus(ITEM1_ID, ArchivingStatus.ARCHIVED); } @Test @@ -141,7 +140,7 @@ public class WorkflowManagerImplTest { mockItem.setId(ITEM1_ID); mockItem.setStatus(ItemStatus.ACTIVE); doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); - workflowManager.updateStatus(ITEM1_ID,WorkflowStatus.ARCHIVED); + workflowManager.updateStatus(ITEM1_ID, ArchivingStatus.ARCHIVED); verify(itemManagerMock).archive(mockItem); } @@ -151,7 +150,7 @@ public class WorkflowManagerImplTest { mockItem.setId(ITEM1_ID); mockItem.setStatus(ItemStatus.ARCHIVED); doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); - workflowManager.updateStatus(ITEM1_ID,WorkflowStatus.ACTIVE); + workflowManager.updateStatus(ITEM1_ID, ArchivingStatus.ACTIVE); verify(itemManagerMock).restore(mockItem); } @@ -166,9 +165,9 @@ public class WorkflowManagerImplTest { @Test public void shouldReturnWorkflow() { - Item retrievedItem = createItem(1, true, true); + Item retrievedItem = createItem(1, true, true, ItemStatus.ACTIVE); doReturn(retrievedItem).when(itemManagerMock).get(ITEM1_ID); - Workflow workflow = createWorkflow(1, true); + Workflow workflow = createWorkflow(1, true, ArchivingStatus.ACTIVE); workflowManager.get(workflow); verify(itemManagerMock).get(ITEM1_ID); verify(workflowMapperMock).itemToWorkflow(retrievedItem); @@ -176,26 +175,24 @@ public class WorkflowManagerImplTest { @Test public void shouldCreateWorkflowItemFromWorkflow() { - Workflow workflowToBeCreated = createWorkflow(1, false); - Item createdWorkflowItem = createItem(1, false, true); + Workflow workflowToBeCreated = createWorkflow(1, false, ArchivingStatus.ACTIVE); + Item createdWorkflowItem = createItem(1, false, true, ItemStatus.ACTIVE); doReturn(createdWorkflowItem).when(workflowMapperMock).workflowToItem(workflowToBeCreated); doReturn(createdWorkflowItem).when(itemManagerMock).create(createdWorkflowItem); workflowManager.create(workflowToBeCreated); - verify(uniqueValueServiceMock) - .validateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflowToBeCreated.getName()}); + verify(uniqueValueServiceMock).validateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, workflowToBeCreated.getName()); createdWorkflowItem.setStatus(ItemStatus.ACTIVE); createdWorkflowItem.setType(WORKFLOW_TYPE); verify(itemManagerMock).create(createdWorkflowItem); - verify(uniqueValueServiceMock) - .createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflowToBeCreated.getName()}); + verify(uniqueValueServiceMock).createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, workflowToBeCreated.getName()); } @Test public void shouldUpdateWorkflow() { - Item workflowItem = createItem(1, true, true); + Item workflowItem = createItem(1, true, true, ItemStatus.ACTIVE); doReturn(workflowItem).when(itemManagerMock).get(ITEM1_ID); - Workflow workflowToBeUpdated = createWorkflow(1, true); + Workflow workflowToBeUpdated = createWorkflow(1, true, ArchivingStatus.ACTIVE); doReturn(workflowItem).when(workflowMapperMock).workflowToItem(workflowToBeUpdated); workflowManager.update(workflowToBeUpdated); verify(itemManagerMock).update(workflowItem); @@ -207,14 +204,14 @@ public class WorkflowManagerImplTest { @Test(expected = EntityNotFoundException.class) public void shouldThrowExceptionWhenWorkflowToUpdateNotFound() { doReturn(null).when(itemManagerMock).get(ITEM1_ID); - workflowManager.update(createWorkflow(1, true)); + workflowManager.update(createWorkflow(1, true, ArchivingStatus.ACTIVE)); } @Test public void listWhenRequestSpecIsNull() { doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, null); + Page<Workflow> workflows = workflowManager.list(null, null, null, null); assertEquals(ITEMS.size(), workflows.getItems().size()); assertPaging(workflows.getPaging(), DEFAULT_OFFSET, DEFAULT_LIMIT, ITEMS.size()); @@ -229,8 +226,8 @@ public class WorkflowManagerImplTest { public void listWhenPagingIsNull() { doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, new RequestSpec(null, - SortingRequest.builder().sort(new Sort(SORT_FIELD_NAME, true)).build())); + Page<Workflow> workflows = workflowManager.list(null, null, null, + new RequestSpec(null, SortingRequest.builder().sort(new Sort(SORT_FIELD_NAME, true)).build())); assertEquals(ITEMS.size(), workflows.getItems().size()); assertPaging(workflows.getPaging(), DEFAULT_OFFSET, DEFAULT_LIMIT, ITEMS.size()); @@ -242,7 +239,7 @@ public class WorkflowManagerImplTest { mockItemToWorkflowMaps(); RequestSpec requestSpec = new RequestSpec(new PagingRequest(-2, -8), SortingRequest.builder().sort(new Sort(SORT_FIELD_NAME, true)).build()); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(ITEMS.size(), workflows.getItems().size()); assertPaging(workflows.getPaging(), DEFAULT_OFFSET, DEFAULT_LIMIT, ITEMS.size()); @@ -253,7 +250,7 @@ public class WorkflowManagerImplTest { doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); RequestSpec requestSpec = new RequestSpec(new PagingRequest(2, 8), null); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(3, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), @@ -270,7 +267,7 @@ public class WorkflowManagerImplTest { doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); RequestSpec requestSpec = new RequestSpec(new PagingRequest(2, 8), SortingRequest.builder().build()); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(3, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), @@ -287,7 +284,7 @@ public class WorkflowManagerImplTest { RequestSpec requestSpec = createRequestSpec(0, 5, true); doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(5, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), @@ -299,7 +296,7 @@ public class WorkflowManagerImplTest { RequestSpec requestSpec = createRequestSpec(0, 3, true); doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(3, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), ITEMS.size()); @@ -311,7 +308,7 @@ public class WorkflowManagerImplTest { RequestSpec requestSpec = createRequestSpec(3, 1, true); doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(1, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), ITEMS.size()); @@ -322,7 +319,7 @@ public class WorkflowManagerImplTest { RequestSpec requestSpec = createRequestSpec(0, 10, true); doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(5, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), ITEMS.size()); @@ -333,7 +330,7 @@ public class WorkflowManagerImplTest { RequestSpec requestSpec = createRequestSpec(6, 3, true); doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(0, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), ITEMS.size()); @@ -344,7 +341,7 @@ public class WorkflowManagerImplTest { doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); RequestSpec requestSpec = createRequestSpec(0, 5555, true); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(ITEMS.size(), workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), MAX_LIMIT, ITEMS.size()); @@ -355,7 +352,7 @@ public class WorkflowManagerImplTest { RequestSpec requestSpec = createRequestSpec(10, 10, true); doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(0, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), ITEMS.size()); @@ -366,7 +363,7 @@ public class WorkflowManagerImplTest { RequestSpec requestSpec = createRequestSpec(2, 1, false); doReturn(ITEMS).when(itemManagerMock).list(any()); mockItemToWorkflowMaps(); - Page<Workflow> workflows = workflowManager.list(null,null,null, requestSpec); + Page<Workflow> workflows = workflowManager.list(null, null, null, requestSpec); assertEquals(1, workflows.getItems().size()); assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), ITEMS.size()); diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java index d6e16d57..843e89e1 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java @@ -2,14 +2,15 @@ package org.onap.sdc.workflow.services.impl.mappers; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.onap.sdc.workflow.TestUtil.createItem; import static org.onap.sdc.workflow.TestUtil.createWorkflow; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.sdc.workflow.services.types.Workflow; +import org.onap.sdc.workflow.services.types.ArchivingStatus; import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdc.versioning.types.ItemStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -30,21 +31,23 @@ public class WorkflowMapperTest { @Test public void shouldMapItemToWorkflow() { - Item item = createItem(1,false,true); + Item item = createItem(1, false, true, ItemStatus.ACTIVE); Workflow mappedWorkflow = workflowMapper.itemToWorkflow(item); assertEquals(mappedWorkflow.getId(), item.getId()); assertEquals(mappedWorkflow.getDescription(), item.getDescription()); assertEquals(mappedWorkflow.getName(), item.getName()); + assertEquals(mappedWorkflow.getArchiving().name(), item.getStatus().name()); } @Test - public void shouldMapWorkflowToItem(){ + public void shouldMapWorkflowToItem() { - Workflow workflow = createWorkflow(1,true); - Item mappedItem = workflowMapper.workflowToItem(workflow); + Workflow workflow = createWorkflow(1, true, ArchivingStatus.ARCHIVED); + Item mappedItem = workflowMapper.workflowToItem(workflow); assertEquals(mappedItem.getId(), workflow.getId()); assertEquals(mappedItem.getDescription(), workflow.getDescription()); assertEquals(mappedItem.getName(), workflow.getName()); + assertEquals(mappedItem.getStatus().name(), workflow.getArchiving().name()); } }
\ No newline at end of file |