aboutsummaryrefslogtreecommitdiffstats
path: root/workflow-designer-be/src
diff options
context:
space:
mode:
authorpriyanshu <pagarwal@amdocs.com>2018-07-16 19:25:05 +0530
committerpriyanshu <pagarwal@amdocs.com>2018-07-16 19:25:07 +0530
commit7e78cd19bbb2b0730fafc0b328a71c69f5730e16 (patch)
tree24b4b72ef67f64304bfee867076517c37896db5b /workflow-designer-be/src
parent39c01dd3ccb69f53d2e9350994e25f6e64412aa4 (diff)
Workflow Docker containers
1. Implemented workflow init container. 2. Implemented workflow backend container. 3. Added a placeholder for frontend module container. 4. Modifiled directory structure and POM files. 5. Added a ReadMe with sample commands to detail how to run the containers. Change-Id: Ib110fcc104ce72ff28fce514a1475a032cc2d82b Issue-ID: SDC-1482 Signed-off-by: priyanshu <pagarwal@amdocs.com> Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com> Signed-off-by: priyanshu <pagarwal@amdocs.com>
Diffstat (limited to 'workflow-designer-be/src')
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/SpringBootWebApplication.java20
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java9
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java66
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java117
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/exceptionshandlers/CustomizedResponseEntityExceptionHandler.java48
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java18
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionRequestDto.java11
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java20
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java18
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/UniqueValueRepository.java10
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java104
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ArtifactEntity.java16
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/UniqueValueEntity.java23
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java12
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowProperty.java9
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java26
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionState.java20
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java24
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java32
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java64
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java107
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java15
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java30
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/EntityNotFoundException.java8
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/InvalidArtifactException.java8
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/UniqueValueViolationException.java11
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionCreationException.java15
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionModificationException.java10
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java12
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java22
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java79
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java186
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java19
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java22
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java19
-rw-r--r--workflow-designer-be/src/main/resources/application.properties7
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java24
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java38
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java121
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java118
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryTest.java29
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/UniqueValueServiceTest.java98
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java119
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java258
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapperTest.java80
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapperTest.java75
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java50
47 files changed, 0 insertions, 2247 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/SpringBootWebApplication.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/SpringBootWebApplication.java
deleted file mode 100644
index b7e3b345..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/SpringBootWebApplication.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.onap.sdc.workflow;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-
-@SpringBootApplication
-public class SpringBootWebApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(SpringBootWebApplication.class, args);
- }
-
- @Bean
- public ConfigurableServletWebServerFactory webServerFactory() {
- return new JettyServletWebServerFactory();
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java
deleted file mode 100644
index 8f02be0f..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.onap.sdc.workflow.api;
-
-public class RestConstants {
-
- private RestConstants() {
- }
-
- public static final String USER_ID_HEADER_PARAM = "USER_ID";
-}
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
deleted file mode 100644
index bb4320cc..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.onap.sdc.workflow.api;
-
-import static org.onap.sdc.workflow.api.RestConstants.USER_ID_HEADER_PARAM;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.onap.sdc.workflow.api.types.CollectionWrapper;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.services.WorkflowManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RequestMapping("/workflows")
-@Api("Workflows")
-@RestController("workflowController")
-public class WorkflowController {
-
- private final WorkflowManager workflowManager;
-
- @Autowired
- public WorkflowController(@Qualifier("workflowManager") WorkflowManager workflowManager) {
- this.workflowManager = workflowManager;
- }
-
- @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation("List workflows")
- public CollectionWrapper<Workflow> list(@RequestHeader(USER_ID_HEADER_PARAM) String user) {
- return new CollectionWrapper<>(workflowManager.list());
- }
-
- @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation("Create workflow")
- public ResponseEntity<Workflow> create(@RequestBody Workflow workflow,
- @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- return new ResponseEntity<>(workflowManager.create(workflow), HttpStatus.CREATED);
- }
-
- @GetMapping(path = "/{workflowId}")
- @ApiOperation("Get workflow")
- public Workflow get(@PathVariable("workflowId") String workflowId,
- @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- Workflow workflow = new Workflow();
- workflow.setId(workflowId);
- return workflowManager.get(workflow);
- }
-
- @PutMapping(path = "/{workflowId}", consumes = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation("Update workflow")
- public Workflow update(@RequestBody Workflow workflow, @PathVariable("workflowId") String workflowId,
- @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- workflow.setId(workflowId);
- workflowManager.update(workflow);
- return workflow;
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java
deleted file mode 100644
index 6214f1bb..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.onap.sdc.workflow.api;
-
-import static org.onap.sdc.workflow.api.RestConstants.USER_ID_HEADER_PARAM;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.onap.sdc.workflow.api.types.CollectionWrapper;
-import org.onap.sdc.workflow.api.types.VersionRequestDto;
-import org.onap.sdc.workflow.api.types.VersionStateDto;
-import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
-import org.onap.sdc.workflow.services.WorkflowVersionManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.core.io.InputStreamResource;
-import org.springframework.core.io.Resource;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-
-@RequestMapping("/workflows/{workflowId}/versions")
-@Api("Workflow versions")
-@RestController("workflowsVersionController")
-public class WorkflowVersionController {
-
- private final WorkflowVersionManager workflowVersionManager;
-
- @Autowired
- public WorkflowVersionController(
- @Qualifier("workflowVersionManager") WorkflowVersionManager workflowVersionManager) {
- this.workflowVersionManager = workflowVersionManager;
- }
-
- @GetMapping
- @ApiOperation("List workflow versions")
- public CollectionWrapper<WorkflowVersion> list(@PathVariable("workflowId") String workflowId,
- @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- return new CollectionWrapper<>(workflowVersionManager.list(workflowId));
- }
-
- @PostMapping
- @ApiOperation("Create workflow version")
- public ResponseEntity<WorkflowVersion> create(@RequestBody VersionRequestDto versionRequest,
- @PathVariable("workflowId") String workflowId, @RequestHeader(USER_ID_HEADER_PARAM) String user) {
-
- WorkflowVersion createdVersion = workflowVersionManager.create(workflowId, versionRequest);
- return new ResponseEntity<>(createdVersion, HttpStatus.CREATED);
- }
-
- @GetMapping("/{versionId}")
- @ApiOperation("Get workflow version")
- public WorkflowVersion get(@PathVariable("workflowId") String workflowId,
- @PathVariable("versionId") String versionId, @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- return workflowVersionManager.get(workflowId, versionId);
- }
-
- @PutMapping("/{versionId}")
- @ApiOperation("Update workflow version")
- public void update(@RequestBody WorkflowVersion version, @PathVariable("workflowId") String workflowId,
- @PathVariable("versionId") String versionId, @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- version.setId(versionId);
- workflowVersionManager.update(workflowId, version);
- }
-
- @GetMapping("/{versionId}/state")
- @ApiOperation("Get workflow version state")
- public VersionStateDto getState(@PathVariable("workflowId") String workflowId,
- @PathVariable("versionId") String versionId, @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- return new VersionStateDto(workflowVersionManager.getState(workflowId, versionId));
- }
-
- @PostMapping("/{versionId}/state")
- @ApiOperation("Update workflow version state")
- public VersionStateDto updateState(@RequestBody VersionStateDto state,
- @PathVariable("workflowId") String workflowId, @PathVariable("versionId") String versionId,
- @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- workflowVersionManager.updateState(workflowId, versionId, state.getName());
- return new VersionStateDto(state.getName());
- }
-
- @PutMapping("/{versionId}/artifact")
- @ApiOperation("Create/update artifact of a version")
- public void uploadArtifact(@RequestBody MultipartFile fileToUpload, @PathVariable("workflowId") String workflowId,
- @PathVariable("versionId") String versionId, @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- workflowVersionManager.uploadArtifact(workflowId, versionId, fileToUpload);
- }
-
- @GetMapping("/{versionId}/artifact")
- @ApiOperation("Download workflow version artifact")
- public ResponseEntity<Resource> getArtifact(@PathVariable("workflowId") String workflowId,
- @PathVariable("versionId") String versionId, @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- ArtifactEntity artifact = workflowVersionManager.getArtifact(workflowId, versionId);
-
- return ResponseEntity.ok()
- .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + artifact.getFileName())
- .contentType(MediaType.APPLICATION_OCTET_STREAM)
- .body(new InputStreamResource(artifact.getArtifactData()));
- }
-
- @DeleteMapping("/{versionId}/artifact")
- @ApiOperation("Delete workflow version artifact")
- public void deleteArtifact(@PathVariable("workflowId") String workflowId,
- @PathVariable("versionId") String versionId, @RequestHeader(USER_ID_HEADER_PARAM) String user) {
- workflowVersionManager.deleteArtifact(workflowId, versionId);
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/exceptionshandlers/CustomizedResponseEntityExceptionHandler.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/exceptionshandlers/CustomizedResponseEntityExceptionHandler.java
deleted file mode 100644
index 68fd41a5..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/exceptionshandlers/CustomizedResponseEntityExceptionHandler.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.onap.sdc.workflow.api.exceptionshandlers;
-
-import static org.springframework.http.HttpStatus.FORBIDDEN;
-import static org.springframework.http.HttpStatus.NOT_FOUND;
-import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
-
-import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
-import org.onap.sdc.workflow.services.exceptions.InvalidArtifactException;
-import org.onap.sdc.workflow.services.exceptions.UniqueValueViolationException;
-import org.onap.sdc.workflow.services.exceptions.VersionCreationException;
-import org.onap.sdc.workflow.services.exceptions.VersionModificationException;
-import org.onap.sdc.workflow.services.exceptions.VersionStateModificationException;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
-
-@ControllerAdvice
-@RestController
-public class CustomizedResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
-
- @ExceptionHandler(UniqueValueViolationException.class)
- public final ResponseEntity<String> handleUniqueValueViolationException(
- UniqueValueViolationException exception) {
- return new ResponseEntity<>(exception.getMessage(), UNPROCESSABLE_ENTITY);
- }
-
- @ExceptionHandler(EntityNotFoundException.class)
- public final ResponseEntity<String> handleWorkflowNotFoundException(
- Exception exception) {
- return new ResponseEntity<>(exception.getMessage(), NOT_FOUND);
- }
-
- @ExceptionHandler({InvalidArtifactException.class, VersionModificationException.class,
- VersionStateModificationException.class})
- public final ResponseEntity<String> handleInvalidArtifactException(
- Exception exception) {
- return new ResponseEntity<>(exception.getMessage(), UNPROCESSABLE_ENTITY);
- }
-
-
- @ExceptionHandler(VersionCreationException.class)
- public final ResponseEntity<String> handleVersioningErrorException(
- VersionCreationException exception) {
- return new ResponseEntity<>(exception.getMessage(), FORBIDDEN);
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java
deleted file mode 100644
index 653b0dcf..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.onap.sdc.workflow.api.types;
-
-import java.util.Collection;
-import lombok.Data;
-
-@Data
-public class CollectionWrapper<T> {
-
- private int total;
- private int limit;
- private int offset;
- private Collection<T> results;
-
- public CollectionWrapper(Collection<T> results) {
- this.results = results;
- this.total = results.size();
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionRequestDto.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionRequestDto.java
deleted file mode 100644
index 92ac3a73..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionRequestDto.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.onap.sdc.workflow.api.types;
-
-import lombok.Data;
-
-@Data
-public class VersionRequestDto {
-
- private String description;
- private String baseVersionId;
-
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java
deleted file mode 100644
index 5963a2bf..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.onap.sdc.workflow.api.types;
-
-import java.util.List;
-import lombok.Data;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
-
-@Data
-public class VersionStateDto {
-
- private WorkflowVersionState name;
- private List<WorkflowVersionState> nextStates;
-
- public VersionStateDto() {
- }
-
- public VersionStateDto(WorkflowVersionState state) {
- name = state;
- nextStates = state.getNextStates();
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
deleted file mode 100644
index a473f166..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.onap.sdc.workflow.persistence;
-
-
-import java.util.Optional;
-import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
-
-
-public interface ArtifactRepository {
-
- void update(String id, String versionId,ArtifactEntity artifactEntity);
-
- Optional<ArtifactEntity> get(String id, String versionId);
-
- void createStructure(String id, String versionId);
-
- void delete(String id, String versionId);
-
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/UniqueValueRepository.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/UniqueValueRepository.java
deleted file mode 100644
index d374a404..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/UniqueValueRepository.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.onap.sdc.workflow.persistence;
-
-import org.onap.sdc.workflow.persistence.types.UniqueValueEntity;
-import org.springframework.data.cassandra.repository.CassandraRepository;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface UniqueValueRepository extends CassandraRepository<UniqueValueEntity, UniqueValueEntity> {
-
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
deleted file mode 100644
index 9a449f0d..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.onap.sdc.workflow.persistence.impl;
-
-import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
-import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
-
-import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
-import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Action;
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Optional;
-import org.apache.commons.io.IOUtils;
-import org.onap.sdc.workflow.persistence.ArtifactRepository;
-import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
-import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
-import org.openecomp.sdc.datatypes.model.ElementType;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class ArtifactRepositoryImpl implements ArtifactRepository {
-
- private static final String FILE_NAME_PROPERTY = "fileName";
- private static final String EMPTY_DATA = "{}";
- private ZusammenAdaptor zusammenAdaptor = ZusammenAdaptorFactory.getInstance().createInterface();
-
-
- @Override
- public void update(String id, String versionId, ArtifactEntity artifactEntity) {
-
- ZusammenElement artifactElement = buildStructuralElement(ElementType.Artifact, Action.UPDATE);
- artifactElement.setData(artifactEntity.getArtifactData());
- artifactElement.getInfo().addProperty(FILE_NAME_PROPERTY, artifactEntity.getFileName());
-
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
-
- zusammenAdaptor
- .saveElement(context, elementContext, artifactElement, "Update WorkflowVersion Artifact Element");
- }
-
- @Override
- public Optional<ArtifactEntity> get(String id, String versionId) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
-
- Optional<Element> elementOptional =
- zusammenAdaptor.getElementByName(context, elementContext, null, ElementType.Artifact.name());
-
- if (!elementOptional.isPresent() || hasEmptyData(elementOptional.get().getData())) {
- return Optional.empty();
- }
-
- Element artifactElement = elementOptional.get();
-
- ArtifactEntity artifact = new ArtifactEntity(artifactElement.getInfo().getProperty(FILE_NAME_PROPERTY),
- artifactElement.getData());
-
- return Optional.of(artifact);
- }
-
- @Override
- public void createStructure(String id, String versionId) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
-
- ZusammenElement artifactElement = buildStructuralElement(ElementType.Artifact, Action.CREATE);
- artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
-
- zusammenAdaptor
- .saveElement(context, elementContext, artifactElement, "Create WorkflowVersion Artifact Element");
-
- }
-
- @Override
- public void delete(String id, String versionId) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
-
- ZusammenElement artifactElement = buildStructuralElement(ElementType.Artifact, Action.UPDATE);
- artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
- artifactElement.getInfo().getProperties().remove(FILE_NAME_PROPERTY);
-
- zusammenAdaptor
- .saveElement(context, elementContext, artifactElement, "Update WorkflowVersion Artifact Element");
-
- }
-
- private boolean hasEmptyData(InputStream elementData) {
-
- byte[] byteElementData;
- try {
- byteElementData = IOUtils.toByteArray(elementData);
- } catch (IOException ex) {
- return false;
- }
- return Arrays.equals(EMPTY_DATA.getBytes(), byteElementData);
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ArtifactEntity.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ArtifactEntity.java
deleted file mode 100644
index 8f24ecc9..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ArtifactEntity.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.onap.sdc.workflow.persistence.types;
-
-import java.io.InputStream;
-import lombok.Data;
-
-@Data
-public class ArtifactEntity {
-
- private String fileName;
- private InputStream artifactData;
-
- public ArtifactEntity(String fileName, InputStream artifactData) {
- this.fileName = fileName;
- this.artifactData = artifactData;
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/UniqueValueEntity.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/UniqueValueEntity.java
deleted file mode 100644
index 925ec5cb..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/UniqueValueEntity.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.onap.sdc.workflow.persistence.types;
-
-import static org.springframework.data.cassandra.core.cql.PrimaryKeyType.PARTITIONED;
-
-import lombok.Data;
-import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
-import org.springframework.data.cassandra.core.mapping.Table;
-
-@Table("unique_value")
-@Data
-public class UniqueValueEntity {
-
- @PrimaryKeyColumn(ordinal = 0, type = PARTITIONED)
- private String type;
-
- @PrimaryKeyColumn(ordinal = 1, type = PARTITIONED)
- private String value;
-
- public UniqueValueEntity(String type, String value) {
- this.type = type;
- this.value = value;
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java
deleted file mode 100644
index 8c66d820..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.onap.sdc.workflow.persistence.types;
-
-
-import lombok.Data;
-
-@Data
-public class Workflow {
-
- private String id;
- private String name;
- private String description;
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowProperty.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowProperty.java
deleted file mode 100644
index 6c2d804d..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowProperty.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.onap.sdc.workflow.persistence.types;
-
-public final class WorkflowProperty {
-
- private WorkflowProperty() {
- }
-
- public static final String CATEGORY = "category";
-}
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
deleted file mode 100644
index db0999b6..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.onap.sdc.workflow.persistence.types;
-
-import java.util.Date;
-import lombok.Data;
-
-
-@Data
-public class WorkflowVersion {
-
- private String id;
- private String name;
- private String description;
- private String baseId;
- private Date creationTime;
- private Date modificationTime;
- private WorkflowVersionState state;
-
-
- public WorkflowVersion(String id) {
- this.id = id;
- this.state = WorkflowVersionState.DRAFT;
- }
-
- public WorkflowVersion() {
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionState.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionState.java
deleted file mode 100644
index 9414fa17..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionState.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.onap.sdc.workflow.persistence.types;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public enum WorkflowVersionState {
-
- CERTIFIED, DRAFT(CERTIFIED);
-
- private final List<WorkflowVersionState> nextStates;
-
- WorkflowVersionState(WorkflowVersionState... nextStates) {
- this.nextStates = Collections.unmodifiableList(Arrays.asList(nextStates));
- }
-
- public List<WorkflowVersionState> getNextStates() {
- return nextStates;
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java
deleted file mode 100644
index 5105114f..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.onap.sdc.workflow.server.config;
-
-import static springfox.documentation.builders.PathSelectors.regex;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-@Configuration
-@EnableSwagger2
-public class SwaggerConfig {
-
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2)
- .select()
- .apis(RequestHandlerSelectors.basePackage("org.onap.sdc.workflow.api"))
- .paths(regex("/workflows.*"))
- .build();
- }
-} \ No newline at end of file
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java
deleted file mode 100644
index 092c3464..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.onap.sdc.workflow.server.config;
-
-import javax.annotation.PostConstruct;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class ZusammenConfig {
-
- @Value("${zusammen-tenant:workflow}")
- private String tenant;
- @Value("${spring.data.cassandra.contact-points:localhost}")
- private String cassandraAddress;
- @Value("${spring.data.cassandra.username:}")
- private String cassandraUser;
- @Value("${spring.data.cassandra.password:}")
- private String cassandraPassword;
- @Value("${zusammen.cassandra.isAuthenticate:false}")
- private String cassandraAuth;
-
- @PostConstruct
- public void init(){
- System.setProperty("cassandra.nodes", cassandraAddress);
- System.setProperty("cassandra.user", cassandraUser);
- System.setProperty("cassandra.password", cassandraPassword);
- System.setProperty("cassandra.authenticate", Boolean.toString(Boolean.valueOf(cassandraAuth)));
- }
-
- public String getTenant() {
- return tenant;
- }
-} \ No newline at end of file
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java
deleted file mode 100644
index 07d8eee7..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.onap.sdc.workflow.server.filters;
-
-import static org.onap.sdc.workflow.api.RestConstants.USER_ID_HEADER_PARAM;
-
-import java.io.IOException;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import org.onap.sdc.workflow.server.config.ZusammenConfig;
-import org.openecomp.sdc.common.session.SessionContextProvider;
-import org.openecomp.sdc.common.session.SessionContextProviderFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SessionContextFilter implements Filter {
-
- private ZusammenConfig zusammenConfig;
-
- @Autowired
- public SessionContextFilter(ZusammenConfig zusammenConfig) {
- this.zusammenConfig = zusammenConfig;
- }
-
- @Override
- public void init(FilterConfig filterConfig) {
- // not implemented
- }
-
- @Override
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
- throws IOException, ServletException {
- SessionContextProvider contextProvider = SessionContextProviderFactory.getInstance().createInterface();
-
- try {
- if (servletRequest instanceof HttpServletRequest) {
- contextProvider.create(getUser(servletRequest), getTenant());
- }
-
- filterChain.doFilter(servletRequest, servletResponse);
- } finally {
- contextProvider.close();
- }
- }
-
- @Override
- public void destroy() {
- // not implemented
- }
-
- private String getUser(ServletRequest servletRequest) {
- return "GLOBAL_USER";
- // TODO: 7/11/2018 get user from header when collaboration will be supported
- //((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM);
- }
-
- private String getTenant() {
- return zusammenConfig.getTenant();
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java
deleted file mode 100644
index a9acb816..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.onap.sdc.workflow.services;
-
-import java.util.Optional;
-import org.apache.commons.lang.ArrayUtils;
-import org.onap.sdc.workflow.persistence.UniqueValueRepository;
-import org.onap.sdc.workflow.persistence.types.UniqueValueEntity;
-import org.onap.sdc.workflow.services.exceptions.UniqueValueViolationException;
-import org.openecomp.core.utilities.CommonMethods; // todo get rid of
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-@Service("uniqueValueService")
-public class UniqueValueService {
-
- private static final char FORMATTED_UNIQUE_VALUE_SEPARATOR = '_';
-
- private final UniqueValueRepository uniqueValueRepository;
-
- @Autowired
- public UniqueValueService(UniqueValueRepository uniqueValueRepository) {
- this.uniqueValueRepository = uniqueValueRepository;
- }
-
- /**
- * Create unique value.
- *
- * @param type the type
- * @param uniqueCombination the unique combination
- */
- public void createUniqueValue(String type, String[] uniqueCombination) {
- formatValue(uniqueCombination).ifPresent(formattedValue -> {
- validateUniqueValue(type, formattedValue, uniqueCombination);
- uniqueValueRepository.insert(new UniqueValueEntity(type, formattedValue));
- });
- }
-
- /**
- * Delete unique value.
- *
- * @param type the type
- * @param uniqueCombination the unique combination
- */
- public void deleteUniqueValue(String type, String[] uniqueCombination) {
- formatValue(uniqueCombination)
- .ifPresent(formattedValue -> uniqueValueRepository.delete(new UniqueValueEntity(type, formattedValue)));
-
- }
-
- /**
- * Update unique value.
- *
- * @param type the type
- * @param oldValue the old value
- * @param newValue the new value
- * @param uniqueContext the unique context
- */
- public void updateUniqueValue(String type, String oldValue, String newValue, String ... uniqueContext) {
- if (newValue == null || !newValue.equalsIgnoreCase(oldValue)) {
- createUniqueValue(type, CommonMethods.concat(uniqueContext, new String[] {newValue}));
- deleteUniqueValue(type, CommonMethods.concat(uniqueContext, new String[] {oldValue}));
- }
- }
-
- /**
- * Validate unique value.
- *
- * @param type the type
- * @param uniqueCombination the unique combination
- */
- public void validateUniqueValue(String type, String[] uniqueCombination) {
- formatValue(uniqueCombination)
- .ifPresent(formattedValue -> validateUniqueValue(type, formattedValue, uniqueCombination));
- }
-
- /**
- * Checks if a unique value is taken.
- *
- * @return true if the unique value is occupied, false otherwise
- */
- public boolean isUniqueValueOccupied(String type, String[] uniqueCombination) {
- return formatValue(uniqueCombination).map(formattedValue -> isUniqueValueOccupied(type, formattedValue))
- .orElse(false);
- }
-
- private void validateUniqueValue(String type, String formattedValue, String[] uniqueCombination) {
- if (isUniqueValueOccupied(type, formattedValue)) {
- throw new UniqueValueViolationException(type, getValueWithoutContext(uniqueCombination));
- }
- }
-
- private boolean isUniqueValueOccupied(String type, String formattedValue) {
- return uniqueValueRepository.findById(new UniqueValueEntity(type, formattedValue)).isPresent();
- }
-
- private Optional<String> formatValue(String[] uniqueCombination) {
- if (ArrayUtils.isEmpty(uniqueCombination) || getValueWithoutContext(uniqueCombination) == null) {
- return Optional.empty();
- }
-
- uniqueCombination[uniqueCombination.length - 1] = getValueWithoutContext(uniqueCombination).toLowerCase();
- return Optional.of(CommonMethods.arrayToSeparatedString(uniqueCombination, FORMATTED_UNIQUE_VALUE_SEPARATOR));
- }
-
- private String getValueWithoutContext(String[] uniqueCombination) {
- return uniqueCombination[uniqueCombination.length - 1];
- }
-}
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
deleted file mode 100644
index 01c0b053..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.onap.sdc.workflow.services;
-
-import java.util.Collection;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-
-public interface WorkflowManager {
-
- Collection<Workflow> list();
-
- Workflow get(Workflow workflow);
-
- Workflow create(Workflow workflow);
-
- void update(Workflow workflow);
-}
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
deleted file mode 100644
index 30234526..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.onap.sdc.workflow.services;
-
-import java.util.Collection;
-import org.onap.sdc.workflow.api.types.VersionRequestDto;
-import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
-import org.springframework.web.multipart.MultipartFile;
-
-
-public interface WorkflowVersionManager {
-
- Collection<WorkflowVersion> list(String workflowId);
-
- WorkflowVersion create(String workflowId, VersionRequestDto versionRequest);
-
- void update(String id, WorkflowVersion version);
-
- WorkflowVersion get(String workflowId, String versionId);
-
- WorkflowVersionState getState(String workflowId, String versionId);
-
- void updateState(String workflowId, String versionId, WorkflowVersionState state);
-
- ArtifactEntity getArtifact(String workflowId, String versionId);
-
- void deleteArtifact(String workflowId, String versionId);
-
- void uploadArtifact(String workflowId, String versionId, MultipartFile artifact);
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/EntityNotFoundException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/EntityNotFoundException.java
deleted file mode 100644
index 1ed3df5a..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/EntityNotFoundException.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.onap.sdc.workflow.services.exceptions;
-
-public class EntityNotFoundException extends RuntimeException {
-
- public EntityNotFoundException(String message) {
- super(message);
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/InvalidArtifactException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/InvalidArtifactException.java
deleted file mode 100644
index 89c5fd5f..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/InvalidArtifactException.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.onap.sdc.workflow.services.exceptions;
-
-public class InvalidArtifactException extends RuntimeException {
-
- public InvalidArtifactException(String message) {
- super("Invalid artifact file can not be processed. Error: " + message);
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/UniqueValueViolationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/UniqueValueViolationException.java
deleted file mode 100644
index 82c97f94..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/UniqueValueViolationException.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.onap.sdc.workflow.services.exceptions;
-
-
-public class UniqueValueViolationException extends RuntimeException {
-
- private static final String UNIQUE_VALUE_VIOLATION_MSG = "%s with the value '%s' already exists.";
-
- public UniqueValueViolationException(String uniqueType, String value) {
- super(String.format(UNIQUE_VALUE_VIOLATION_MSG, uniqueType, value));
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionCreationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionCreationException.java
deleted file mode 100644
index af01c68f..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionCreationException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.onap.sdc.workflow.services.exceptions;
-
-public class VersionCreationException extends RuntimeException {
-
- private static final String MSG = "Error creating a new version for workflow with id %s";
- private static final String MSG_WITH_BASE_ID = MSG + " based on version %s";
-
- public VersionCreationException(String workflowId, String baseVersionId) {
- super(String.format(MSG_WITH_BASE_ID, workflowId, baseVersionId));
- }
-
- public VersionCreationException(String workflowId) {
- super(String.format(MSG, workflowId));
- }
-}
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
deleted file mode 100644
index 64ab6103..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionModificationException.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.onap.sdc.workflow.services.exceptions;
-
-public class VersionModificationException extends RuntimeException {
-
- public VersionModificationException(String workflowId, String versionId) {
- super(String.format(
- "Error while trying to modify version %s of workflow %s: Version is CERTIFIED and can not be edited",
- versionId, workflowId));
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java
deleted file mode 100644
index 6c4606db..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.onap.sdc.workflow.services.exceptions;
-
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
-
-public class VersionStateModificationException extends RuntimeException {
-
- public VersionStateModificationException(String workflowId, String versionId, WorkflowVersionState sourceState,
- WorkflowVersionState targetState) {
- super(String.format("Workflow %s, version %s: state can not be changed from %s to %s", workflowId, versionId,
- sourceState.name(), targetState.name()));
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java
deleted file mode 100644
index 2a4cd5aa..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.onap.sdc.workflow.services.impl;
-
-import org.openecomp.sdc.versioning.ItemManager;
-import org.openecomp.sdc.versioning.ItemManagerFactory;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class CollaborationConfiguration {
-
- @Bean
- public ItemManager itemManager() {
- return ItemManagerFactory.getInstance().createInterface();
- }
-
- @Bean
- public VersioningManager versioningManager() {
- return VersioningManagerFactory.getInstance().createInterface();
- }
-}
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
deleted file mode 100644
index 8ac5025a..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.onap.sdc.workflow.services.impl;
-
-import java.util.Collection;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.services.UniqueValueService;
-import org.onap.sdc.workflow.services.WorkflowManager;
-import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
-import org.onap.sdc.workflow.services.impl.mappers.WorkflowMapper;
-import org.openecomp.sdc.versioning.ItemManager;
-import org.openecomp.sdc.versioning.types.Item;
-import org.openecomp.sdc.versioning.types.ItemStatus;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Service;
-
-@Service("workflowManager")
-public class WorkflowManagerImpl implements WorkflowManager {
-
- public static final String WORKFLOW_TYPE = "WORKFLOW";
- private static final String WORKFLOW_NOT_FOUND_ERROR_MSG = "Workflow with id '%s' does not exist";
- private static final String WORKFLOW_NAME_UNIQUE_TYPE = "WORKFLOW_NAME";
- static final Predicate<Item> ITEM_PREDICATE = item -> WORKFLOW_TYPE.equals(item.getType());
-
- private final ItemManager itemManager;
- private final UniqueValueService uniqueValueService;
- private final WorkflowMapper workflowMapper;
-
- @Autowired
- public WorkflowManagerImpl(ItemManager itemManager,
- @Qualifier("uniqueValueService") UniqueValueService uniqueValueService, WorkflowMapper workflowMapper) {
- this.itemManager = itemManager;
- this.uniqueValueService = uniqueValueService;
- this.workflowMapper = workflowMapper;
- }
-
- @Override
- public Collection<Workflow> list() {
- return itemManager.list(ITEM_PREDICATE).stream().map(workflowMapper::itemToWorkflow)
- .collect(Collectors.toList());
- }
-
- @Override
- public Workflow get(Workflow workflow) {
- Item retrievedItem = itemManager.get(workflow.getId());
- if (retrievedItem == null) {
- throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflow.getId()));
- }
- return this.workflowMapper.itemToWorkflow(retrievedItem);
- }
-
- @Override
- public Workflow create(Workflow workflow) {
- Item item = workflowMapper.workflowToItem(workflow);
- item.setStatus(ItemStatus.ACTIVE);
-
- uniqueValueService.validateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflow.getName()});
- workflow.setId(itemManager.create(item).getId());
- uniqueValueService.createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflow.getName()});
- return workflow;
- }
-
- @Override
- public void update(Workflow workflow) {
- Item retrievedItem = itemManager.get(workflow.getId());
- if (retrievedItem == null) {
- throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflow.getId()));
- }
-
- uniqueValueService.updateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, retrievedItem.getName(), workflow.getName());
-
- Item item = workflowMapper.workflowToItem(workflow);
- item.setId(workflow.getId());
- item.setStatus(retrievedItem.getStatus());
- item.setVersionStatusCounters(retrievedItem.getVersionStatusCounters());
- itemManager.update(item);
- }
-}
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
deleted file mode 100644
index d559f025..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package org.onap.sdc.workflow.services.impl;
-
-import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Certified;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-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.WorkflowVersionState;
-import org.onap.sdc.workflow.services.WorkflowVersionManager;
-import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
-import org.onap.sdc.workflow.services.exceptions.InvalidArtifactException;
-import org.onap.sdc.workflow.services.exceptions.VersionCreationException;
-import org.onap.sdc.workflow.services.exceptions.VersionModificationException;
-import org.onap.sdc.workflow.services.exceptions.VersionStateModificationException;
-import org.onap.sdc.workflow.services.impl.mappers.VersionMapper;
-import org.onap.sdc.workflow.services.impl.mappers.VersionStateMapper;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionCreationMethod;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-import org.springframework.web.multipart.MultipartFile;
-
-@Service("workflowVersionManager")
-public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
-
- private static final String VERSION_NOT_EXIST_MSG = "version with id '%s' does not exist for workflow with id '%s'";
- private final VersioningManager versioningManager;
- private final ArtifactRepository artifactRepository;
- private final VersionMapper versionMapper;
- private final VersionStateMapper versionStateMapper;
-
-
- @Autowired
- public WorkflowVersionManagerImpl(VersioningManager versioningManager, ArtifactRepository artifactRepository,
- VersionMapper versionMapper, VersionStateMapper versionStateMapper) {
- this.versioningManager = versioningManager;
- this.artifactRepository = artifactRepository;
- this.versionMapper = versionMapper;
- this.versionStateMapper = versionStateMapper;
- }
-
- @Override
- public Collection<WorkflowVersion> list(String workflowId) {
- return versioningManager.list(workflowId).stream().map(versionMapper::versionToWorkflowVersion)
- .collect(Collectors.toList());
- }
-
- @Override
- public WorkflowVersion get(String workflowId, String versionId) {
- return versionMapper.versionToWorkflowVersion(getVersion(workflowId, versionId));
- }
-
- @Override
- public WorkflowVersion create(String workflowId, VersionRequestDto versionRequest) {
- List<Version> versions = versioningManager.list(workflowId);
-
- if (versionRequest.getBaseVersionId() != null) {
- validateVersionExistAndCertified(workflowId, versions, versionRequest.getBaseVersionId());
- } else if (!versions.isEmpty()) {
- throw new VersionCreationException(workflowId);
- }
-
- Version version = new Version();
- version.setDescription(versionRequest.getDescription());
- version.setBaseId(versionRequest.getBaseVersionId());
- Version createdVersion = versioningManager.create(workflowId, version, VersionCreationMethod.major);
-
- if (versions.isEmpty()) { // only for first version
- artifactRepository.createStructure(workflowId, createdVersion.getId());
- versioningManager.publish(workflowId, createdVersion, "Add workflow structure");
- }
-
- return versionMapper.versionToWorkflowVersion(createdVersion);
- }
-
- @Override
- public void update(String workflowId, WorkflowVersion workflowVersion) {
- Version retrievedVersion = getVersion(workflowId, workflowVersion.getId());
- if (WorkflowVersionState.CERTIFIED
- .equals(versionStateMapper.versionStatusToWorkflowVersionState(retrievedVersion.getStatus()))) {
- throw new VersionModificationException(workflowId, workflowVersion.getId());
- }
-
- Version version = versionMapper.workflowVersionToVersion(workflowVersion);
- version.setName(retrievedVersion.getName());
- version.setStatus(retrievedVersion.getStatus());
-
- versioningManager.updateVersion(workflowId, version);
- versioningManager.publish(workflowId, version, "Update version");
- }
-
- @Override
- public WorkflowVersionState getState(String workflowId, String versionId) {
- return versionStateMapper.versionStatusToWorkflowVersionState(getVersion(workflowId, versionId).getStatus());
- }
-
- @Override
- public void updateState(String workflowId, String versionId, WorkflowVersionState state) {
- Version retrievedVersion = getVersion(workflowId, versionId);
- WorkflowVersionState retrievedState =
- versionStateMapper.versionStatusToWorkflowVersionState(retrievedVersion.getStatus());
- if (WorkflowVersionState.CERTIFIED.equals(retrievedState) || retrievedState.equals(state)) {
- throw new VersionStateModificationException(workflowId, versionId, retrievedState, state);
- }
-
- retrievedVersion.setStatus(versionStateMapper.workflowVersionStateToVersionStatus(state));
- versioningManager.updateVersion(workflowId, retrievedVersion);
- versioningManager.publish(workflowId, retrievedVersion,
- String.format("Update version state from %s to %s", retrievedState.name(), state.name()));
- }
-
- @Override
- public void uploadArtifact(String workflowId, String versionId, MultipartFile artifact) {
- Version retrievedVersion = getVersion(workflowId, versionId);
- if (WorkflowVersionState.CERTIFIED
- .equals(versionStateMapper.versionStatusToWorkflowVersionState(retrievedVersion.getStatus()))) {
- throw new VersionModificationException(workflowId, versionId);
- }
-
- try (InputStream artifactData = artifact.getInputStream()) {
- ArtifactEntity artifactEntity =
- new ArtifactEntity(StringUtils.cleanPath(artifact.getOriginalFilename()), artifactData);
- artifactRepository.update(workflowId, versionId, artifactEntity);
- versioningManager.publish(workflowId, new Version(versionId), "Update Artifact");
-
- } catch (IOException e) {
- throw new InvalidArtifactException(e.getMessage());
- }
- }
-
- @Override
- public ArtifactEntity getArtifact(String workflowId, String versionId) {
- getVersion(workflowId, versionId);
- Optional<ArtifactEntity> artifactOptional = artifactRepository.get(workflowId, versionId);
- if (!artifactOptional.isPresent()) {
- throw new EntityNotFoundException(
- String.format("Artifact for workflow id %S version id %S was not found", workflowId, versionId));
- }
- return artifactOptional.get();
- }
-
- @Override
- public void deleteArtifact(String workflowId, String versionId) {
- WorkflowVersion retrievedVersion = get(workflowId, versionId);
- if (WorkflowVersionState.CERTIFIED.equals(retrievedVersion.getState())) {
- throw new VersionModificationException(workflowId, versionId);
- }
-
- artifactRepository.delete(workflowId, versionId);
- versioningManager.publish(workflowId, new Version(versionId), "Delete Artifact");
- }
-
- private void validateVersionExistAndCertified(String workflowId, List<Version> versions, String versionId) {
- Version baseVersion = findVersion(versions, versionId).orElseThrow(
- () -> new EntityNotFoundException(String.format(VERSION_NOT_EXIST_MSG, versionId, workflowId)));
-
- if (!Certified.equals(baseVersion.getStatus())) {
- throw new VersionCreationException(workflowId, versionId);
- }
- }
-
- private Version getVersion(String workflowId, String versionId) {
- try {
- Version version = versioningManager.get(workflowId, new Version(versionId));
- if (version == null) {
- throw new EntityNotFoundException(String.format(VERSION_NOT_EXIST_MSG, versionId, workflowId));
- }
- return version;
- } catch (Exception e) {
- throw new EntityNotFoundException(String.format(VERSION_NOT_EXIST_MSG, versionId, workflowId));
- }
- }
-
- private static Optional<Version> findVersion(List<Version> versions, String versionId) {
- return versions.stream().filter(version -> versionId.equals(version.getId())).findFirst();
- }
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java
deleted file mode 100644
index bcf89661..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.onap.sdc.workflow.services.impl.mappers;
-
-import org.mapstruct.InheritInverseConfiguration;
-import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-@Mapper(componentModel = "spring", uses = VersionStateMapper.class)
-public interface VersionMapper {
-
-
- @Mapping(source = "status", target = "state")
- WorkflowVersion versionToWorkflowVersion(Version version);
-
- @InheritInverseConfiguration
- Version workflowVersionToVersion(WorkflowVersion workflowVersion);
-
-}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java
deleted file mode 100644
index 0c2f5391..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.onap.sdc.workflow.services.impl.mappers;
-
-import org.mapstruct.InheritInverseConfiguration;
-import org.mapstruct.Mapper;
-import org.mapstruct.ValueMapping;
-import org.mapstruct.ValueMappings;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-
-@Mapper(componentModel = "spring")
-public interface VersionStateMapper {
-
- @ValueMappings({@ValueMapping(source = "Certified", target = "CERTIFIED"),
- @ValueMapping(source = "Draft", target = "DRAFT"),
- @ValueMapping(source = "<ANY_REMAINING>", target = "DRAFT")})
- WorkflowVersionState versionStatusToWorkflowVersionState(VersionStatus status);
-
- @InheritInverseConfiguration
- VersionStatus workflowVersionStateToVersionStatus(WorkflowVersionState status);
-
-
-}
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
deleted file mode 100644
index 34327ce7..00000000
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.onap.sdc.workflow.services.impl.mappers;
-
-import org.mapstruct.InheritInverseConfiguration;
-import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.services.impl.WorkflowManagerImpl;
-import org.openecomp.sdc.versioning.types.Item;
-
-@Mapper(componentModel = "spring", imports = WorkflowManagerImpl.class)
-public interface WorkflowMapper {
-
- Workflow itemToWorkflow(Item item);
-
- @InheritInverseConfiguration
- @Mapping(expression = "java(WorkflowManagerImpl.WORKFLOW_TYPE)", target = "type")
- Item workflowToItem(Workflow workflow);
-
-}
diff --git a/workflow-designer-be/src/main/resources/application.properties b/workflow-designer-be/src/main/resources/application.properties
deleted file mode 100644
index b7cfc5aa..00000000
--- a/workflow-designer-be/src/main/resources/application.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-server.servlet.context-path=/wf
-server.port=8080
-
-#CASSANDRA
-spring.data.cassandra.contact-points=localhost
-spring.data.cassandra.keyspace-name=workflow
-spring.data.cassandra.port=9042 \ No newline at end of file
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java
deleted file mode 100644
index 266ca91b..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.onap.sdc.workflow;
-
-public class RestPath {
- private static final String WORKFLOWS_URL = "/workflows";
- private static final String WORKFLOW_URL_FORMATTER = WORKFLOWS_URL + "/%s";
- private static final String VERSIONS_URL_FORMATTER = WORKFLOWS_URL + "/%s/versions";
- private static final String VERSION_URL_FORMATTER = WORKFLOWS_URL + "/%s/versions/%s";
-
- public static String getWorkflowsPath(){
- return WORKFLOWS_URL;
- }
-
- public static String getWorkflowPath(String workflowId){
- return String.format(WORKFLOW_URL_FORMATTER, workflowId);
- }
-
- public static String getWorkflowVersions(String workflowId){
- return String.format(VERSIONS_URL_FORMATTER, workflowId);
- }
-
- public static String getWorkflowVersion(String workflowId, String versionId){
- return String.format(VERSION_URL_FORMATTER, workflowId, versionId);
- }
-}
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
deleted file mode 100644
index 47ce060b..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.onap.sdc.workflow;
-
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.openecomp.sdc.versioning.types.Item;
-
-public class TestUtil {
-
- private static final String WORKFLOW_TYPE = "WORKFLOW";
-
- public static Workflow createWorkflow(int workflowPropertySuffix, boolean createId) {
- Workflow workflow = new Workflow();
- if (createId) {
- workflow.setId("workflowId" + workflowPropertySuffix);
- }
- workflow.setName("workflowName" + workflowPropertySuffix);
- workflow.setDescription("workflowDesc" + workflowPropertySuffix);
-
- return workflow;
- }
-
- public static Item createItem(int itemNum,boolean setType, boolean setId){
- Item item = new Item();
- if(setId) {
- item.setId("workflowId" + itemNum);
- }
- item.addProperty("category","category_" + itemNum);
- item.setName("Workflow_" + itemNum);
- item.setDescription("Description_" + itemNum);
- if(setType) {
- item.setType(WORKFLOW_TYPE);
- }
-
- 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
deleted file mode 100644
index 69b25b01..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.onap.sdc.workflow.api;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.onap.sdc.workflow.TestUtil.createWorkflow;
-import static org.onap.sdc.workflow.api.RestConstants.USER_ID_HEADER_PARAM;
-import static org.springframework.http.MediaType.APPLICATION_JSON;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-import com.google.gson.Gson;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.sdc.workflow.RestPath;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.services.WorkflowManager;
-import org.openecomp.sdc.versioning.types.Item;
-import org.springframework.http.MediaType;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-
-@RunWith(MockitoJUnitRunner.class)
-public class WorkflowControllerTest {
-
- private static final String MISSING_REQUEST_HEADER_ERRROR_FORMAT =
- "Missing request header '%s' for method parameter of type String";
- private static final String USER_ID = "userId";
- private static final Gson GSON = new Gson();
-
- private MockMvc mockMvc;
-
-
- @InjectMocks
- private WorkflowController workflowController;
-
- @Mock
- private WorkflowManager workflowManagerMock;
-
- @Before
- public void setUp() {
- mockMvc = MockMvcBuilders.standaloneSetup(workflowController).build();
- }
-
- @Test
- public void shouldReturnErrorWhenMissingUserIdInGetReqHeader() throws Exception {
- Workflow workflowMock = createWorkflow(1, true);
- MockHttpServletResponse response =
- mockMvc.perform(get(RestPath.getWorkflowPath(workflowMock.getId())).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isBadRequest()).andExpect(status().is(400)).andReturn()
- .getResponse();
- assertEquals(String.format(MISSING_REQUEST_HEADER_ERRROR_FORMAT, "USER_ID"), response.getErrorMessage());
- }
-
- @Test
- public void shouldReturnWorkflowDataWhenRequestPathIsOk() throws Exception {
- Workflow workflowMock = createWorkflow(1, true);
- doReturn(workflowMock).when(workflowManagerMock).get(any(Workflow.class));
- mockMvc.perform(
- get(RestPath.getWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER_PARAM, USER_ID)
- .contentType(APPLICATION_JSON)).andDo(print())
- .andExpect(status().isOk()).andExpect(jsonPath("$.id", is(workflowMock.getId())))
- .andExpect(jsonPath("$.name", is(workflowMock.getName())));
- }
-
- @Test
- public void shouldReturnErrorWhenMissingUserIdInListReqHeader() throws Exception {
- MockHttpServletResponse response =
- mockMvc.perform(get(RestPath.getWorkflowsPath()).contentType(APPLICATION_JSON)).andDo(print())
- .andExpect(status().isBadRequest()).andExpect(status().is(400)).andReturn().getResponse();
- assertEquals(String.format(MISSING_REQUEST_HEADER_ERRROR_FORMAT, USER_ID_HEADER_PARAM), response.getErrorMessage());
- }
-
- @Test
- public void shouldReturn5WorkflowWhen5WorkflowsExists() throws Exception {
- int numOfWorkflows = 5;
- List<Workflow> workflowMocks = createWorkflows(numOfWorkflows);
- doReturn(workflowMocks).when(workflowManagerMock).list();
- mockMvc.perform(
- get(RestPath.getWorkflowsPath()).header(USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(numOfWorkflows)));
- }
-
- @Test
- public void shouldCreateWorkflowWhenCallingPostRESTRequest() throws Exception {
- Item item = new Item();
- item.setId("abc");
- Workflow reqWorkflow = createWorkflow(1, false);
- mockMvc.perform(
- post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON)
- .content(GSON.toJson(reqWorkflow))).andDo(print()).andExpect(status().isCreated())
- .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
- verify(workflowManagerMock, times(1)).create(reqWorkflow);
- }
-
- private List<Workflow> createWorkflows(int numOfWorkflows) {
- List<Workflow> workflowList = new ArrayList<>(numOfWorkflows);
- for (int i = 0; i < numOfWorkflows; i++) {
- workflowList.add(createWorkflow(i, true));
- }
-
- return workflowList;
- }
-
-
-} \ No newline at end of file
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java
deleted file mode 100644
index 75b132ad..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.onap.sdc.workflow.api;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.springframework.http.MediaType.APPLICATION_JSON;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-import com.google.gson.Gson;
-import java.util.Arrays;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.sdc.workflow.RestPath;
-import org.onap.sdc.workflow.api.types.VersionRequestDto;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
-import org.onap.sdc.workflow.services.WorkflowVersionManager;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.springframework.http.HttpStatus;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-
-@RunWith(MockitoJUnitRunner.class)
-public class WorkflowVersionControllerTest {
-
- private static final String USER_ID = "cs0008";
- private static final String ITEM1_ID = "item_id_1";
- private static final String VERSION1_ID = "version_id_1";
- private static final String VERSION2_ID = "version_id_2";
- private List<Version> versionList;
-
- private static final Gson GSON = new Gson();
-
- private MockMvc mockMvc;
-
- @Mock
- private WorkflowVersionManager workflowVersionManagerMock;
-
- @InjectMocks
- private WorkflowVersionController workflowVersionController;
-
- @Before
- public void setUp() {
- versionList = Arrays.asList( new Version(VERSION1_ID),new Version(VERSION2_ID));
- mockMvc = MockMvcBuilders.standaloneSetup(workflowVersionController).build();
- }
-
- @Test
- public void shouldReturnWorkflowVersionListWhenCallingVersionGetREST() throws Exception {
-
- doReturn(versionList).when(workflowVersionManagerMock).list(ITEM1_ID);
- mockMvc.perform(get(RestPath.getWorkflowVersions(ITEM1_ID)).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID)
- .contentType(APPLICATION_JSON)).andExpect(status().isOk())
- .andExpect(jsonPath("$.results", hasSize(2)))
- .andExpect(jsonPath("$.results[0].id", equalTo(VERSION1_ID)))
- .andExpect(jsonPath("$.results[1].id", equalTo(VERSION2_ID)));
-
- verify(workflowVersionManagerMock, times(1)).list(ITEM1_ID);
- }
-
-
- @Test
- public void shouldCreateWorkflowVersionWhenCallingVersionsPostREST() throws Exception {
-
- VersionRequestDto version = new VersionRequestDto();
- version.setDescription("VersionDescription");
- mockMvc.perform(post(RestPath.getWorkflowVersions(ITEM1_ID)).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID)
- .contentType(APPLICATION_JSON)
- .content(GSON.toJson(version)))
- .andExpect(status().isCreated());
-
- verify(workflowVersionManagerMock, times(1)).create(ITEM1_ID, version);
- }
-
-
- @Test
- public void shouldReturnWorkflowVersionWhenExists() throws Exception {
- WorkflowVersion version = new WorkflowVersion(VERSION1_ID);
- doReturn(version).when(workflowVersionManagerMock).get(ITEM1_ID, VERSION1_ID);
- mockMvc.perform(
- get(RestPath.getWorkflowVersion(ITEM1_ID, VERSION1_ID)).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID)
- .contentType(APPLICATION_JSON)).andDo(print())
- .andExpect(status().isOk()).andExpect(jsonPath("$.id", is(version.getId())));
- verify(workflowVersionManagerMock, times(1)).get(ITEM1_ID, VERSION1_ID);
- }
-
- @Test
- public void shouldUpdateWorkflowVersionWhenCallingPutREST() throws Exception {
- WorkflowVersion version = new WorkflowVersion();
- version.setDescription("Updated");
-
- MockHttpServletResponse result = mockMvc.perform(
- put(RestPath.getWorkflowVersion(ITEM1_ID, VERSION1_ID)).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID)
- .contentType(APPLICATION_JSON)
- .content(GSON.toJson(version))).andReturn()
- .getResponse();
-
- assertEquals(HttpStatus.OK.value(), result.getStatus());
- version.setId(VERSION1_ID);
- verify(workflowVersionManagerMock, times(1)).update(ITEM1_ID, version);
-
- }
-
-}
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryTest.java
deleted file mode 100644
index 4bec8b97..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.onap.sdc.workflow.persistence.impl;
-
-import java.io.IOException;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-
-public class ArtifactRepositoryTest {
-
- private static final String FILE_NAME_PROPERTY = "fileName";
- private static final String EMPTY_DATA = "{}";
- private static final String ITEM1_ID = "item_id_1";
- private static final String VERSION1_ID = "version_id_1";
-
-
- @Mock
- private ZusammenAdaptor zusammenAdaptorMock;
-
- @InjectMocks
- private ArtifactRepositoryImpl artifactRepository;
-
- @Test
- public void shouldUpdateArtifact() throws IOException {
-
- }
-
-
-}
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/UniqueValueServiceTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/UniqueValueServiceTest.java
deleted file mode 100644
index 4911060a..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/UniqueValueServiceTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.onap.sdc.workflow.services;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.onap.sdc.workflow.persistence.UniqueValueRepository;
-import org.onap.sdc.workflow.persistence.types.UniqueValueEntity;
-import org.onap.sdc.workflow.services.exceptions.UniqueValueViolationException;
-
-public class UniqueValueServiceTest {
-
- private static final String TYPE = "ss";
- private static final String DUMMY_COMBINATION = "dummy";
-
- @Mock
- private UniqueValueRepository uniqueValueRepositoryMock;
-
- @Spy
- @InjectMocks
- private UniqueValueService uniqueValueService;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void shouldCallRepositoryInsertIfValueUnique(){
- doReturn(Optional.empty()).when(uniqueValueRepositoryMock).findById(any());
- uniqueValueService.createUniqueValue(TYPE, new String[]{DUMMY_COMBINATION});
- verify(uniqueValueRepositoryMock, times(1)).insert(any(UniqueValueEntity.class));
- }
-
- @Test
- public void shouldNotCheckValueIfNoUniqueCombination(){
- uniqueValueService.createUniqueValue(TYPE, null);
- verify(uniqueValueRepositoryMock, never()).findById(any(UniqueValueEntity.class));
- }
-
- @Test(expected = UniqueValueViolationException.class)
- public void shouldThrowExceptionIfValueIsNotUnique(){
- doReturn(Optional.of("xxx")).when(uniqueValueRepositoryMock).findById(any());
- uniqueValueService.createUniqueValue(TYPE, new String[]{DUMMY_COMBINATION});
- }
-
- @Test
- public void shouldCallRepositoryDeleteIfValueValid(){
- uniqueValueService.deleteUniqueValue(TYPE, new String[]{DUMMY_COMBINATION});
- verify(uniqueValueRepositoryMock, times(1)).delete(any(UniqueValueEntity.class));
- }
-
- @Test
- public void shouldNotCallRepositoryDeleteIfValueNouniqueCombination(){
- uniqueValueService.deleteUniqueValue(TYPE, new String[]{});
- verify(uniqueValueRepositoryMock, never()).delete(any(UniqueValueEntity.class));
- }
-
- @Test
- public void shouldNotUpdateIfNewAndOldValueAreEqualsCaseIgnore(){
- String value = "value";
- uniqueValueService.updateUniqueValue(TYPE, value, value.toUpperCase());
- verify(uniqueValueService, never()).createUniqueValue(anyString(), any());
- }
-
- @Test
- public void shouldUpdateIfNewAndOldValueAreNotEqualsCaseIgnore(){
- String oldValue = "oldValue";
- String newValue = "newValue";
- uniqueValueService.updateUniqueValue(TYPE, oldValue, newValue);
- verify(uniqueValueService, times(1)).createUniqueValue(anyString(), any());
- verify(uniqueValueService, times(1)).deleteUniqueValue(anyString(), any());
- }
-
- @Test
- public void shouldReturnTrueIfValueExist() {
- doReturn(Optional.of("xxx")).when(uniqueValueRepositoryMock).findById(any());
- assertTrue(uniqueValueService.isUniqueValueOccupied(TYPE, new String[]{DUMMY_COMBINATION}));
- }
-
- @Test
- public void shouldReturnFalseIfValueNotExist() {
- doReturn(Optional.empty()).when(uniqueValueRepositoryMock).findById(any());
- assertFalse(uniqueValueService.isUniqueValueOccupied(TYPE, new String[]{DUMMY_COMBINATION}));
- }
-}
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
deleted file mode 100644
index 3e228759..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.onap.sdc.workflow.services.impl;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.onap.sdc.workflow.TestUtil.createItem;
-import static org.onap.sdc.workflow.TestUtil.createWorkflow;
-
-import java.util.Arrays;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.services.UniqueValueService;
-import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
-import org.onap.sdc.workflow.services.impl.mappers.WorkflowMapper;
-import org.openecomp.sdc.versioning.ItemManager;
-import org.openecomp.sdc.versioning.types.Item;
-import org.openecomp.sdc.versioning.types.ItemStatus;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-public class WorkflowManagerImplTest {
-
- private static final String ITEM1_ID = "workflowId1";
- private static final String WORKFLOW_TYPE = "WORKFLOW";
- private static final String WORKFLOW_NAME_UNIQUE_TYPE = "WORKFLOW_NAME";
- private List<Item> itemList;
-
- @Mock
- private WorkflowMapper workflowMapperMock;
-
- @Mock
- private ItemManager itemManagerMock;
-
- @Mock
- private UniqueValueService uniqueValueServiceMock;
-
- @InjectMocks
- private WorkflowManagerImpl workflowManager;
-
-
- @Before
- public void setUp() {
- itemList = Arrays.asList(createItem(1, true, true), createItem(2, true, true), createItem(3, true, true));
-
- }
-
-
- @Test
- public void shouldReturnWorkflowVersionList() {
-
- doReturn(itemList).when(itemManagerMock).list(WorkflowManagerImpl.ITEM_PREDICATE);
- workflowManager.list();
- verify(itemManagerMock).list(WorkflowManagerImpl.ITEM_PREDICATE);
- }
-
- @Test(expected = EntityNotFoundException.class)
- public void shouldThrowExceptionWhenWorkflowDontExist() {
- Workflow nonExistingWorkflow = new Workflow();
- nonExistingWorkflow.setId(ITEM1_ID);
- doReturn(null).when(itemManagerMock).get(ITEM1_ID);
- workflowManager.get(nonExistingWorkflow);
- verify(workflowMapperMock, times(3)).itemToWorkflow(any(Item.class));
- }
-
- @Test
- public void shouldReturnWorkflow() {
- Item retrievedItem = createItem(1, true, true);
- doReturn(retrievedItem).when(itemManagerMock).get(ITEM1_ID);
- Workflow workflow = createWorkflow(1, true);
- workflowManager.get(workflow);
- verify(itemManagerMock).get(ITEM1_ID);
- verify(workflowMapperMock).itemToWorkflow(retrievedItem);
-
-
- }
-
- @Test
- public void shouldCreateWorkflowItemFromWorkflow() {
- Workflow workflowToBeCreated = createWorkflow(1, false);
- Item createdWorkflowItem = createItem(1, false, true);
- 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()});
-
- createdWorkflowItem.setStatus(ItemStatus.ACTIVE);
- createdWorkflowItem.setType(WORKFLOW_TYPE);
- verify(itemManagerMock).create(createdWorkflowItem);
- verify(uniqueValueServiceMock)
- .createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflowToBeCreated.getName()});
- }
-
- @Test
- public void shouldUpdateWorkflow() {
- Item workflowItem = createItem(1, true, true);
- doReturn(workflowItem).when(itemManagerMock).get(ITEM1_ID);
- Workflow workflowToBeUpdated = createWorkflow(1, true);
- doReturn(workflowItem).when(workflowMapperMock).workflowToItem(workflowToBeUpdated);
- workflowManager.update(workflowToBeUpdated);
- verify(itemManagerMock).update(workflowItem);
- verify(uniqueValueServiceMock)
- .updateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, workflowItem.getName(), workflowToBeUpdated.getName());
-
- }
-
- @Test(expected = EntityNotFoundException.class)
- public void shouldThrowExceptionWhenWorkflowToUpdateNotFound() {
- doReturn(null).when(itemManagerMock).get(ITEM1_ID);
- workflowManager.update(createWorkflow(1, true));
- }
-
-}
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java
deleted file mode 100644
index ae69b280..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-package org.onap.sdc.workflow.services.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.any;
-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.WorkflowVersionState.CERTIFIED;
-import static org.onap.sdc.workflow.persistence.types.WorkflowVersionState.DRAFT;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.ArgumentMatcher;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-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.WorkflowVersionState;
-import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
-import org.onap.sdc.workflow.services.exceptions.VersionCreationException;
-import org.onap.sdc.workflow.services.exceptions.VersionStateModificationException;
-import org.onap.sdc.workflow.services.impl.mappers.VersionMapper;
-import org.onap.sdc.workflow.services.impl.mappers.VersionStateMapper;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.types.VersionCreationMethod;
-import org.springframework.mock.web.MockMultipartFile;
-
-@RunWith(MockitoJUnitRunner.class)
-public class WorkflowVersionManagerImplTest {
-
- private static final String ITEM1_ID = "item_id_1";
- private static final String VERSION1_ID = "version_id_1";
- private static final String VERSION2_ID = "version_id_2";
-
- @Mock
- private VersioningManager versioningManagerMock;
- @Mock
- private ArtifactRepository artifactRepositoryMock;
- @Mock
- private VersionMapper versionMapperMock;
- @Mock
- private VersionStateMapper versionStateMapperMock;
- @InjectMocks
- private WorkflowVersionManagerImpl workflowVersionManager;
-
- @Test(expected = EntityNotFoundException.class)
- public void shouldThrowExceptionWhenVersionDontExist() {
- Version nonExistingVersion = new Version(VERSION1_ID);
- doThrow(new RuntimeException()).when(versioningManagerMock).get(ITEM1_ID, nonExistingVersion);
- workflowVersionManager.get(ITEM1_ID, VERSION1_ID);
- }
-
- @Test
- public void shouldReturnWorkflowVersionWhenExist() {
- Version version = new Version(VERSION1_ID);
- doReturn(version).when(versioningManagerMock).get(ITEM1_ID, version);
- workflowVersionManager.get(ITEM1_ID, VERSION1_ID);
- verify(versioningManagerMock).get(ITEM1_ID, version);
- }
-
- @Test
- public void shouldReturnWorkflowVersionList() {
- List<Version> versionList = Arrays.asList(new Version(VERSION1_ID), new Version(VERSION2_ID));
- versionList.forEach(version -> {
- version.setBaseId("baseVersionId");
- version.setDescription("Version description");
- version.setName("name");
- version.setCreationTime(new Date());
- version.setModificationTime(new Date());
- });
- doReturn(versionList).when(versioningManagerMock).list(ITEM1_ID);
- workflowVersionManager.list(ITEM1_ID);
- verify(versioningManagerMock).list(ITEM1_ID);
- verify(versionMapperMock, times(2)).versionToWorkflowVersion(any(Version.class));
- }
-
- @Test
- public void shouldUpdateWorkflowVersion() {
- Version retrievedVersion = new Version(VERSION1_ID);
- retrievedVersion.setName("1.0");
- retrievedVersion.setDescription("WorkflowVersion description");
- retrievedVersion.setStatus(VersionStatus.Draft);
- doReturn(retrievedVersion).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
- doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(retrievedVersion.getStatus());
-
- WorkflowVersion inputVersion = new WorkflowVersion(VERSION1_ID);
- inputVersion.setName("1.0");
- inputVersion.setDescription("WorkflowVersion description updated");
-
- Version mappedInputVersion = new Version(VERSION1_ID);
- mappedInputVersion.setName("1.0");
- mappedInputVersion.setDescription("WorkflowVersion description updated");
- doReturn(mappedInputVersion).when(versionMapperMock).workflowVersionToVersion(inputVersion);
-
- ArgumentCaptor<Version> versionArgCaptor = ArgumentCaptor.forClass(Version.class);
- workflowVersionManager.update(ITEM1_ID, inputVersion);
-
- verify(versioningManagerMock).updateVersion(eq(ITEM1_ID), versionArgCaptor.capture());
- Version captorVersion = versionArgCaptor.getValue();
- assertEquals("1.0", captorVersion.getName());
- assertEquals("WorkflowVersion description updated", captorVersion.getDescription());
- assertEquals(VersionStatus.Draft, captorVersion.getStatus());
- verify(versioningManagerMock).publish(ITEM1_ID, mappedInputVersion, "Update version");
- }
-
- @Test
- public void shouldCreateWorkflowVersion() {
- Version version = new Version(VERSION1_ID);
- version.setDescription("version desc");
- doReturn(version).when(versioningManagerMock).create(ITEM1_ID, version, VersionCreationMethod.major);
- VersionRequestDto workflowVersion = new VersionRequestDto();
- workflowVersion.setDescription("version desc");
- workflowVersionManager.create(ITEM1_ID, workflowVersion);
- verify(versioningManagerMock).create(ITEM1_ID, version, VersionCreationMethod.major);
-
- }
-
- @Test(expected = VersionCreationException.class)
- public void shouldTrowExceptionWhenDraftVersionExists() {
- VersionRequestDto versionRequestDto = new VersionRequestDto();
- versionRequestDto.setBaseVersionId(VERSION2_ID);
-
- Version baseVersion = new Version(VERSION2_ID);
- baseVersion.setStatus(VersionStatus.Draft);
- List<Version> versions = Collections.singletonList(baseVersion);
- doReturn(versions).when(versioningManagerMock).list(ITEM1_ID);
-
- workflowVersionManager.create(ITEM1_ID, versionRequestDto);
- }
-
- @Test(expected = EntityNotFoundException.class)
- public void getStateOfNonExisting() {
- doThrow(new RuntimeException()).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
- workflowVersionManager.getState(ITEM1_ID, VERSION1_ID);
- }
-
- @Test
- public void getState() {
- Version version = new Version(VERSION1_ID);
- version.setStatus(VersionStatus.Certified);
- doReturn(version).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
- doReturn(CERTIFIED).when(versionStateMapperMock).versionStatusToWorkflowVersionState(version.getStatus());
-
- WorkflowVersionState state = workflowVersionManager.getState(ITEM1_ID, VERSION1_ID);
- assertEquals(CERTIFIED, state);
- }
-
- @Test(expected = EntityNotFoundException.class)
- public void updateStateOfNonExisting() {
- doThrow(new RuntimeException()).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
- workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED);
- }
-
- @Test(expected = VersionStateModificationException.class)
- public void updateStateToCurrentState() {
- Version version = new Version(VERSION1_ID);
- version.setStatus(VersionStatus.Draft);
- doReturn(version).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
- doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(version.getStatus());
-
- workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, DRAFT);
- }
-
- @Test(expected = VersionStateModificationException.class)
- public void updateStateWhenCertified() {
- Version version = new Version(VERSION1_ID);
- version.setStatus(VersionStatus.Certified);
- doReturn(version).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
- doReturn(CERTIFIED).when(versionStateMapperMock).versionStatusToWorkflowVersionState(version.getStatus());
-
- workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED);
- }
-
- @Test
- public void updateState() {
- Version retrievedVersion = new Version(VERSION1_ID);
- retrievedVersion.setStatus(VersionStatus.Draft);
- doReturn(retrievedVersion).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
- doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(VersionStatus.Draft);
- doReturn(VersionStatus.Certified).when(versionStateMapperMock).workflowVersionStateToVersionStatus(CERTIFIED);
-
- ArgumentCaptor<Version> versionArgCaptor = ArgumentCaptor.forClass(Version.class);
- workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED);
-
- verify(versioningManagerMock).updateVersion(eq(ITEM1_ID), versionArgCaptor.capture());
- assertEquals(VersionStatus.Certified, versionArgCaptor.getValue().getStatus());
- verify(versioningManagerMock)
- .publish(eq(ITEM1_ID), eqVersion(VERSION1_ID), eq("Update version state from DRAFT to CERTIFIED"));
- }
-
- @Test
- public void shouldUploadArtifact() {
- Version version = new Version(VERSION1_ID);
- version.setStatus(VersionStatus.Draft);
- doReturn(version).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
- doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(version.getStatus());
-
- MockMultipartFile mockFile = new MockMultipartFile("data", "filename.txt", "text/plain", "some xml".getBytes());
- workflowVersionManager.uploadArtifact(ITEM1_ID, VERSION1_ID, mockFile);
-
- verify(artifactRepositoryMock).update(eq(ITEM1_ID), eq(VERSION1_ID), any(ArtifactEntity.class));
- }
-
- @Test(expected = EntityNotFoundException.class)
- public void shouldThrowExceptionWhenArtifactNotFound() {
- doReturn(new Version(VERSION1_ID)).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
-
- doReturn(Optional.empty()).when(artifactRepositoryMock).get(ITEM1_ID, VERSION1_ID);
- workflowVersionManager.getArtifact(ITEM1_ID, VERSION1_ID);
- }
-
- @Test
- public void shouldReturnArtifact() throws IOException {
- doReturn(new Version(VERSION1_ID)).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
-
- InputStream inputStreamMock = IOUtils.toInputStream("some test data for my input stream", "UTF-8");
- ArtifactEntity artifactMock = new ArtifactEntity("fileName.txt", inputStreamMock);
- doReturn(Optional.of(artifactMock)).when(artifactRepositoryMock).get(ITEM1_ID, VERSION1_ID);
- ArtifactEntity returnedArtifact = workflowVersionManager.getArtifact(ITEM1_ID, VERSION1_ID);
- assertEquals(artifactMock, returnedArtifact);
- }
-
- private static Version eqVersion(String versionId) {
- return argThat(new EqVersion(versionId));
- }
-
- private static class EqVersion implements ArgumentMatcher<Version> {
-
- private final String versionId;
-
- EqVersion(String versionId) {
- this.versionId = versionId;
- }
-
- @Override
- public boolean matches(Version version) {
- return versionId.equals(version.getId());
- }
- }
-
-}
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapperTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapperTest.java
deleted file mode 100644
index b778de47..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapperTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.onap.sdc.workflow.services.impl.mappers;
-
-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.WorkflowVersionState;
-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, VersionStateMapper.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.setState(WorkflowVersionState.CERTIFIED);
-
- return workflowVersion;
- }
-}
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapperTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapperTest.java
deleted file mode 100644
index 59d16289..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapperTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.onap.sdc.workflow.services.impl.mappers;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
-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 = VersionStateMapperTest.VersionStatusMapperSpringTestConfig.class)
-@RunWith(SpringJUnit4ClassRunner.class)
-public class VersionStateMapperTest {
-
- @Configuration
- @ComponentScan(basePackageClasses = {VersionStateMapper.class})
- public static class VersionStatusMapperSpringTestConfig { }
-
-
- @Autowired
- VersionStateMapper versionStateMapper;
-
- @Test
- public void shouldMapCertifiedVersionStatusToWorkflowVersionStatus() {
- WorkflowVersionState mappedVersionStatus =
- versionStateMapper.versionStatusToWorkflowVersionState(VersionStatus.Certified);
- assertEquals(WorkflowVersionState.CERTIFIED, mappedVersionStatus);
- }
-
- @Test
- public void shouldMapDraftVersionStatusToWorkflowVersionStatus() {
- WorkflowVersionState mappedVersionStatus =
- versionStateMapper.versionStatusToWorkflowVersionState(VersionStatus.Draft);
- assertEquals(WorkflowVersionState.DRAFT, mappedVersionStatus);
- }
-
- @Test
- public void shouldMapDeletedVersionStatusToWorkflowVersionStatus() {
- WorkflowVersionState mappedVersionStatus =
- versionStateMapper.versionStatusToWorkflowVersionState(VersionStatus.Deleted);
- assertEquals(WorkflowVersionState.DRAFT, mappedVersionStatus);
- }
-
- @Test
- public void shouldMapLockedVersionStatusToWorkflowVersionStatus() {
- WorkflowVersionState mappedVersionStatus =
- versionStateMapper.versionStatusToWorkflowVersionState(VersionStatus.Locked);
- assertEquals(WorkflowVersionState.DRAFT, mappedVersionStatus);
- }
-
- @Test
- public void shouldMapDeprecatedVersionStatusToWorkflowVersionStatus() {
- WorkflowVersionState mappedVersionStatus =
- versionStateMapper.versionStatusToWorkflowVersionState(VersionStatus.Deprecated);
- assertEquals(WorkflowVersionState.DRAFT, mappedVersionStatus);
- }
-
- @Test
- public void shouldMapCertifiedWorkflowVersionStatusToVersionStatus() {
- VersionStatus mappedVersionStatus =
- versionStateMapper.workflowVersionStateToVersionStatus(WorkflowVersionState.CERTIFIED);
- assertEquals(VersionStatus.Certified, mappedVersionStatus);
- }
-
- @Test
- public void shouldMapDraftWorkflowVersionStatusToVersionStatus() {
- VersionStatus mappedVersionStatus =
- versionStateMapper.workflowVersionStateToVersionStatus(WorkflowVersionState.DRAFT);
- assertEquals(VersionStatus.Draft, mappedVersionStatus);
- }
-}
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
deleted file mode 100644
index 55802cc0..00000000
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-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.persistence.types.Workflow;
-import org.openecomp.sdc.versioning.types.Item;
-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 = WorkflowMapperTest.WorkflowMapperSpringTestConfig.class)
-@RunWith(SpringJUnit4ClassRunner.class)
-public class WorkflowMapperTest {
-
- @Configuration
- @ComponentScan(basePackageClasses = {WorkflowMapper.class})
- public static class WorkflowMapperSpringTestConfig { }
-
- @Autowired
- WorkflowMapper workflowMapper;
-
- @Test
- public void shouldMapItemToWorkflow() {
-
- Item item = createItem(1,false,true);
- Workflow mappedWorkflow = workflowMapper.itemToWorkflow(item);
- assertEquals(mappedWorkflow.getId(), item.getId());
- assertEquals(mappedWorkflow.getDescription(), item.getDescription());
- assertEquals(mappedWorkflow.getName(), item.getName());
- }
-
- @Test
- public void shouldMapWorkflowToItem(){
-
- Workflow workflow = createWorkflow(1,true);
- Item mappedItem = workflowMapper.workflowToItem(workflow);
- assertEquals(mappedItem.getId(), workflow.getId());
- assertEquals(mappedItem.getDescription(), workflow.getDescription());
- assertEquals(mappedItem.getName(), workflow.getName());
- }
-
-} \ No newline at end of file