diff options
Diffstat (limited to 'workflow-designer-be/src/test/java/org/onap')
2 files changed, 158 insertions, 0 deletions
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/VersionMapperTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/VersionMapperTest.java new file mode 100644 index 00000000..e7566f34 --- /dev/null +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/VersionMapperTest.java @@ -0,0 +1,82 @@ +package org.onap.sdc.workflow.api.mapping; + +import static org.junit.Assert.assertEquals; + +import java.util.Date; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.sdc.workflow.persistence.types.WorkflowVersion; +import org.onap.sdc.workflow.persistence.types.WorkflowVersionStatus; +import org.onap.sdc.workflow.services.mappers.VersionMapper; +import org.onap.sdc.workflow.services.mappers.VersionStatusMapper; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@ContextConfiguration(classes = VersionMapperTest.VersionMapperSpringTestConfig.class) +@RunWith(SpringJUnit4ClassRunner.class) +public class VersionMapperTest { + + @Configuration + @ComponentScan(basePackageClasses = {VersionMapper.class, VersionStatusMapper.class}) + public static class VersionMapperSpringTestConfig { } + + @Autowired + VersionMapper versionMapper; + + + @Test + public void shouldMapVersionToWorkflowVersion(){ + Version version = createVersion(); + WorkflowVersion mappedWorkflowVersion = versionMapper.versionToWorkflowVersion(version); + assertEquals(mappedWorkflowVersion.getId(),version.getId()); + assertEquals(mappedWorkflowVersion.getBaseId(),version.getBaseId()); + assertEquals(mappedWorkflowVersion.getDescription(),version.getDescription()); + assertEquals(mappedWorkflowVersion.getName(),version.getName()); + assertEquals(mappedWorkflowVersion.getCreationTime(),version.getCreationTime()); + assertEquals(mappedWorkflowVersion.getModificationTime(),version.getModificationTime()); + } + + @Test + public void shouldMapWorkflowVersionToVersion(){ + WorkflowVersion workflowVersion = createWorkflowVersion(); + Version mappedVersion = versionMapper.workflowVersionToVersion(workflowVersion); + assertEquals(mappedVersion.getId(),workflowVersion.getId()); + assertEquals(mappedVersion.getBaseId(),workflowVersion.getBaseId()); + assertEquals(mappedVersion.getDescription(),workflowVersion.getDescription()); + assertEquals(mappedVersion.getName(),workflowVersion.getName()); + assertEquals(mappedVersion.getCreationTime(),workflowVersion.getCreationTime()); + assertEquals(mappedVersion.getModificationTime(),workflowVersion.getModificationTime()); + + } + + private Version createVersion(){ + Version version = new Version("version_id"); + version.setBaseId("base_version_id"); + version.setName("1.0"); + version.setCreationTime(new Date()); + version.setModificationTime(new Date()); + version.setDescription("version_description"); + version.setStatus(VersionStatus.Draft); + + return version; + + } + + private WorkflowVersion createWorkflowVersion(){ + WorkflowVersion workflowVersion = new WorkflowVersion(); + workflowVersion.setId("wf_version_id"); + workflowVersion.setBaseId("wf_base_version_id"); + workflowVersion.setName("1.0"); + workflowVersion.setCreationTime(new Date()); + workflowVersion.setModificationTime(new Date()); + workflowVersion.setDescription("version_description"); + workflowVersion.setStatus(WorkflowVersionStatus.CERTIFIED); + + return workflowVersion; + } +} diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/VersionStatusMapperTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/VersionStatusMapperTest.java new file mode 100644 index 00000000..cb3444d4 --- /dev/null +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/VersionStatusMapperTest.java @@ -0,0 +1,76 @@ +package org.onap.sdc.workflow.api.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.sdc.workflow.persistence.types.WorkflowVersionStatus; +import org.onap.sdc.workflow.services.mappers.VersionStatusMapper; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@ContextConfiguration(classes = VersionStatusMapperTest.VersionStatusMapperSpringTestConfig.class) +@RunWith(SpringJUnit4ClassRunner.class) +public class VersionStatusMapperTest { + + @Configuration + @ComponentScan(basePackageClasses = {VersionStatusMapper.class}) + public static class VersionStatusMapperSpringTestConfig { } + + + @Autowired + VersionStatusMapper versionStatusMapper; + + @Test + public void shouldMapCertifiedVersionStatusToWorkflowVersionStatus() { + WorkflowVersionStatus mappedVersionStatus = + versionStatusMapper.versionStatusToWorkflowVersionStatus(VersionStatus.Certified); + assertEquals(WorkflowVersionStatus.CERTIFIED, mappedVersionStatus); + } + + @Test + public void shouldMapDraftVersionStatusToWorkflowVersionStatus() { + WorkflowVersionStatus mappedVersionStatus = + versionStatusMapper.versionStatusToWorkflowVersionStatus(VersionStatus.Draft); + assertEquals(WorkflowVersionStatus.DRAFT, mappedVersionStatus); + } + + @Test + public void shouldMapDeletedVersionStatusToWorkflowVersionStatus() { + WorkflowVersionStatus mappedVersionStatus = + versionStatusMapper.versionStatusToWorkflowVersionStatus(VersionStatus.Deleted); + assertEquals(WorkflowVersionStatus.DRAFT, mappedVersionStatus); + } + + @Test + public void shouldMapLockedVersionStatusToWorkflowVersionStatus() { + WorkflowVersionStatus mappedVersionStatus = + versionStatusMapper.versionStatusToWorkflowVersionStatus(VersionStatus.Locked); + assertEquals(WorkflowVersionStatus.DRAFT, mappedVersionStatus); + } + + @Test + public void shouldMapDeprecatedVersionStatusToWorkflowVersionStatus() { + WorkflowVersionStatus mappedVersionStatus = + versionStatusMapper.versionStatusToWorkflowVersionStatus(VersionStatus.Deprecated); + assertEquals(WorkflowVersionStatus.DRAFT, mappedVersionStatus); + } + + @Test + public void shouldMapCertifiedWorkflowVersionStatusToVersionStatus() { + VersionStatus mappedVersionStatus = + versionStatusMapper.workflowVersionStatusToVersionStatus(WorkflowVersionStatus.CERTIFIED); + assertEquals(VersionStatus.Certified, mappedVersionStatus); + } + + @Test + public void shouldMapDraftWorkflowVersionStatusToVersionStatus() { + VersionStatus mappedVersionStatus = + versionStatusMapper.workflowVersionStatusToVersionStatus(WorkflowVersionStatus.DRAFT); + assertEquals(VersionStatus.Draft, mappedVersionStatus); + } +} |