diff options
author | Bhatt, Prema <prema.bhatt@att.com> | 2019-06-18 15:13:35 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-06-18 15:13:42 -0400 |
commit | 496a93265e8326e48aba073e825df25b13349bbe (patch) | |
tree | c8152d487d9897b7fdaa9cf81c2c73fdcf478b3c /bpmn/so-bpmn-tasks/src/main | |
parent | 7c69f07593a8c7474bd7a69a65979dc0635f1526 (diff) |
nullpointer in vnfadaptervfmoduleobjectmapper
Added code block to throw exception when we get a 'Name' wthout a
'Value' tag in the SDNC vf-module-topology. Right now we are seeing
oam0_net_id is missing a value tag. Added Unit test to test this code
change.
Change-Id: I765d5a4eb9d351b7613d4c3561a2a5dbe37e4781
Issue-ID: SO-2031
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
3 files changed, 27 insertions, 3 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index a1fcbff0db..bf8c80db82 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -78,6 +78,9 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.entity.MsoRequest; import org.onap.so.jsonpath.JsonPathUtil; import org.onap.so.openstack.utils.MsoMulticloudUtils; +import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonParseException; @@ -92,6 +95,7 @@ import com.google.common.base.Joiner; public class VnfAdapterVfModuleObjectMapper { @Autowired protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils; + private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVfModuleObjectMapper.class); private static List<String> sdncResponseParamsToSkip = asList("vnf_id", "vf_module_id", "vnf_name", "vf_module_name"); @@ -203,8 +207,8 @@ public class VnfAdapterVfModuleObjectMapper { return paramsMap; } - private void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive, - Map<String, Object> srcMap) { + protected void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive, + Map<String, Object> srcMap) throws MissingValueTagException { StringBuilder directives = new StringBuilder(); int no_directives_size = 0; if (directive.equals(MsoMulticloudUtils.USER_DIRECTIVES) @@ -217,6 +221,10 @@ public class VnfAdapterVfModuleObjectMapper { for (String attributeName : srcMap.keySet()) { if (!(MsoMulticloudUtils.USER_DIRECTIVES.equals(directive) && attributeName.equals(MsoMulticloudUtils.OOF_DIRECTIVES))) { + if (srcMap.get(attributeName) == null) { + logger.error("No value tag found for attribute: {}", attributeName); + throw new MissingValueTagException("No value tag found for " + attributeName); + } directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString())); if (i < (srcMap.size() - 1 + no_directives_size)) directives.append(", "); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/exceptions/MissingValueTagException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/exceptions/MissingValueTagException.java new file mode 100644 index 0000000000..7271971e46 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/exceptions/MissingValueTagException.java @@ -0,0 +1,15 @@ +package org.onap.so.client.adapter.vnf.mapper.exceptions; + +public class MissingValueTagException extends Exception { + + private static final long serialVersionUID = -1598147488593823724L; + + public MissingValueTagException() { + super(); + } + + public MissingValueTagException(String message) { + super(message); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java index efe5f34824..0a825b8424 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java @@ -33,6 +33,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper; +import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -47,7 +48,7 @@ public class VnfAdapterVfModuleResources { public CreateVfModuleRequest createVfModuleRequest(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) - throws IOException { + throws IOException, MissingValueTagException { return vnfAdapterVfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse); |