diff options
author | Steve Smokowski <ss835w@att.com> | 2019-10-22 18:10:01 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-10-22 18:10:01 +0000 |
commit | 86f62530f1813152efbcc3d61f85e1fa6c943e36 (patch) | |
tree | 7915140b82d866230164fa545166f4030d91ff9d /bpmn/so-bpmn-tasks/src/main | |
parent | 91c976affc2a25fed5e184b0b62414eaf7e13df4 (diff) | |
parent | 847d9cefc96b4f5a9bbd6d3dc1d8d28789346304 (diff) |
Merge "add junit coverage and sonar fix"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
2 files changed, 13 insertions, 5 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/VnfNotFoundException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/VnfNotFoundException.java new file mode 100644 index 0000000000..e1c2e01832 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/VnfNotFoundException.java @@ -0,0 +1,7 @@ +package org.onap.so.bpmn.infrastructure.flowspecific.exceptions; + +public class VnfNotFoundException extends Exception { + public VnfNotFoundException(String modelCustomizationUuidOfSearchedVnf) { + super("Can not find vnf for model customization uuid: " + modelCustomizationUuidOfSearchedVnf); + }; +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java index e73a504291..3a69d27f32 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java @@ -22,11 +22,13 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.UUID; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.flowspecific.exceptions.VnfNotFoundException; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -127,12 +129,12 @@ public class ConfigAssignVnf { return getServiceObjectFromServiceMap(serviceMap); } - private Service getServiceObjectFromServiceMap(Map<String, Object> serviceMap) throws Exception { + private Service getServiceObjectFromServiceMap(Map<String, Object> serviceMap) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); String serviceFromJson = objectMapper.writeValueAsString(serviceMap.get("service")); try { return objectMapper.readValue(serviceFromJson, Service.class); - } catch (Exception e) { + } catch (IOException e) { logger.error(String.format( "An exception occurred while converting json object to Service object. The json is: %s", serviceFromJson), e); @@ -141,15 +143,14 @@ public class ConfigAssignVnf { } private List<Map<String, String>> getInstanceParamForVnf(Service service, String genericVnfModelCustomizationUuid) - throws Exception { + throws VnfNotFoundException { Optional<Vnfs> foundedVnf = service.getResources().getVnfs().stream() .filter(vnfs -> vnfs.getModelInfo().getModelCustomizationId().equals(genericVnfModelCustomizationUuid)) .findFirst(); if (foundedVnf.isPresent()) { return foundedVnf.get().getInstanceParams(); } else { - throw new Exception(String.format("Can not find vnf for genericVnfModelCustomizationUuid: %s", - genericVnfModelCustomizationUuid)); + throw new VnfNotFoundException(genericVnfModelCustomizationUuid); } } } |