diff options
author | ayalaben <ayala.benzvi@amdocs.com> | 2018-07-10 17:04:02 +0300 |
---|---|---|
committer | ayalaben <ayala.benzvi@amdocs.com> | 2018-07-10 17:04:02 +0300 |
commit | 9e47975d13f2c6f814f52d858b5c4733623576ba (patch) | |
tree | 141ba01495e5427fce89195fc50ed9e905afeff1 | |
parent | 8660fef75d965fa92f0a6d28187469009abcf3ad (diff) |
Version Status Mapper
Change-Id: I4fe428aad7bc06d72a6c8b0c60ea08cadc30cae8
Issue-ID: SDC-1462
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
10 files changed, 49 insertions, 20 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/VersionStatus.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/VersionStatus.java deleted file mode 100644 index a3e8a38a..00000000 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/VersionStatus.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.onap.sdc.workflow.persistence.types; - -public enum VersionStatus { - - Draft, - Certified; -} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java index 3c667bed..ce90e3fd 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java @@ -13,12 +13,12 @@ public class WorkflowVersion { private String baseId; private Date creationTime; private Date modificationTime; - private VersionStatus status; + private WorkflowVersionStatus status; public WorkflowVersion(String id) { this.id = id; - this.status = VersionStatus.Draft; + this.status = WorkflowVersionStatus.DRAFT; } public WorkflowVersion() { diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionStatus.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionStatus.java new file mode 100644 index 00000000..62f5847c --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionStatus.java @@ -0,0 +1,6 @@ +package org.onap.sdc.workflow.persistence.types; + +public enum WorkflowVersionStatus { + + DRAFT, CERTIFIED; +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java index fc60b27a..ec9db1f7 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java @@ -4,6 +4,7 @@ import java.util.Collection; import org.onap.sdc.workflow.api.types.VersionRequestDto; import org.onap.sdc.workflow.persistence.types.WorkflowVersion; import org.onap.sdc.workflow.persistence.types.ArtifactEntity; +import org.springframework.web.multipart.MultipartFile; public interface WorkflowVersionManager { diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionModificationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionModificationException.java index dc7d62fd..35680475 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionModificationException.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionModificationException.java @@ -4,6 +4,6 @@ public class VersionModificationException extends RuntimeException { public VersionModificationException(String workflowId, String version) { super(String.format("Error while trying to modify version for workflow id %s. " - + "Version %s is Certified and can not be edited", workflowId, version)); + + "Version %s is CERTIFIED and can not be edited", workflowId, version)); } } 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 99b64c7f..dfcc6c63 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 @@ -9,11 +9,10 @@ import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.onap.sdc.workflow.api.types.VersionRequestDto; import org.onap.sdc.workflow.persistence.ArtifactRepository; import org.onap.sdc.workflow.persistence.types.ArtifactEntity; -import org.onap.sdc.workflow.persistence.types.VersionStatus; +import org.onap.sdc.workflow.persistence.types.WorkflowVersionStatus; import org.onap.sdc.workflow.persistence.types.WorkflowVersion; import org.onap.sdc.workflow.services.WorkflowVersionManager; import org.onap.sdc.workflow.services.exceptions.CreateVersionException; @@ -112,7 +111,7 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { @Override public void uploadArtifact(String workflowId, WorkflowVersion version, MultipartFile artifact) { WorkflowVersion retrievedVersion = get(workflowId, version.getId()); - if (VersionStatus.Certified.equals(retrievedVersion.getStatus())) { + if (WorkflowVersionStatus.CERTIFIED.equals(retrievedVersion.getStatus())) { throw new VersionModificationException(workflowId, version.getId()); } @@ -142,7 +141,7 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { @Override public void deleteArtifact(String workflowId, WorkflowVersion version) { WorkflowVersion retrievedVersion = get(workflowId, version.getId()); - if (VersionStatus.Certified.equals(retrievedVersion.getStatus())) { + if (WorkflowVersionStatus.CERTIFIED.equals(retrievedVersion.getStatus())) { throw new VersionModificationException(workflowId, version.getId()); } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionMapper.java index 4f894f7f..e36193f9 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionMapper.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionMapper.java @@ -1,15 +1,24 @@ package org.onap.sdc.workflow.services.mappers; +import java.util.Collections; +import java.util.Map; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Named; +import org.onap.sdc.workflow.persistence.types.WorkflowProperty; import org.onap.sdc.workflow.persistence.types.WorkflowVersion; +import org.onap.sdc.workflow.persistence.types.WorkflowVersionStatus; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; -@Mapper(componentModel = "spring") +@Mapper(componentModel = "spring", uses = VersionStatusMapper.class) public interface VersionMapper { + WorkflowVersion versionToWorkflowVersion(Version version); @InheritInverseConfiguration Version workflowVersionToVersion(WorkflowVersion workflowVersion); + } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionStatusMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionStatusMapper.java new file mode 100644 index 00000000..e9fe0a2e --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionStatusMapper.java @@ -0,0 +1,22 @@ +package org.onap.sdc.workflow.services.mappers; + +import org.mapstruct.InheritInverseConfiguration; +import org.mapstruct.Mapper; +import org.mapstruct.ValueMapping; +import org.mapstruct.ValueMappings; +import org.onap.sdc.workflow.persistence.types.WorkflowVersionStatus; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; + +@Mapper(componentModel = "spring") +public interface VersionStatusMapper { + + @ValueMappings({@ValueMapping(source = "Certified", target = "CERTIFIED"), + @ValueMapping(source = "Draft", target = "DRAFT"), + @ValueMapping(source = "<ANY_REMAINING>", target = "DRAFT")}) + WorkflowVersionStatus versionStatusToWorkflowVersionStatus(VersionStatus status); + + @InheritInverseConfiguration + VersionStatus workflowVersionStatusToVersionStatus(WorkflowVersionStatus status); + + +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java index 5615b861..f89441a7 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java @@ -10,7 +10,6 @@ public interface WorkflowMapper { Workflow itemToWorkflow(Item item); - @InheritInverseConfiguration Item workflowToItem(Workflow workflow); diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerTest.java index 543ca82a..0d5b0ad5 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerTest.java @@ -7,7 +7,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.onap.sdc.workflow.persistence.types.VersionStatus.*; +import static org.onap.sdc.workflow.persistence.types.WorkflowVersionStatus.*; import java.io.IOException; import java.io.InputStream; @@ -16,7 +16,6 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Optional; -import java.util.Set; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,6 +27,7 @@ import org.onap.sdc.workflow.api.types.VersionRequestDto; import org.onap.sdc.workflow.persistence.ArtifactRepository; import org.onap.sdc.workflow.persistence.types.ArtifactEntity; import org.onap.sdc.workflow.persistence.types.WorkflowVersion; +import org.onap.sdc.workflow.persistence.types.WorkflowVersionStatus; import org.onap.sdc.workflow.services.exceptions.CreateVersionException; import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException; import org.onap.sdc.workflow.services.mappers.VersionMapper; @@ -136,7 +136,7 @@ public class WorkflowVersionManagerTest { MockMultipartFile mockFile = new MockMultipartFile("data", mockFileName, "text/plain", "some xml".getBytes()); WorkflowVersion version = new WorkflowVersion(VERSION1_ID); - version.setStatus(org.onap.sdc.workflow.persistence.types.VersionStatus.Draft); + version.setStatus(WorkflowVersionStatus.DRAFT); doReturn(version).when(workflowVersionManager).get(ITEM1_ID,VERSION1_ID); workflowVersionManager.uploadArtifact(ITEM1_ID,version,mockFile); @@ -146,7 +146,7 @@ public class WorkflowVersionManagerTest { @Test(expected = EntityNotFoundException.class) public void shouldThrowExceptionWhenArtifactNotFound(){ WorkflowVersion version = new WorkflowVersion(VERSION1_ID); - version.setStatus(Draft); + version.setStatus(DRAFT); doReturn(version).when(workflowVersionManager).get(ITEM1_ID,VERSION1_ID); doReturn(Optional.empty()).when(artifactRepositoryMock).get(ITEM1_ID,VERSION1_ID); workflowVersionManager.getArtifact(ITEM1_ID,version); |