summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorChris André <chris.andre@yoppworks.com>2020-05-04 13:58:39 -0400
committerOjas Dubey <Ojas.Dubey@amdocs.com>2020-05-05 12:13:48 +0000
commit8e039ab3f81af2d1452f1b2db06588883529a428 (patch)
treeaf04ec201a37d1af41bf1de8485e3ffd74a9b5e3 /catalog-be/src/main
parentefec7c5f7abb24da6d8ab93a71ee725e1c1f438f (diff)
Add tests for the presence of Optional values
Issue-ID: SDC-3012 Signed-off-by: Chris Andre <chris.andre@yoppworks.com> Change-Id: I56cbf7fb5bd04ad2fbc496231d6abe72066124fe
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java38
1 files changed, 24 insertions, 14 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
index fccc034baa..021e6b49e4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
@@ -183,23 +183,33 @@ public class NodeFilterValidator {
private Either<Boolean, ResponseFormat> validatePropertyData(UIConstraint uiConstraint,
Optional<? extends PropertyDefinition> sourceSelectedProperty,
Optional<? extends PropertyDefinition> targetComponentInstanceProperty) {
- final PropertyDefinition sourcePropDefinition = sourceSelectedProperty.get();
- final String sourceType = sourcePropDefinition.getType();
- final PropertyDefinition targetPropDefinition = targetComponentInstanceProperty.get();
- final String targetType = targetPropDefinition.getType();
- if (sourceType.equals(targetType)) {
- if (schemableTypes.contains(sourceType)) {
- final SchemaDefinition sourceSchemaDefinition = sourcePropDefinition.getSchema();
- final SchemaDefinition targetSchemaDefinition = targetPropDefinition.getSchema();
- if (!sourceSchemaDefinition.equals(targetSchemaDefinition)) {
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.SOURCE_TARGET_SCHEMA_MISMATCH,
- uiConstraint.getServicePropertyName(), uiConstraint.getValue().toString()));
+ if (sourceSelectedProperty.isPresent() && targetComponentInstanceProperty.isPresent()) {
+ final PropertyDefinition sourcePropDefinition = sourceSelectedProperty.get();
+ final String sourceType = sourcePropDefinition.getType();
+ final PropertyDefinition targetPropDefinition = targetComponentInstanceProperty.get();
+ final String targetType = targetPropDefinition.getType();
+ if (sourceType.equals(targetType)) {
+ if (schemableTypes.contains(sourceType)) {
+ final SchemaDefinition sourceSchemaDefinition = sourcePropDefinition.getSchema();
+ final SchemaDefinition targetSchemaDefinition = targetPropDefinition.getSchema();
+ if (!sourceSchemaDefinition.equals(targetSchemaDefinition)) {
+ return Either
+ .right(componentsUtils.getResponseFormat(ActionStatus.SOURCE_TARGET_SCHEMA_MISMATCH,
+ uiConstraint.getServicePropertyName(), uiConstraint.getValue().toString()));
+ }
}
+ return Either.left(Boolean.TRUE);
+ } else {
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.SOURCE_TARGET_PROPERTY_TYPE_MISMATCH,
+ uiConstraint.getServicePropertyName(), uiConstraint.getValue().toString()));
}
- return Either.left(Boolean.TRUE);
} else {
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.SOURCE_TARGET_PROPERTY_TYPE_MISMATCH,
- uiConstraint.getServicePropertyName(), uiConstraint.getValue().toString()));
+ LOGGER.debug(
+ "Null value passed to `validatePropertyData` - sourceSelectedProperty: '{}' - targetComponentInstanceProperty: '{}'",
+ sourceSelectedProperty, targetComponentInstanceProperty);
+ return Either.right(componentsUtils
+ .getResponseFormat(ActionStatus.GENERAL_ERROR, uiConstraint.getServicePropertyName(),
+ uiConstraint.getValue().toString()));
}
}
ral.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3">
  <bpmn:process id="DeleteVFCNSResource" name="DeleteVFCNSResource" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" name="Start Custom Delete E2E NS">
      <bpmn:outgoing>SequenceFlow_0x2e9we</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_0x2e9we" sourceRef="StartEvent_1" targetRef="Task_0yl3rau" />
    <bpmn:sequenceFlow id="SequenceFlow_00vpfm3" sourceRef="Task_0yl3rau" targetRef="Task_14gmbq4" />
    <bpmn:sequenceFlow id="SequenceFlow_1s4cyms" sourceRef="Task_14gmbq4" targetRef="Task_1e27uaw" />
    <bpmn:endEvent id="EndEvent_07ew0rf" name="End Custom Delete E2E NS">
      <bpmn:incoming>SequenceFlow_0jvtdhv</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_152xb4z" sourceRef="Task_1e27uaw" targetRef="ScriptTask_0pkuukn" />
    <bpmn:scriptTask id="Task_0yl3rau" name="DoCustomDeleteE2ENS prepare" scriptFormat="groovy">
      <bpmn:incoming>SequenceFlow_0x2e9we</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_00vpfm3</bpmn:outgoing>
      <bpmn:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.*
def ddsi = new DeleteVFCNSResource()
ddsi.preProcessRequest(execution)]]></bpmn:script>
    </bpmn:scriptTask>
    <bpmn:scriptTask id="Task_1e27uaw" name="Post delet NS resource" scriptFormat="groovy">
      <bpmn:incoming>SequenceFlow_1s4cyms</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_152xb4z</bpmn:outgoing>
      <bpmn:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.*
def ddsi = new DeleteVFCNSResource()
ddsi.postProcessRequest(execution)]]></bpmn:script>
    </bpmn:scriptTask>
    <bpmn:callActivity id="Task_14gmbq4" name="Call Delete NS Instance" calledElement="DoDeleteVFCNetworkServiceInstance">
      <bpmn:extensionElements>
        <camunda:in source="globalSubscriberId" target="globalSubscriberId" />
        <camunda:in source="serviceType" target="serviceType" />
        <camunda:in source="serviceInstanceId" target="serviceId" />
        <camunda:in source="operationId" target="operationId" />
        <camunda:in source="resourceTemplateId" target="resourceTemplateId" />
        <camunda:in source="resourceInstanceId" target="resourceInstanceId" />
        <camunda:in source="resourceType" target="resourceType" />
        <camunda:in source="operationType" target="operationType" />
        <camunda:out source="operationStatus" target="operationStatus" />
        <camunda:out source="nsInstanceId" target="nsInstanceId" />
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_00vpfm3</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1s4cyms</bpmn:outgoing>
    </bpmn:callActivity>
    <bpmn:subProcess id="SubProcess_11qmm22" triggeredByEvent="true">
      <bpmn:startEvent id="StartEvent_0zwedl6">
        <bpmn:outgoing>SequenceFlow_0yro7o2</bpmn:outgoing>
        <bpmn:errorEventDefinition />
      </bpmn:startEvent>
      <bpmn:endEvent id="EndEvent_10tfowz">
        <bpmn:incoming>SequenceFlow_0p0ayci</bpmn:incoming>
      </bpmn:endEvent>
      <bpmn:scriptTask id="ScriptTask_0tdtqwh" name="Log / Print Unexpected Error">
        <bpmn:incoming>SequenceFlow_0yro7o2</bpmn:incoming>
        <bpmn:outgoing>SequenceFlow_0p0ayci</bpmn:outgoing>
        <bpmn:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
ExceptionUtil ex = new ExceptionUtil()
ex.processJavaException(execution)]]></bpmn:script>
      </bpmn:scriptTask>
      <bpmn:sequenceFlow id="SequenceFlow_0yro7o2" sourceRef="StartEvent_0zwedl6" targetRef="ScriptTask_0tdtqwh" />
      <bpmn:sequenceFlow id="SequenceFlow_0p0ayci" sourceRef="ScriptTask_0tdtqwh" targetRef="EndEvent_10tfowz" />
    </bpmn:subProcess>
    <bpmn:scriptTask id="ScriptTask_0pkuukn" name="Send Sync Ack Response" scriptFormat="groovy">
      <bpmn:incoming>SequenceFlow_152xb4z</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_0jvtdhv</bpmn:outgoing>
      <bpmn:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.*
def dsi = new  DeleteVFCNSResource()
dsi.sendSyncResponse(execution)]]></bpmn:script>
    </bpmn:scriptTask>
    <bpmn:sequenceFlow id="SequenceFlow_0jvtdhv" sourceRef="ScriptTask_0pkuukn" targetRef="EndEvent_07ew0rf" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteVFCNSResource">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="330" y="336" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="312" y="372" width="76" height="24" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0x2e9we_di" bpmnElement="SequenceFlow_0x2e9we">
        <di:waypoint xsi:type="dc:Point" x="366" y="354" />
        <di:waypoint xsi:type="dc:Point" x="474" y="354" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="375" y="333" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_00vpfm3_di" bpmnElement="SequenceFlow_00vpfm3">
        <di:waypoint xsi:type="dc:Point" x="574" y="354" />
        <di:waypoint xsi:type="dc:Point" x="661" y="354" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="572.5" y="333" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1s4cyms_di" bpmnElement="SequenceFlow_1s4cyms">
        <di:waypoint xsi:type="dc:Point" x="761" y="354" />
        <di:waypoint xsi:type="dc:Point" x="889" y="354" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="780" y="333" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="EndEvent_07ew0rf_di" bpmnElement="EndEvent_07ew0rf">
        <dc:Bounds x="1313" y="336" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1293" y="376" width="76" height="24" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_152xb4z_di" bpmnElement="SequenceFlow_152xb4z">
        <di:waypoint xsi:type="dc:Point" x="989" y="354" />
        <di:waypoint xsi:type="dc:Point" x="1113" y="354" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1006" y="333" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ScriptTask_1ssr09e_di" bpmnElement="Task_0yl3rau">
        <dc:Bounds x="474" y="314" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ScriptTask_092ktxo_di" bpmnElement="Task_1e27uaw">
        <dc:Bounds x="889" y="314" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="CallActivity_00p99pt_di" bpmnElement="Task_14gmbq4">
        <dc:Bounds x="661" y="314" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="SubProcess_11qmm22_di" bpmnElement="SubProcess_11qmm22" isExpanded="true">
        <dc:Bounds x="636" y="539" width="350" height="200" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="StartEvent_0zwedl6_di" bpmnElement="StartEvent_0zwedl6">
        <dc:Bounds x="667" y="606" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="639" y="644" width="0" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_10tfowz_di" bpmnElement="EndEvent_10tfowz">
        <dc:Bounds x="931" y="606" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="904" y="645" width="0" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ScriptTask_0tdtqwh_di" bpmnElement="ScriptTask_0tdtqwh">
        <dc:Bounds x="763" y="584" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0yro7o2_di" bpmnElement="SequenceFlow_0yro7o2">
        <di:waypoint xsi:type="dc:Point" x="703" y="624" />
        <di:waypoint xsi:type="dc:Point" x="763" y="624" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="688" y="603" width="0" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0p0ayci_di" bpmnElement="SequenceFlow_0p0ayci">
        <di:waypoint xsi:type="dc:Point" x="863" y="624" />
        <di:waypoint xsi:type="dc:Point" x="931" y="624" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="852" y="603" width="0" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ScriptTask_0pkuukn_di" bpmnElement="ScriptTask_0pkuukn">
        <dc:Bounds x="1113" y="314" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0jvtdhv_di" bpmnElement="SequenceFlow_0jvtdhv">
        <di:waypoint xsi:type="dc:Point" x="1213" y="354" />
        <di:waypoint xsi:type="dc:Point" x="1313" y="354" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1263" y="333" width="0" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>