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 | |
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>
16 files changed, 123 insertions, 117 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java index 8eb22390..ff06f828 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java @@ -35,12 +35,12 @@ import org.onap.sdc.workflow.api.types.WorkflowStatusDto; import org.onap.sdc.workflow.services.WorkflowManager; import org.onap.sdc.workflow.services.WorkflowVersionManager; import org.onap.sdc.workflow.services.annotations.UserId; +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.SortingRequest; import org.onap.sdc.workflow.services.types.Workflow; -import org.onap.sdc.workflow.services.types.WorkflowStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; @@ -126,7 +126,7 @@ public class WorkflowController { @ApiOperation("Update workflow status") public ResponseEntity updateStatus(@RequestBody @Valid WorkflowStatusDto request, @PathVariable("workflowId") String workflowId, @UserId String user) { - workflowManager.updateStatus(workflowId,WorkflowStatus.valueOf(request.getStatus())); + workflowManager.updateStatus(workflowId, ArchivingStatus.valueOf(request.getStatus())); return new ResponseEntity(HttpStatus.OK); } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java index ebc7d693..cc17f928 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java @@ -45,9 +45,8 @@ public class VersionStatesFormatter { return value == null ? null : Arrays.stream(value.split(",")).map(WorkflowVersionState::valueOf) .collect(Collectors.toSet()); } catch (IllegalArgumentException ex) { - LOGGER.warn(String.format( - "value %s is invalid and cannot be formatted to a set of version states, therefore it set to empty set", - value), ex); + LOGGER.warn("value {} is invalid and cannot be formatted to a set of version states, " + + "therefore it set to empty set", value, ex); return Collections.emptySet(); } } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/WorkflowStatusValidator.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidator.java index b99b424a..bfbf7580 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/WorkflowStatusValidator.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidator.java @@ -18,9 +18,9 @@ package org.onap.sdc.workflow.api.validation; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import org.onap.sdc.workflow.services.types.WorkflowStatus; +import org.onap.sdc.workflow.services.types.ArchivingStatus; -public class WorkflowStatusValidator implements ConstraintValidator<ValidStatus, String> { +public class ArchivingStatusValidator implements ConstraintValidator<ValidStatus, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { @@ -28,7 +28,7 @@ public class WorkflowStatusValidator implements ConstraintValidator<ValidStatus, return false; } else { try { - Enum.valueOf(WorkflowStatus.class, value); + Enum.valueOf(ArchivingStatus.class, value); return true; } catch (IllegalArgumentException var3) { return false; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ValidStatus.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ValidStatus.java index 96325919..15778b1d 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ValidStatus.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ValidStatus.java @@ -27,7 +27,7 @@ import javax.validation.Payload; @Target({ElementType.TYPE, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented -@Constraint(validatedBy = {WorkflowStatusValidator.class}) +@Constraint(validatedBy = {ArchivingStatusValidator.class}) public @interface ValidStatus { String message(); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java index 0f8f27e2..2c7a7c24 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java @@ -17,10 +17,10 @@ package org.onap.sdc.workflow.services; import java.util.Set; +import org.onap.sdc.workflow.services.types.ArchivingStatus; import org.onap.sdc.workflow.services.types.Page; import org.onap.sdc.workflow.services.types.RequestSpec; import org.onap.sdc.workflow.services.types.Workflow; -import org.onap.sdc.workflow.services.types.WorkflowStatus; import org.onap.sdc.workflow.services.types.WorkflowVersionState; public interface WorkflowManager { @@ -33,5 +33,5 @@ public interface WorkflowManager { void update(Workflow workflow); - void updateStatus(String workflowId, WorkflowStatus status); + void updateStatus(String workflowId, ArchivingStatus status); } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java index 3cfaf4ae..640affe8 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java @@ -127,7 +127,7 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { public void update(ActivitySpecEntity activitySpec) { Item retrievedItem = itemManager.get(activitySpec.getId()); if (retrievedItem == null) { - LOGGER.error(String.format("Activity Spec with id %s was not found", activitySpec.getId())); + LOGGER.error("Activity Spec with id {} was not found", activitySpec.getId()); throw new EntityNotFoundException(ACTIVITY_SPEC_NOT_FOUND); } uniqueValueService.updateUniqueValue(ACTIVITY_SPEC_NAME, retrievedItem.getName(), activitySpec.getName()); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java index 27257b49..3d9cda51 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java @@ -40,7 +40,7 @@ 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.ArchivingStatus; import org.onap.sdc.workflow.services.types.WorkflowVersionState; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.logging.api.Logger; @@ -94,6 +94,7 @@ public class WorkflowManagerImpl implements WorkflowManager { .skip(requestSpec.getPaging().getOffset()) .limit(requestSpec.getPaging().getLimit()) .collect(Collectors.toList()); + return new Page<>(workflowsSlice, requestSpec.getPaging(), workflowItems.size()); } @@ -101,7 +102,6 @@ public class WorkflowManagerImpl implements WorkflowManager { public Workflow get(Workflow workflow) { Item retrievedItem = itemManager.get(workflow.getId()); if (retrievedItem == null) { - LOGGER.error(String.format("Workflow with id %s was not found", workflow.getId())); throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflow.getId())); } return this.workflowMapper.itemToWorkflow(retrievedItem); @@ -123,7 +123,6 @@ public class WorkflowManagerImpl implements WorkflowManager { public void update(Workflow workflow) { Item retrievedItem = itemManager.get(workflow.getId()); if (retrievedItem == null) { - LOGGER.error(String.format("Workflow with id %s was not found", workflow.getId())); throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflow.getId())); } @@ -141,16 +140,15 @@ public class WorkflowManagerImpl implements WorkflowManager { } @Override - public void updateStatus(String workflowId, WorkflowStatus status) { + public void updateStatus(String workflowId, ArchivingStatus status) { Item item = itemManager.get(workflowId); if (item == null) { - LOGGER.error(String.format("Workflow with id %s was not found",workflowId)); throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflowId)); } try { - if (WorkflowStatus.ARCHIVED.equals(status)) { + if (ArchivingStatus.ARCHIVED.equals(status)) { itemManager.archive(item); - } else if (WorkflowStatus.ACTIVE.equals(status)) { + } else if (ArchivingStatus.ACTIVE.equals(status)) { itemManager.restore(item); } } catch (CoreException ex) { @@ -158,7 +156,7 @@ public class WorkflowManagerImpl implements WorkflowManager { } } - private static RequestSpec getRequestSpec(RequestSpec requestSpec) { + private static RequestSpec getRequestSpec(RequestSpec requestSpec) { if (requestSpec == null) { return WORKSPACES_DEFAULT_REQUEST_SPEC; } @@ -196,10 +194,10 @@ public class WorkflowManagerImpl implements WorkflowManager { private Predicate<Item> createFilter(String itemStatusFilter, String searchNameFilter, Set<WorkflowVersionState> versionStatesFilter) { - Set<VersionStatus> versionStatusesFilter = - versionStatesFilter == null ? null : - versionStatesFilter.stream().map(versionStateMapper::workflowVersionStateToVersionStatus) - .collect(Collectors.toSet()); + Set<VersionStatus> versionStatusesFilter = versionStatesFilter == null ? null : + versionStatesFilter.stream() + .map(versionStateMapper::workflowVersionStateToVersionStatus) + .collect(Collectors.toSet()); Predicate<Item> filter = addSearchNameFilter(WORKFLOW_ITEM_TYPE_FILTER, searchNameFilter); @@ -210,13 +208,13 @@ public class WorkflowManagerImpl implements WorkflowManager { } private static Predicate<Item> addSearchNameFilter(Predicate<Item> filter, String searchNameFilter) { - return filter.and(item -> searchNameFilter == null - || item.getName().toLowerCase().contains(searchNameFilter.toLowerCase())); + return filter.and(item -> searchNameFilter == null || item.getName().toLowerCase() + .contains(searchNameFilter.toLowerCase())); } private static Predicate<Item> addVersionStatusFilter(Predicate<Item> filter, Set<VersionStatus> versionStatuses) { - return filter.and(item -> versionStatuses == null - || item.getVersionStatusCounters().keySet().stream().anyMatch(versionStatuses::contains)); + return filter.and(item -> versionStatuses == null || item.getVersionStatusCounters().keySet().stream() + .anyMatch(versionStatuses::contains)); } private static Predicate<Item> addItemStatusFilter(Predicate<Item> filter, String itemStatusFilter) { @@ -224,7 +222,7 @@ public class WorkflowManagerImpl implements WorkflowManager { try { ItemStatus.valueOf(itemStatusFilter.toUpperCase()); } catch (IllegalArgumentException e) { - LOGGER.debug(String.format("Illegal Workflow status filter: %s. Ignoring filter", itemStatusFilter)); + LOGGER.debug("Illegal Workflow status filter: {}. Ignoring filter", itemStatusFilter, e); return filter; } return filter.and(item -> item.getStatus().equals(ItemStatus.valueOf(itemStatusFilter.toUpperCase()))); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java index 5eba8d4a..0078d226 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java @@ -215,10 +215,10 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { getVersion(workflowId, versionId); Optional<ArtifactEntity> artifactOptional = artifactRepository.get(workflowId, versionId); if (!artifactOptional.isPresent()) { - LOGGER.error(String.format("Workflow Version Artifact was not found for workflow id %s and version id %s", - workflowId, versionId)); + LOGGER.error("Workflow Version Artifact was not found for workflow id {} and version id {}", + workflowId, versionId); throw new EntityNotFoundException( - String.format("Artifact for workflow id %S version id %S was not found", workflowId, versionId)); + String.format("Artifact for workflow id %s version id %s was not found", workflowId, versionId)); } return artifactOptional.get(); } @@ -228,9 +228,8 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { validateWorkflowStatus(workflowId); WorkflowVersion retrievedVersion = get(workflowId, versionId); if (CERTIFIED.equals(retrievedVersion.getState())) { - LOGGER.error(String.format( - "Workflow Version is certified and can not be edited.Workflow id %s and version id %s", workflowId, - versionId)); + LOGGER.error("Workflow Version is certified and can not be edited.Workflow id {} and version id {}", + workflowId, versionId); throw new VersionModificationException(workflowId, versionId); } @@ -302,7 +301,7 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { return versions.stream().filter(version -> versionId.equals(version.getId())).findFirst(); } - protected void validateWorkflowStatus(String workflowId) { + void validateWorkflowStatus(String workflowId) { Item workflowItem = itemManager.get(workflowId); if (ItemStatus.ARCHIVED.equals(workflowItem.getStatus())) { throw new WorkflowModificationException(workflowId); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java index 1ca7c713..b7426670 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java @@ -27,7 +27,8 @@ import org.openecomp.sdc.versioning.types.Item; @Mapper(componentModel = "spring", imports = ItemType.class, uses = VersionStateMapper.class) public interface WorkflowMapper { - @Mapping(source = "versionStatusCounters", target = "versionStates") + @Mappings({@Mapping(source = "versionStatusCounters", target = "versionStates"), + @Mapping(source = "status", target = "archiving")}) Workflow itemToWorkflow(Item item); @InheritInverseConfiguration diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowStatus.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/ArchivingStatus.java index 6df7ff30..2e7eb22b 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowStatus.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/ArchivingStatus.java @@ -16,7 +16,7 @@ package org.onap.sdc.workflow.services.types; -public enum WorkflowStatus { +public enum ArchivingStatus { ARCHIVED, ACTIVE } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java index 0c0179e2..fcac779f 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java @@ -33,11 +33,13 @@ public class Workflow { private String id; @NotBlank(message = "Workflow name may not be blank.") - @Size(min = MIN_LENGTH, max = MAX_LENGTH, message = "Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH +" characters.") + @Size(min = MIN_LENGTH, max = MAX_LENGTH, + message = "Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH + + " characters.") @Pattern(regexp = "[A-Za-z0-9_. -]+", message = "Workflow name must contain only letters, digits and underscores.") private String name; private String description; private Set<WorkflowVersionState> versionStates; private Collection<WorkflowVersion> versions; - private WorkflowStatus status; + private ArchivingStatus archiving; } 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 |