aboutsummaryrefslogtreecommitdiffstats
path: root/workflow-designer-be/src/main
diff options
context:
space:
mode:
authorayalaben <ayala.benzvi@amdocs.com>2018-06-27 12:41:14 +0300
committerayalaben <ayala.benzvi@amdocs.com>2018-06-27 14:37:16 +0300
commit2dc593aabe936a21783d7d4e6b7475cab59be6a9 (patch)
treee4cea88a5b3a1b55ee5af52122f9b669589b326d /workflow-designer-be/src/main
parente9d97234f17d8ecdbfc0481d6a2ba2698d52ddd0 (diff)
Service layer unit tests
Change-Id: Ia1c87e81feab7b918a7af52ee1f52914e253dc09 Issue-ID: SDC-1445 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'workflow-designer-be/src/main')
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java1
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java3
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java4
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java7
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java17
5 files changed, 8 insertions, 24 deletions
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
index 76a6591c..8c66d820 100644
--- 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
@@ -9,5 +9,4 @@ public class Workflow {
private String id;
private String name;
private String description;
- private String category;
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java
index d98a15d7..3bf86ad1 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java
@@ -4,4 +4,5 @@ public class VersionNotFoundException extends RuntimeException {
public VersionNotFoundException(String workflowId, String versioId) {
super(String.format("version with id '%s' does not exist for workflow with id %s",versioId,workflowId));
- } }
+ }
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
index aa4bb6f6..8bb5f709 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
@@ -1,6 +1,7 @@
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.services.mappers.WorkflowMapper;
import org.onap.sdc.workflow.persistence.types.Workflow;
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Service;
public class WorkflowManagerImpl implements WorkflowManager {
private static final String WORKFLOW_TYPE = "WORKFLOW";
+ protected static final Predicate<Item> ITEM_PREDICATE = item -> WORKFLOW_TYPE.equals(item.getType());
private static final String WORKFLOW_NAME_UNIQUE_TYPE = "WORKFLOW_NAME";
private final ItemManager itemManager;
private final UniqueValueService uniqueValueService;
@@ -33,7 +35,7 @@ public class WorkflowManagerImpl implements WorkflowManager {
@Override
public Collection<Workflow> list() {
- return itemManager.list(item -> WORKFLOW_TYPE.equals(item.getType())).stream()
+ return itemManager.list(ITEM_PREDICATE).stream()
.map(item -> workflowMapper.itemToWorkflow(item)).collect(Collectors.toList());
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
index cda17914..b0a14fd6 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
@@ -3,7 +3,6 @@ package org.onap.sdc.workflow.services.impl;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
-import java.util.Optional;
import org.onap.sdc.workflow.services.WorkflowVersionManager;
import org.onap.sdc.workflow.services.exceptions.VersionNotFoundException;
import org.openecomp.sdc.versioning.VersioningManager;
@@ -50,11 +49,9 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
versioningManager.updateVersion(id,version);
}
- private Version getLatestVersion(String itemId) {
+ protected Version getLatestVersion(String itemId) {
List<Version> list = versioningManager.list(itemId);
- Optional<Version> max = list.stream().max(Version::compareTo);
-
- return max.orElse(null);
+ return list.stream().max(Version::compareTo).orElse(null);
}
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java
index c603908b..5615b861 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java
@@ -1,32 +1,17 @@
package org.onap.sdc.workflow.services.mappers;
-import java.util.Collections;
-import java.util.Map;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
-import org.mapstruct.Named;
import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.persistence.types.WorkflowProperty;
import org.openecomp.sdc.versioning.types.Item;
@Mapper(componentModel = "spring")
public interface WorkflowMapper {
- @Mapping(source = "properties", target = "category", qualifiedByName = "propertiesToCategoryMapper")
Workflow itemToWorkflow(Item item);
- @Mapping(source = "category", target = "properties", qualifiedByName = "categoryToPropertiesMapper")
+
@InheritInverseConfiguration
Item workflowToItem(Workflow workflow);
- @Named("propertiesToCategoryMapper")
- default String customPropertiesToCategoryMapper(Map<String, Object> properties) {
- return String.class.cast(properties.get(WorkflowProperty.CATEGORY));
- }
-
- @Named("categoryToPropertiesMapper")
- default Map<String, Object> customCategoryToPropertiesMapper(String category) {
- return Collections.singletonMap(WorkflowProperty.CATEGORY, category);
- }
}