diff options
Diffstat (limited to 'src/test')
71 files changed, 0 insertions, 4610 deletions
diff --git a/src/test/java/org/onap/sdc/impl/CapReqWithSameNamesTest.java b/src/test/java/org/onap/sdc/impl/CapReqWithSameNamesTest.java deleted file mode 100644 index 4203293..0000000 --- a/src/test/java/org/onap/sdc/impl/CapReqWithSameNamesTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.sdc.tosca.parser.api.IEntityDetails; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.elements.queries.EntityQuery; -import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery; -import org.onap.sdc.tosca.parser.enums.SdcTypes; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.RequirementAssignment; - -import java.net.URL; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public class CapReqWithSameNamesTest { - - private static ISdcCsarHelper helper = null; - - @BeforeClass - public static void setUpClass() { - try { - URL resource = GetEntityPortMirroringTest.class.getClassLoader() - .getResource("csars/service-VdbePx-csar.csar"); - if (resource != null) { - helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile()); - } - - } catch (SdcToscaParserException e) { - e.printStackTrace(); - } - } - - @Test - public void verify2reqWithSameName() { - EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CONFIGURATION) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - long count = entities.stream() - .flatMap(f -> f.getRequirements().stream()) - .map(RequirementAssignment::getName) - .filter("vlan_assignment"::equals).count(); - assertEquals(2L, count); - - } - -} diff --git a/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java b/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java deleted file mode 100644 index 33e130e..0000000 --- a/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.sdc.tosca.parser.api.IEntityDetails; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.elements.queries.EntityQuery; -import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery; -import org.onap.sdc.tosca.parser.enums.SdcTypes; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.CapabilityAssignment; -import org.onap.sdc.toscaparser.api.RequirementAssignment; - -import java.net.URL; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class GetEntityPortMirroringTest { - - private final static String cap0 = "vepdg5afn0.vlb_1.port_mirroring_vlb_gn_vepdg_fn_5_RVMI"; - private final static String cap1 = "radcomfnvlbavf11_3_3vepdg0.abstract_vlbagentbase_eph_aff.port_mirroring_vlbagentbase_eph_aff_vlbagentbase_eph_aff_int_pktmirror_1_port"; - private static ISdcCsarHelper helper = null; - - @BeforeClass - public static void setUpClass() { - try { - URL resource = GetEntityPortMirroringTest.class.getClassLoader() - .getResource("csars/service-JennnyVepdgPortMirroringTest-csar.csar"); - if (resource != null) { - helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile()); - } - - } catch (SdcToscaParserException e) { - e.printStackTrace(); - } - } - - @Test - public void getServiceConfigurations() { - EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CONFIGURATION) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(1, entities.size()); - assertEquals("54308d8b-21ca-40a1-bd3e-efde64791605", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - assertEquals("Port Mirroring Configuration", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - assertEquals(2, entities.get(0).getRequirements().size()); - assertTrue(entities.get(0).getProperties().isEmpty()); - assertEquals(1, entities.get(0).getCapabilities().size()); - } - - @Test - public void getServiceProxyOnService() { - EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(2, entities.size()); - assertTrue("vEPDG-5A-FN SVC Service Proxy".equals(entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)) || - "vEPDG-5A-FN SVC Service Proxy".equals(entities.get(1).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - assertTrue("Radcom FN vLBA SVC 11_3_3 vEPDG Service Proxy".equals(entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)) || - "Radcom FN vLBA SVC 11_3_3 vEPDG Service Proxy".equals(entities.get(1).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - - assertTrue(entities.get(0).getRequirements().isEmpty()); - assertTrue(entities.get(0).getProperties().isEmpty()); - assertEquals(940, entities.get(0).getCapabilities().size()); - assertEquals(197, entities.get(1).getCapabilities().size()); - } - - @Test - public void getCapabilityForCOnfigurationRequirementOnService() { - EntityQuery entityQueryC = EntityQuery.newBuilder(SdcTypes.CONFIGURATION) - .build(); - - EntityQuery entityQueryS = EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> configurationNodes = helper.getEntity(entityQueryC, topologyTemplateQuery, false); - List<IEntityDetails> proxyNodes = helper.getEntity(entityQueryS, topologyTemplateQuery, false); - - assertEquals(2, proxyNodes.size()); - assertEquals(1, configurationNodes.size()); - - List<RequirementAssignment> reqMap = configurationNodes.get(0).getRequirements(); - assertEquals(cap0, reqMap.stream().filter(f -> f.getName().equals("source")).findAny().get().getCapabilityName()); - assertEquals(cap1, reqMap.stream().filter(f -> f.getName().equals("collector")).findAny().get().getCapabilityName()); - - assertTrue(isCapabilityFound(proxyNodes.get(0), cap0)); - assertTrue(isCapabilityFound(proxyNodes.get(1), cap1)); - } - - private boolean isCapabilityFound(IEntityDetails nodeDetails, String capName) { - List<CapabilityAssignment> assignments = nodeDetails.getCapabilities(); - CapabilityAssignment capabilityAssignment = assignments.stream().filter(f -> f.getDefinition().getName().equals(capName)).findAny().orElse(null); - return capabilityAssignment != null; - } -} diff --git a/src/test/java/org/onap/sdc/impl/GetEntityTest.java b/src/test/java/org/onap/sdc/impl/GetEntityTest.java deleted file mode 100644 index e741cea..0000000 --- a/src/test/java/org/onap/sdc/impl/GetEntityTest.java +++ /dev/null @@ -1,417 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.sdc.tosca.parser.api.IEntityDetails; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.elements.EntityDetails; -import org.onap.sdc.tosca.parser.elements.queries.EntityQuery; -import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery; -import org.onap.sdc.tosca.parser.enums.EntityTemplateType; -import org.onap.sdc.tosca.parser.enums.SdcTypes; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.CapabilityAssignment; -import org.onap.sdc.toscaparser.api.Property; -import org.onap.sdc.toscaparser.api.parameters.Input; - -import java.net.URL; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -public class GetEntityTest { - - private static ISdcCsarHelper helper = null; - - @BeforeClass - public static void setUpClass() { - try { - URL resource = GetEntityTest.class.getClassLoader().getResource("csars/service-JennyVtsbcVlanSvc-csar.csar"); - if (resource != null) { - helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile()); - } - - } catch (SdcToscaParserException e) { - e.printStackTrace(); - } - } - - @Test - public void getCpEntitiesFromCVFC() { - EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .customizationUUID("1fdc9625-dfec-48e1-aaf8-7b92f78ca854") - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(6, entities.size()); - } - - @Test - public void getOneCpEntityFromCVFC() { - EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.resource.cp.v2.extNeutronCP") - .uUID("d5e13a34-c983-4a36-a44a-a53a6e850d73") - .customizationUUID("e97b3399-ab2d-4a34-b07a-9bd5f6461335") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .customizationUUID("1fdc9625-dfec-48e1-aaf8-7b92f78ca854") - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(1, entities.size()); - assertEquals("ssc_ssc_avpn_port_0", entities.get(0).getName()); - assertEquals(18, entities.get(0).getProperties().size()); - assertEquals(1, entities.get(0).getRequirements().size()); - assertEquals(13, entities.get(0).getCapabilities().size()); - assertEquals(0, entities.get(0).getInputs().size()); - List<CapabilityAssignment> capAssignments = entities.get(0).getCapabilities(); - CapabilityAssignment capabilityAssignment = capAssignments.stream().filter(p -> p.getName().equals("network.outgoing.packets.rate")).findAny().orElse(null); - assertEquals("org.openecomp.capabilities.metric.Ceilometer", capabilityAssignment.getDefinition().getType()); - - } - - @Test - public void getCpsFromCVFCRecursively() { - EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true); - - assertEquals(16, entities.size()); - assertEquals("jenny vTSBC vlan VNF 0#abstract_rtp_msc", entities.get(2).getPath()); - assertEquals("jenny vTSBC vlan VNF 0#abstract_rtp_msc#rtp_msc_rtp_msc_avpn_port_0_vlan_subinterface_rtp_msc_avpn", entities.get(7).getPath()); - } - - @Test - public void getCpsFromVfRecursively() { - EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true); - - assertEquals(16, entities.size()); - assertEquals("jenny vTSBC vlan VNF 0#abstract_rtp_msc", entities.get(2).getPath()); - assertEquals("jenny vTSBC vlan VNF 0#abstract_rtp_msc#rtp_msc_rtp_msc_avpn_port_0_vlan_subinterface_rtp_msc_avpn", entities.get(7).getPath()); - } - - @Test - public void getCpByUuidsFromCVFCRecursively() { - EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP) - .customizationUUID("d674b231-34ba-4777-b83a-78be33960a69") - .uUID("f511e1c8-1f21-4370-b7b6-f57a61c15211") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true); - - assertEquals(1, entities.size()); - assertEquals("rtp_msc_subint_mis_vmi_0", entities.get(0).getName()); - assertEquals("ff9ae686-f030-4431-afb7-b65d1bf4733e", entities.get(0).getParent().getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - assertTrue(entities.get(0).getMemberNodes().isEmpty()); - } - - @Test - public void getCpByWrongUuidFromCVFCRecursively() { - EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP) - .customizationUUID("d674b231-34ba-4777-b83a-78be33960a69") - .uUID("f511e1c8-1f21-4370-b7b6-f57a61c15213") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true); - - assertEquals(0, entities.size()); - } - - @Test - public void getServiceGroups() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(4, entities.size()); - assertTrue(entities.get(0).getRequirements().isEmpty()); - assertTrue(entities.get(1).getCapabilities().isEmpty()); - assertEquals(0, entities.get(0).getInputs().size()); - assertTrue(entities.get(0).getPath().isEmpty() && entities.get(1).getPath().isEmpty() && - entities.get(2).getPath().isEmpty() && entities.get(3).getPath().isEmpty()); - } - - @Test - public void getVfGroupsByType1() { - EntityQuery entityQuery = EntityQuery.newBuilder("tosca.groups.Root") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(2, entities.size()); - assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_rtp_msc") || - entities.get(1).getMemberNodes().get(0).getName().equals("abstract_rtp_msc")); - assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_ssc") || - entities.get(1).getMemberNodes().get(0).getName().equals("abstract_ssc")); - - } - - @Test - public void getVfGroupByType2() { - EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(1, entities.size()); - assertTrue(entities.get(0).getName().equals("avpn_group")); - assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_ssc") || - entities.get(0).getMemberNodes().get(1).getName().equals("abstract_ssc")); - assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_rtp_msc") || - entities.get(0).getMemberNodes().get(1).getName().equals("abstract_rtp_msc")); - assertEquals(4, entities.get(0).getProperties().size()); - assertEquals(2, entities.get(0).getMembers().size()); - assertTrue(entities.get(0).getRequirements().isEmpty()); - - } - - @Test - public void getOneServiceGroup() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .customizationUUID("94d27f05-a116-4662-b330-8758c2b049d7") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(1, entities.size()); - assertEquals("org.openecomp.groups.VfModule", entities.get(0).getToscaType()); - assertTrue(entities.get(0).getPath().isEmpty()); - assertTrue(entities.get(0).getMembers().isEmpty()); - assertNull(entities.get(0).getParent()); - assertTrue(entities.get(0).getTargets().isEmpty()); - } - - @Test - public void getAllGroups() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true); - - assertEquals(19, entities.size()); - assertTrue(entities.get(9).getTargetEntities().isEmpty()); - assertEquals(1, entities.get(7).getMembers().size()); - assertEquals("org.openecomp.groups.VfModule", entities.get(7).getToscaType()); - assertEquals("rtp_msc_subint_avpn_vmi_0", entities.get(5).getMemberNodes().get(0).getName()); - } - - @Test - public void getAllPolicies() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true); - - assertEquals(1, entities.size()); - assertEquals("jennyvtsbcvlanvnf..External..0", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - assertEquals(EntityTemplateType.GROUP, entities.get(0).getTargetEntities().get(0).getEntityType()); - assertEquals("org.openecomp.policies.External", entities.get(0).getToscaType()); - assertTrue(entities.get(0).getMembers().isEmpty()); - assertEquals("jenny vTSBC vlan VNF 0", entities.get(0).getPath()); - assertEquals(0, entities.get(0).getInputs().size()); - } - - @Test - public void getServicePolicy() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - assertEquals(0, entities.size()); - } - - @Test - public void getVfPolicyByUUID() { - EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.policies.External") - .uUID("0181f46a-3c68-47dd-9839-8692726356e5") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(1, entities.size()); - assertEquals(EntityTemplateType.GROUP, entities.get(0).getTargetEntities().get(0).getEntityType()); - assertTrue(entities.get(0).getMembers().isEmpty()); - assertTrue(entities.get(0).getRequirements().isEmpty()); - assertTrue(entities.get(0).getCapabilities().isEmpty()); - assertEquals("jenny vTSBC vlan VNF 0", entities.get(0).getPath()); - } - - @Test - public void getVfPolicyByWrongToscaTypeAndUUID() { - EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.policies.External1") - .uUID("0181f46a-3c68-47dd-9839-8692726356e5") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - assertEquals(0, entities.size()); - } - - @Test - public void getCvfcPolicyByToscaTypeAndUUID() { - EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.policies.External") - .uUID("0181f46a-3c68-47dd-9839-8692726356e5") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true); - assertEquals(0, entities.size()); - } - - - @Test - public void getAllEntitiesInServiceOnly() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, false); - assertEquals(5, entities.size()); - assertEquals("org.openecomp.resource.vf.JennyVtsbcVlanVnf", entities.get(4).getToscaType()); - assertEquals("org.openecomp.groups.VfModule", entities.get(0).getToscaType()); - } - - - @Test - public void getAllEntitiesInServiceRecursively() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, true); - assertEquals(48, entities.size()); - } - - @Test - public void getAllEntitiesInCvfcByCUUID() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .customizationUUID("b90c9f8a-9c07-4507-913f-70b533f5934d") - .build(); - - List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, false); - assertEquals(2, entities.size()); - assertTrue(entities.get(1).getMembers().isEmpty()); - assertEquals("ssc_subint_mis_vmi_0", entities.get(0).getMembers().get(0)); - assertTrue("ssc_subint_mis_vmi_0".equals(entities.get(1).getName())); - assertTrue("vlan_subinterface_ssc_mis_group".equals(entities.get(0).getName())); - assertEquals("org.openecomp.resource.cp.nodes.heat.network.v2.contrailV2.VLANSubInterface", - entities.get(1).getToscaType()); - assertEquals("org.openecomp.groups.heat.HeatStack", entities.get(0).getToscaType()); - assertTrue(entities.get(0).getTargetEntities().isEmpty()); - - } - - @Test - public void getAllEntitiesInCvfcByUuidRecursively() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .customizationUUID("1fdc9625-dfec-48e1-aaf8-7b92f78ca854") - .build(); - - List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, true); - assertEquals(13, entities.size()); - } - - @Test - public void getCpPropertyWhenCpIsInInternalCVFC() { - EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.resource.cp.nodes.heat.network.neutron.Port") - .customizationUUID("c03b7d04-5457-4ad2-9102-1edb7806c7b2") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true); - - assertEquals(1, entities.size()); - Property p = entities.get(0).getProperties().get("ip_requirements"); - List<String> valueList = p.getLeafPropertyValue("ip_version"); - assertEquals(1, valueList.size()); - assertEquals("4", valueList.get(0)); - } - - @Test - public void getCpPropertyOnCVFC() { - EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.resource.cp.v2.extNeutronCP") - .customizationUUID("e56919d1-b23f-4334-93b0-1daa507fd2a9") - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .customizationUUID("1fdc9625-dfec-48e1-aaf8-7b92f78ca854") - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - - assertEquals(1, entities.size()); - Property p = entities.get(0).getProperties().get("mac_requirements"); - List<String> valueList = p.getLeafPropertyValue("mac_count_required#is_required"); - assertEquals(1, valueList.size()); - assertEquals("false", valueList.get(0)); - } - - - @Test - public void getServiceInputs() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE) - .build(); - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - - List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); - assertEquals(163, entities.get(0).getInputs().size()); - } -} diff --git a/src/test/java/org/onap/sdc/impl/MyTest.java b/src/test/java/org/onap/sdc/impl/MyTest.java deleted file mode 100644 index a1dcf5b..0000000 --- a/src/test/java/org/onap/sdc/impl/MyTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.testng.annotations.Test; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; - -import java.io.File; - -import static org.onap.sdc.impl.SdcToscaParserBasicTest.getCsarHelper; - -public class MyTest { - - static SdcToscaParserFactory factory; - static ISdcCsarHelper fdntCsarHelper; - - @Test - public void testMyCsar() throws SdcToscaParserException { - - -// factory = SdcToscaParserFactory.getInstance(); -// fdntCsarHelper = getCsarHelper("csars/service-Oren1-csar-4.csar"); -// -// -// List<NodeTemplate> serviceNodeTemplatesByType = fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.nodes.ForwardingPath"); -// -// String target_range = fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceNodeTemplatesByType.get(0), "target_range"); - - } - - - protected static ISdcCsarHelper getCsarHelper(String path) throws SdcToscaParserException { - System.out.println("Parsing CSAR "+path+"..."); - String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile(); - File file1 = new File(fileStr1); - ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath()); - return sdcCsarHelper; - } - -} diff --git a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java deleted file mode 100644 index 0dfe2df..0000000 --- a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.common.JToscaException; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; - -public abstract class SdcToscaParserBasicTest { - - public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73"; - static SdcToscaParserFactory factory; - static ISdcCsarHelper rainyCsarHelperSingleVf; - static ISdcCsarHelper rainyCsarHelperMultiVfs; - static ISdcCsarHelper fdntCsarHelper; - static ISdcCsarHelper fdntCsarHelperWithInputs; - static ISdcCsarHelper nfodCsarHlper; - static ISdcCsarHelper ipAssignCsarHelper; - static ISdcCsarHelper nestedVfcCsarHlper; - static ISdcCsarHelper nfodNEWCsarHlper; - static ISdcCsarHelper QAServiceForToscaParserTests; - static ISdcCsarHelper resolveGetInputCsar; - static ISdcCsarHelper resolveGetInputCsarFalse; - static ISdcCsarHelper resolveGetInputCsarQA; - static ISdcCsarHelper resolveReqsCapsCsarQA; - static ISdcCsarHelper portMirroring; - static ISdcCsarHelper csarHelperServiceWithCrs; - static ISdcCsarHelper csarHelperServicePolicy; - static ISdcCsarHelper csarHelperVfPolicy; - static ISdcCsarHelper csarHelperServiceGroups; - static ISdcCsarHelper csarHelperServiceGroupsInputs; - static ISdcCsarHelper csarHelperServiceGroupsCapabilities; - static ISdcCsarHelper csarHelperVfGroupsPolicies; - static ISdcCsarHelper csarHelperServiceGroupsPolicies; - static ISdcCsarHelper csarHelperVfInterfaces; - static ISdcCsarHelper csarHelperServiceAnnotations; - static ISdcCsarHelper csarHelperServiceAdiodAnnotations; - static ISdcCsarHelper csarHelperServiceNetworkCloud; - - static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data; - - @BeforeSuite - public static void init() throws SdcToscaParserException, JToscaException, IOException { - - factory = SdcToscaParserFactory.getInstance(); - fdntCsarHelper = getCsarHelper("csars/service-sunny-flow.csar", false); - rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar", false); - rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar", false); - fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar", false); - nfodCsarHlper = getCsarHelper("csars/service-NfodService-csar.csar", false); - ipAssignCsarHelper = getCsarHelper("csars/service-Ipassignservice-csar.csar", false); - nestedVfcCsarHlper = getCsarHelper("csars/service-nested-vfc-csar.csar", false); - nfodNEWCsarHlper = getCsarHelper("csars/service-Nfod2images-csar.csar", false); - resolveGetInputCsar = getCsarHelper("csars/service-resolve-get-input-csar.csar"); - resolveGetInputCsarFalse = getCsarHelper("csars/service-resolve-get-input-csar.csar",false); - resolveGetInputCsarQA = getCsarHelper("csars/service-resolve-get-input-csar_QA.csar"); - QAServiceForToscaParserTests = getCsarHelper("csars/service-ServiceForToscaParserTests-csar.csar"); - resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.csar"); - portMirroring = getCsarHelper("csars/service-PortMirroring.csar"); - csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar"); - csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar"); - csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.csar"); - csarHelperServiceGroups = getCsarHelper("csars/service-Groupstest-csar.csar"); - csarHelperServiceGroupsInputs = getCsarHelper("csars/service-VdbeSrv-csar.csar"); - csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar"); - csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar"); - csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar"); - csarHelperServiceAnnotations = getCsarHelper("csars/resource-Sirovinputannotation-csar.csar"); - csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar"); - csarHelperServiceAdiodAnnotations = getCsarHelper("csars/service-AdiodVmxVpeBvService-csar.csar"); - csarHelperServiceNetworkCloud = getCsarHelper("csars/service-NetworkCloudVnfServiceMock-csar.csar"); - - fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){ - { - HashMap<String, List<String>> FDNT ; - - FDNT = new HashMap<String, List<String>>(); - FDNT.put("VF Name", Arrays.asList("FDNT 1")); - FDNT.put("capabilities", Arrays.asList( - "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI", - "dnt_fw_rhrg.host_DNT_FW_SERVER", - "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI", - "dnt_fw_rhrg.scalable_DNT_FW_SERVER", - "dnt_fw_rhrg.endpoint_DNT_FW_SERVER", - "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI", - "dnt_fw_rhrg.os_DNT_FW_SERVER", - "dnt_fw_rhrg.feature", - "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI", - "dnt_fw_rhrg.binding_DNT_FW_SERVER", - "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI", - "dnt_fw_rsg_si_1.feature")); - FDNT.put("requirements", Arrays.asList( - "DNT_FW_RSG_SI_1.dependency", - "DNT_FW_RHRG.dependency", - "DNT_FW_RHRG.link_DNT_FW_INTERNET_DNS_DIRECT_RVMI", - "DNT_FW_RHRG.link_DNT_FW_CORE_DIRECT_RVMI", - "DNT_FW_RHRG.link_DNT_FW_OAM_PROTECTED_RVMI", - "DNT_FW_RHRG.link_DNT_FW_INT_DNS_TRUSTED_RVMI", - "DNT_FW_RHRG.link_DNT_FW_NIMBUS_HSL_RVMI", - "DNT_FW_RSG_SI_1.port", - "DNT_FW_RHRG.local_storage_DNT_FW_SERVER")); - FDNT.put("capabilitiesTypes", Arrays.asList( - "tosca.capabilities.network.Bindable", - "tosca.capabilities.OperatingSystem", - "tosca.capabilities.network.Bindable", - "tosca.capabilities.Scalable", - "tosca.capabilities.Endpoint.Admin", - "tosca.capabilities.network.Bindable", - "tosca.capabilities.network.Bindable", - "tosca.capabilities.network.Bindable", - "tosca.capabilities.Node", - "tosca.capabilities.Container", - "tosca.nodes.SoftwareComponent", - "tosca.capabilities.network.Bindable")); - FDNT.put("capabilityProperties", Arrays.asList( - "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI:none", - "dnt_fw_rhrg.host_DNT_FW_SERVER:num_cpus,integer,false;", - "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI", - "dnt_fw_rhrg.scalable_DNT_FW_SERVER", - "dnt_fw_rhrg.endpoint_DNT_FW_SERVER", - "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI", - "dnt_fw_rhrg.os_DNT_FW_SERVER", - "dnt_fw_rhrg.feature", - "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI", - "dnt_fw_rhrg.binding_DNT_FW_SERVER", - "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI", - "dnt_fw_rsg_si_1.feature")); - - - put("FDNT", FDNT); - } - }; - }; - - protected static ISdcCsarHelper getCsarHelper(String path) throws SdcToscaParserException { - System.out.println("Parsing CSAR "+path+"..."); - String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile(); - File file1 = new File(fileStr1); - ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath()); - return sdcCsarHelper; - } - - protected static ISdcCsarHelper getCsarHelper(String path, boolean resolveGetInput) throws SdcToscaParserException { - System.out.println("Parsing CSAR "+path+"..."); - String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile(); - File file1 = new File(fileStr1); - ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath(), resolveGetInput); - return sdcCsarHelper; - } - - @BeforeMethod - public void setupTest(Method method) { - System.out.println("#### Starting Test " + method.getName() + " ###########"); - } - - @AfterMethod - public void tearDown(Method method){ - System.out.println("#### Ended test " + method.getName() + " ###########"); - } -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserConfigurationTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserConfigurationTest.java deleted file mode 100644 index 30f85e8..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserConfigurationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.onap.sdc.tosca.parser.config.ErrorConfiguration; -import org.onap.sdc.tosca.parser.config.JtoscaValidationIssueConfiguration; -import org.testng.annotations.Test; -import org.onap.sdc.tosca.parser.config.Configuration; -import org.onap.sdc.tosca.parser.config.ConfigurationManager; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -public class ToscaParserConfigurationTest extends SdcToscaParserBasicTest { - - @Test - public void testConfigurationConformanceLevel() { - Configuration config = ConfigurationManager.getInstance().getConfiguration(); - assertNotNull(config); - assertNotNull(config.getConformanceLevel()); - assertNotNull(config.getConformanceLevel().getMaxVersion()); - assertNotNull(config.getConformanceLevel().getMinVersion()); - } - - - @Test - public void testErrorConfigurations() { - ErrorConfiguration errorConfig = ConfigurationManager.getInstance().getErrorConfiguration(); - assertNotNull(errorConfig); - assertNotNull(errorConfig.getErrors()); - } - - @Test - public void testSetErrorConfiguration() { - ConfigurationManager configurationManager = ConfigurationManager.getInstance(); - try { - configurationManager.setErrorConfiguration("error-configuration-test.yaml"); - ErrorConfiguration errorConfig = configurationManager.getErrorConfiguration(); - assertEquals(false, - errorConfig.getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError()); - assertEquals(true, errorConfig.getErrorInfo("FILE_NOT_FOUND").getFailOnError()); - } - finally { - // Reset the configuration for other tests - configurationManager.setErrorConfiguration("error-configuration.yaml"); - } - } - - @Test - public void testSetJtoscaValidationIssueConfiguration() { - ConfigurationManager configurationManager = ConfigurationManager.getInstance(); - try { - configurationManager.setJtoscaValidationIssueConfiguration( - "jtosca-validation-issue-configuration-test.yaml"); - JtoscaValidationIssueConfiguration issueConfig = configurationManager - .getJtoscaValidationIssueConfiguration(); - assertNotNull(issueConfig); - } - finally { - // Reset the configuration for other tests - configurationManager.setJtoscaValidationIssueConfiguration - ("jtosca-validation-issue-configuration.yaml"); - } - } -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserDataTypeTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserDataTypeTest.java deleted file mode 100644 index aed9445..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserDataTypeTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ================================================================================ - * Copyright (C) 2019 Fujitsu Limited. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.elements.DataType; -import org.onap.sdc.toscaparser.api.elements.PropertyDef; -import org.onap.sdc.toscaparser.api.elements.constraints.Schema; - -import java.net.URL; -import java.util.HashSet; -import java.util.LinkedHashMap; - -import static org.junit.Assert.assertThat; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.core.IsNull.notNullValue; - -public class ToscaParserDataTypeTest { - - private static ISdcCsarHelper helper = null; - private static final String TEST_DATATYPE_FILENAME = "csars/dataTypes-test-service.csar"; - private static final String TEST_DATATYPE_TEST1 = "TestType1"; - private static final String TEST_DATATYPE_TEST2 = "TestType2"; - private static final String TEST_DATATYPE_PROPERTY_STR = "strdata"; - private static final String TEST_DATATYPE_PROPERTY_INT = "intdata"; - private static final String TEST_DATATYPE_PROPERTY_LIST = "listdata"; - private static final String TEST_DATATYPE_PROPERTY_TYPE = "type"; - private static final String TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA = "entry_schema"; - - @BeforeClass - public static void setUpClass() { - try { - URL resource = GetEntityPortMirroringTest.class.getClassLoader() - .getResource(TEST_DATATYPE_FILENAME); - if (resource != null) { - helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile()); - } - - } catch (SdcToscaParserException e) { - e.printStackTrace(); - } - } - - @Test - public void getDataTypes() { - HashSet<DataType> dataTypes = helper.getDataTypes(); - assertThat(dataTypes, notNullValue()); - assertThat(dataTypes.size(), is(2)); - - for(DataType dataType: dataTypes){ - LinkedHashMap<String, PropertyDef> properties; - PropertyDef property; - if(dataType.getType().equals(TEST_DATATYPE_TEST1)){ - properties = dataType.getAllProperties(); - property = properties.get(TEST_DATATYPE_PROPERTY_STR); - assertThat(property,notNullValue()); - assertThat(property.getName(),is(TEST_DATATYPE_PROPERTY_STR)); - assertThat( property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE),is(Schema.STRING)); - } - if(dataType.getType().equals(TEST_DATATYPE_TEST2)) { - properties = dataType.getAllProperties(); - property = properties.get(TEST_DATATYPE_PROPERTY_INT); - assertThat(property, notNullValue()); - assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_INT)); - assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.INTEGER)); - - property = properties.get(TEST_DATATYPE_PROPERTY_LIST); - assertThat(property, notNullValue()); - assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_LIST)); - assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.LIST)); - assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA), is(TEST_DATATYPE_TEST1)); - } - } - } - - -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserErrorHandlingTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserErrorHandlingTest.java deleted file mode 100644 index 6c88494..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserErrorHandlingTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.testng.annotations.Test; -import static org.testng.Assert.*; - -import java.io.File; - -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.toscaparser.api.utils.JToscaErrorCodes; - - - -public class ToscaParserErrorHandlingTest extends SdcToscaParserBasicTest { - - - @Test - public void testMissingMetadata(){ - String csarPath = "csars/service-missing-meta-file.csar"; - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - testThrowable(captureThrowable, "TP0002"); - } - - - @Test - public void testInvalidYamlContentMeta(){ - String csarPath = "csars/service-invalid-yaml-content-meta.csar"; - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - testThrowable(captureThrowable, "TP0002"); - } - - @Test - public void testEntryDefinitionNotDefined(){ - String csarPath = "csars/service-entry-definition-not-defined.csar"; - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - testThrowable(captureThrowable, "TP0002"); - } - - @Test - public void testMissingEntryDefinitionFile(){ - String csarPath = "csars/service-missing-entry-definition.csar"; - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - testThrowable(captureThrowable, "TP0002"); - } - - //@Test - PA - there are currently no critical erros in JTosca - public void tesValidationError(){ - String csarPath = "csars/service-invalid-input-args.csar"; - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - testThrowable(captureThrowable, "TP0002"); - } - - @Test - public void testInValidMinConformanceLevelError(){ - String csarPath = "csars/service-invalid-conformence-level.csar"; - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - testThrowable(captureThrowable, "TP0003"); - } - - @Test - public void testIgnoreMaxConformanceLevelNoError(){ - String csarPath = "csars/service-max-conformence-level.csar"; - //TODO: Currently, the conformentce level of the csar for this test is 99 (hard coded). Consider to add ability to replace the configuration in run time. - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - assertNull(captureThrowable); - } - - @Test - public void testVerifyConformanceLevelVersion9(){ - String csarPath = "csars/service-Servicetosca9-csar.csar"; - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - assertNull(captureThrowable); - } - - @Test - public void testFileNotFound(){ - Throwable captureThrowable = captureThrowable("csars/XXX.csar"); - testThrowable(captureThrowable, "TP0001"); - } - - @Test - public void testInvalidCsarFormat(){ - String csarPath = "csars/csar-invalid-zip.zip"; - String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile(); - File file = new File(fileLocationString); - Throwable captureThrowable = captureThrowable(file.getAbsolutePath()); - testThrowable(captureThrowable, "TP0002"); - } - - private static void testThrowable(Throwable captureThrowable, String expectedCode) { - assertNotNull(captureThrowable); - assertTrue(captureThrowable instanceof SdcToscaParserException, "Error thrown is of type "+captureThrowable.getClass().getSimpleName()); - assertEquals(((SdcToscaParserException)captureThrowable).getCode(), expectedCode); - } - - public static Throwable captureThrowable(String csarPath) { - Throwable result = null; - try { - factory.getSdcCsarHelper(csarPath); - } catch( Throwable throwable ) { - result = throwable; - } - return result; - } -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserGeneralUtilTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserGeneralUtilTest.java deleted file mode 100644 index c242d85..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserGeneralUtilTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.testng.annotations.Test; -import org.onap.sdc.tosca.parser.utils.GeneralUtility; - -import static org.testng.Assert.assertTrue; - -public class ToscaParserGeneralUtilTest extends SdcToscaParserBasicTest { - - @Test - public void testVersionCompare() { - assertTrue(GeneralUtility.conformanceLevelCompare("2", "3.0") < 0); - assertTrue(GeneralUtility.conformanceLevelCompare("0.5", "0.5") == 0); - assertTrue(GeneralUtility.conformanceLevelCompare("0.5", "0.6") < 0); - assertTrue(GeneralUtility.conformanceLevelCompare("1.5", "2.6") < 0); - assertTrue(GeneralUtility.conformanceLevelCompare("0.2", "0.1") > 0); - assertTrue(GeneralUtility.conformanceLevelCompare("2", "1.15") > 0); - assertTrue(GeneralUtility.conformanceLevelCompare("2", "2.0.0") == 0); - assertTrue(GeneralUtility.conformanceLevelCompare("2.0", "2.0.0.0") == 0); - assertTrue(GeneralUtility.conformanceLevelCompare("2.", "2.0.0.0") == 0); - assertTrue(GeneralUtility.conformanceLevelCompare("2.0", "2.0.0.2") < 0); - } -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserGroupTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserGroupTest.java deleted file mode 100644 index dc79bb1..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserGroupTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.testng.annotations.Test; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.toscaparser.api.Group; -import org.onap.sdc.toscaparser.api.elements.Metadata; - -import java.util.List; - -import static org.testng.Assert.*; - -public class ToscaParserGroupTest extends SdcToscaParserBasicTest{ - - //region getVfModulesByVf - @Test - public void testVfModulesFromVf(){ - List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); - assertEquals(2, vfModulesByVf.size()); - for (Group group : vfModulesByVf){ - assertTrue(group.getName().startsWith("fdnt1")); - assertNotNull(group.getMetadata()); - assertNotNull(group.getMetadata().getValue("vfModuleModelCustomizationUUID")); - } - } - - @Test - public void testGetGroupMetadata(){ - List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); - boolean found = false; - for (Group group : vfModulesByVf){ - if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")){ - found = true; - Metadata metadata = group.getMetadata(); - assertNotNull(metadata); - assertEquals("b458f4ef-ede2-403d-9605-d08c9398b6ee", metadata.getValue("vfModuleModelCustomizationUUID")); - } - } - assertTrue(found); - } - - @Test - public void testGetGroupEmptyMetadata(){ - List<Group> vfModulesByVf = rainyCsarHelperMultiVfs.getVfModulesByVf("56179cd8-de4a-4c38-919b-bbc4452d2d72"); - boolean found = false; - for (Group group : vfModulesByVf){ - if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")){ - found = true; - Metadata metadata = group.getMetadata(); - assertNull(metadata); - } - } - assertTrue(found); - } - - @Test - public void testGetVfModuleNonExisitingVf() { - List<Group> vfModulesByVf = rainyCsarHelperSingleVf.getVfModulesByVf("dummy"); - assertNotNull(vfModulesByVf); - assertEquals(0, vfModulesByVf.size()); - } - - @Test - public void testGetVfModuleNullVf() { - List<Group> vfModulesByVf = rainyCsarHelperSingleVf.getVfModulesByVf(null); - assertNotNull(vfModulesByVf); - assertEquals(0, vfModulesByVf.size()); - } - //endregion - - //region getGroupPropertyLeafValue - @Test - public void testGroupFlatProperty() throws SdcToscaParserException { - List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); - String volumeGroup = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "volume_group"); - assertEquals("false", volumeGroup); - } - -// @Test -// public void testGroupFlatGetInputProperty() throws SdcToscaParserException { -// List<Group> vfModulesByVf = fdntCsarHelperWithInputs.getVfModulesByVf(VF_CUSTOMIZATION_UUID); -// String volumeGroup = fdntCsarHelperWithInputs.getGroupPropertyLeafValue(vfModulesByVf.get(1), "volume_group"); -// assertEquals("false", volumeGroup); -// } - - @Test - public void testGroupPropertyLeafValueByNullProperty() { - List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); - String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), null); - assertNull(groupProperty); - } - - @Test - public void testGroupPropertyLeafValueByDummyProperty() { - List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); - String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "XXX"); - assertNull(groupProperty); - } - - @Test - public void testGroupPropertyLeafValueByNullGroup() { - String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(null, "volume_group"); - assertNull(groupProperty); - } - //endregion - - //region getGroupPropertyAsObject - @Test - public void testGetGroupPropertyAsObject() { - List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); - Object volumeGroup = fdntCsarHelper.getGroupPropertyAsObject(vfModulesByVf.get(0), "volume_group"); - assertEquals(false, volumeGroup); - } - //getGroupPropertyAsObject - -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java deleted file mode 100644 index a22fd11..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; -import java.util.Map; -import org.mockito.internal.util.collections.Sets; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.elements.InterfacesDef; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class ToscaParserInterfaceTest extends SdcToscaParserBasicTest { - - List<NodeTemplate> vfs; - - @BeforeClass - public void setup(){ - vfs = csarHelperVfInterfaces.getServiceVfList(); - } - - @Test - public void testGetInterfaceOf() { - Map<String, List<InterfacesDef>> interfaceDetails = csarHelperVfInterfaces.getInterfacesOf(vfs.get(0)); - assertNotNull(interfaceDetails); - assertEquals(interfaceDetails.size(), 2); - } - - @Test - public void testGetInterfaces() { - List<String> interfaceNames = csarHelperVfInterfaces.getInterfaces(vfs.get(0)); - assertNotNull(interfaceNames); - assertEquals(interfaceNames, Sets.newSet("org.openecomp.interfaces.node.lifecycle.CxVnf1", "tosca.interfaces.node.lifecycle.Standard")); - } - - @Test - public void testGetInterfaceDetails() { - List<InterfacesDef> interfaceDetails = csarHelperVfInterfaces.getInterfaceDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1"); - assertNotNull(interfaceDetails); - assertEquals(interfaceDetails.get(0).getOperationName(), "instantiate"); - assertEquals(interfaceDetails.get(1).getOperationName(), "upgrade"); - } - - @Test - public void testGetAllInterfaceOperations() { - List<String> operations = csarHelperVfInterfaces.getAllInterfaceOperations(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1"); - assertNotNull(operations); - assertEquals(operations, Sets.newSet("instantiate", "upgrade", "create", "configure", "start", "stop", "delete")); - } - - @Test - public void testGetInterfaceOperationDetails() { - InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "instantiate"); - assertNotNull(interfaceDef); - assertEquals(interfaceDef.getOperationName(), "instantiate"); - } - - @Test - public void testGetInterfaceOperationImplementationDetails() { - InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "upgrade"); - assertNotNull(interfaceDef); - assertNotNull(interfaceDef.getImplementation()); - assertEquals(((Map)interfaceDef.getImplementation()).get("primary"), "Artifacts/Deployment/WORKFLOW/CreateWorkFlow.json"); - assertEquals(((Map)interfaceDef.getImplementation()).get("dependencies"), "TestDependency1"); - } - -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java deleted file mode 100644 index 2acd5a4..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.config.ConfigurationManager; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.elements.Metadata; -import org.testng.annotations.Test; - -import java.util.List; -import java.util.Map; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -public class ToscaParserMetadataTest extends SdcToscaParserBasicTest { - - //region getServiceMetadata - @Test - public void testGetServiceMetadata() { - Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); - assertNotNull(serviceMetadata); - assertEquals("78c72999-1003-4a35-8534-bbd7d96fcae3", serviceMetadata.getValue("invariantUUID")); - assertEquals("Service FDNT", serviceMetadata.getValue("name")); - assertEquals("true", String.valueOf(serviceMetadata.getValue("serviceEcompNaming"))); - } - - @Test - public void testServiceMetadata() { - Metadata metadata = rainyCsarHelperSingleVf.getServiceMetadata(); - assertNull(metadata); - } - //endregion - - //region getMetadataPropertyValue - @Test - public void testGetMetadataProperty(){ - Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); - String metadataPropertyValue = fdntCsarHelper.getMetadataPropertyValue(serviceMetadata, "invariantUUID"); - assertEquals("78c72999-1003-4a35-8534-bbd7d96fcae3", metadataPropertyValue); - } - - @Test - public void testGetNullMetadataPropertyValue() { - String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(null, "XXX"); - assertNull(value); - } - - @Test - public void testGetMetadataByNullPropertyValue() { - Metadata metadata = rainyCsarHelperMultiVfs.getServiceMetadata(); - String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, null); - assertNull(value); - } - - @Test - public void testGetMetadataByEmptyPropertyValue() { - Metadata metadata = rainyCsarHelperMultiVfs.getServiceMetadata(); - String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, ""); - assertNull(value); - } - //endregion - - @Test - public void GetServiceNodeTemplateMetadataTypeCR() { - NodeTemplate nodeTemplate = csarHelperServiceWithCrs.getServiceNodeTemplateByNodeName("chaya best cr 0"); - Metadata nodeTemplateMetadata = csarHelperServiceWithCrs.getNodeTemplateMetadata(nodeTemplate); - assertNotNull(nodeTemplateMetadata); - assertEquals(nodeTemplateMetadata.getValue("resourceVendorModelNumber"), ""); - assertEquals(nodeTemplateMetadata.getValue("type"), "CR"); - assertEquals(nodeTemplateMetadata.getValue("name"), "chaya best cr"); - assertEquals(nodeTemplateMetadata.getValue("version"), "0.1"); - } - - //region getConformanceLevel - @Test - public void testSunnyGetConformanceLevel() { - String conformanceLevel = fdntCsarHelper.getConformanceLevel(); - assertNotNull(conformanceLevel); - assertEquals("3.0", conformanceLevel); - } - //endregion - - //region getServiceMetadataProperties - @Test - public void testNullServiceMetadataPropertiesMap() { - Map<String, Object> metadata = rainyCsarHelperSingleVf.getServiceMetadataProperties(); - assertNull(metadata); - } - - @Test - public void testServiceMetadataPropertiesMap() { - Map<String, Object> metadata = fdntCsarHelper.getServiceMetadataProperties(); - assertNotNull(metadata); - assertEquals(metadata.size(),9); - assertEquals(metadata.get("namingPolicy"),"test"); - } - //endregion - - //region getServiceMetadataAllProperties - @Test - public void testNullServiceMetadataAllPropertiesMap() { - Map<String, String> metadata = rainyCsarHelperSingleVf.getServiceMetadataAllProperties(); - assertNull(metadata); - } - - @Test - public void testServiceMetadataAllPropertiesMap() { - Map<String, String> metadata = fdntCsarHelper.getServiceMetadataAllProperties(); - assertNotNull(metadata); - assertEquals(metadata.size(),9); - assertEquals(metadata.get("namingPolicy"),"test"); - } - //endregion - - //region getNodeTemplateMetadata - @Test - public void testGetNodeTemplateMetadata() { - List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList(); - Metadata metadata = fdntCsarHelper.getNodeTemplateMetadata(vfs.get(0)); - assertNotNull(metadata); - assertEquals("VF", metadata.getValue("type")); - assertEquals("1.0", metadata.getValue("version")); - } - - @Test - public void testGetNodeTemplateMetadataByNull() { - Metadata metadata = fdntCsarHelper.getNodeTemplateMetadata(null); - assertNull(metadata); - } - //endregion - - //QA tests region for US 319197 -port mirroring - - //getNodeTemplateMetadata (All Types) - @Test - public void GetServiceNodeTemplateMetadataTypeVF() { - NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("VF_1_V_port_1 0"); - Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate); - assertNotNull(nodeTemplateMetadata); - assertEquals(nodeTemplateMetadata.getValue("resourceVendorRelease"), "12-12-12"); - assertEquals(nodeTemplateMetadata.getValue("type"), "VF"); - } - - @Test - public void GetServiceNodeTemplateMetadataTypeVL() { - NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtVL 0"); - Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate); - assertNotNull(nodeTemplateMetadata); - assertEquals(nodeTemplateMetadata.getValue("resourceVendorRelease"), "1.0.0.wd03"); - assertEquals(nodeTemplateMetadata.getValue("type"), "VL"); - } - - @Test - public void GetServiceNodeTemplateMetadataTypeCP() { - NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtCP 0"); - Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate); - assertNotNull(nodeTemplateMetadata); - assertEquals(nodeTemplateMetadata.getValue("UUID"), "7a883088-5cab-4bfb-8d55-307d3ffd0758"); - assertEquals(nodeTemplateMetadata.getValue("type"), "CP"); - } - - @Test - public void GetServiceNodeTemplateMetadataTypePNF() { - NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("PNF TEST 0"); - Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate); - assertNotNull(nodeTemplateMetadata); - assertEquals(nodeTemplateMetadata.getValue("resourceVendorModelNumber"), ""); - assertEquals(nodeTemplateMetadata.getValue("type"), "PNF"); - } - - //QA end region for US 319197 -port mirroring - - // Added by QA //region getServiceMetadataAllProperties - - @Test - public void testGetAllMetadataProperties() { - Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); - assertNotNull(serviceMetadata); - Map<String, String> allProperties = serviceMetadata.getAllProperties(); - assertNotNull(allProperties); - String invariantUUID = allProperties.get("invariantUUID"); - String UUID = allProperties.get("UUID"); - String name = allProperties.get("name"); - String description = allProperties.get("description"); - String type = allProperties.get("type"); - String category = allProperties.get("category"); - String ecompGeneratedNaming = allProperties.get("ecompGeneratedNaming"); - String namingPolicy = allProperties.get("namingPolicy"); - String serviceEcompNaming = allProperties.get("serviceEcompNaming"); - - assertEquals(invariantUUID, "78c72999-1003-4a35-8534-bbd7d96fcae3"); - assertEquals(UUID, "edd0a9f7-d084-4423-8461-a2eff4cb3eb6"); - assertEquals(name, "Service FDNT"); - assertEquals(description, "Service FDNT"); - assertEquals(type, "Service"); - assertEquals(category, "Network L1-3"); - assertEquals(ecompGeneratedNaming, "true"); - assertEquals(namingPolicy, "test"); - assertEquals(serviceEcompNaming, "true"); - } - //endregion - - @Test - public void testCSARMissingConformanceLevelWithCustomErrorConfig() throws - SdcToscaParserException { - - ConfigurationManager configurationManager = ConfigurationManager.getInstance(); - try { - configurationManager.setErrorConfiguration("error-configuration-test.yaml"); - SdcToscaParserFactory.setConfigurationManager(configurationManager); - ISdcCsarHelper missingCSARMetaCsarCustomConfig = getCsarHelper - ("csars/service-missing-csar-meta-file.csar"); - String conformanceLevel = missingCSARMetaCsarCustomConfig.getConformanceLevel(); - assertNotNull(conformanceLevel); - assertEquals(conformanceLevel, configurationManager.getConfiguration().getConformanceLevel() - .getMaxVersion()); - } - finally { - configurationManager.setErrorConfiguration("error-configuration.yaml"); - SdcToscaParserFactory.setConfigurationManager(configurationManager); - } - - } - - @Test(expectedExceptions = SdcToscaParserException.class) - public void testCSARMissingConformanceLevelWithDefaultErrorConfig() throws - SdcToscaParserException { - ISdcCsarHelper missingCSARMetaCsarDefaultConfig = getCsarHelper("csars/service-missing-csar-meta-file.csar"); - missingCSARMetaCsarDefaultConfig.getConformanceLevel(); - } - -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java deleted file mode 100644 index 1a36506..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java +++ /dev/null @@ -1,1331 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import java.util.*; -import java.util.stream.Collectors; - -import com.google.common.collect.ImmutableMap; -import org.apache.commons.lang3.tuple.Pair; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.enums.FilterType; -import org.onap.sdc.tosca.parser.enums.SdcTypes; -import org.onap.sdc.toscaparser.api.CapabilityAssignment; -import org.onap.sdc.toscaparser.api.CapabilityAssignments; -import org.onap.sdc.toscaparser.api.Group; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.Policy; -import org.onap.sdc.toscaparser.api.Property; -import org.onap.sdc.toscaparser.api.parameters.Annotation; -import org.onap.sdc.toscaparser.api.parameters.Input; -import org.testng.annotations.Test; - -public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { - - //region getServiceVfList - @Test - public void testNumberOfVfSunnyFlow() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); - assertNotNull(serviceVfList); - assertEquals(2, serviceVfList.size()); - } - - @Test - public void testGetNodeTemplateCustomizationUuid(){ - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); - boolean found = false; - for (NodeTemplate nt : serviceVfList){ - if (nt.getName().equals("FDNT 1")){ - found = true; - assertEquals(fdntCsarHelper.getNodeTemplateCustomizationUuid(nt), "56179cd8-de4a-4c38-919b-bbc4452d2d73"); - } - } - assertTrue(found); - } - - @Test - public void testSingleVFWithNotMetadata() throws SdcToscaParserException { - //If there is no metadata on VF level - There is no VF's because the type is taken from metadata values. - List<NodeTemplate> serviceVfList = rainyCsarHelperSingleVf.getServiceVfList(); - assertNotNull(serviceVfList); - assertEquals(0, serviceVfList.size()); - } - //endregion - - //region getNodeTemplatePropertyLeafValue - @Test - public void testNodeTemplateFlatProperty() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); - assertEquals("2", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "availability_zone_max_count")); - assertEquals("3", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "max_instances")); - assertEquals("some code", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_naming_code")); - } - - @Test - public void testNodeTemplateFlatFunctionProperty() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = fdntCsarHelperWithInputs.getServiceVfList(); - assertEquals(null, fdntCsarHelperWithInputs.getNodeTemplatePropertyLeafValue(serviceVfList.get(1), "target_network_role")); - } - - @Test - public void testNodeTemplateNestedFunctionProperty() throws SdcToscaParserException { - List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - assertEquals(null, ipAssignCsarHelper.getNodeTemplatePropertyLeafValue(vfcs.get(0), "port_pd01_port_ip_requirements#ip_count_required#count")); - } - - @Test - public void testNodeTemplateNestedProperty() throws SdcToscaParserException { - List<NodeTemplate> serviceVlList = fdntCsarHelper.getServiceVlList(); - NodeTemplate nodeTemplate = serviceVlList.get(0); - //System.out.println("node template " + nodeTemplate.toString()); - assertEquals("24", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask")); - assertEquals("7a6520b-9982354-ee82992c-105720", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_flows#vpn_binding")); - } - - @Test - public void testNodeTemplateNestedPropertyFromInput() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); - NodeTemplate nodeTemplate = serviceVfList.get(0); - //System.out.println("node template " + nodeTemplate.toString()); - assertEquals("true", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#ecomp_generated_naming")); - assertEquals("FDNT_instance_VF_2", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#naming_policy")); - } - - @Test - public void testNodeTemplateNestedPropertyNotExists() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); - String nodeTemplatePropertyLeafValue = fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_role#nf_naming#kuku"); - assertNull(nodeTemplatePropertyLeafValue); - } - - @Test - public void testNodeTemplateFlatPropertyByNotFoundProperty() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList(); - String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "XXXX"); - assertNull(nodeTemplatePropertyLeafValue); - } - - @Test - public void testNodeTemplateFlatPropertyByNullProperty() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList(); - String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), null); - assertNull(nodeTemplatePropertyLeafValue); - } - - @Test - public void testNodeTemplateFlatPropertyByNullNodeTemplate() throws SdcToscaParserException { - String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(null, "availability_zone_max_count"); - assertNull(nodeTemplatePropertyLeafValue); - } - //endregion - - //region getServiceVlList - @Test - public void testServiceVl() { - List<NodeTemplate> vlList = fdntCsarHelper.getServiceVlList(); - assertEquals(1, vlList.size()); - assertEquals("exVL", vlList.get(0).getName()); - } - - @Test - public void testNumberOfVLRainyFlow() throws SdcToscaParserException { - List<NodeTemplate> serviceVlList = rainyCsarHelperMultiVfs.getServiceVlList(); - assertNotNull(serviceVlList); - assertEquals(0, serviceVlList.size()); - } - //endregion - - //region getServiceNodeTemplatesByType - @Test - public void testServiceNodeTemplatesByType() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Fdnt"); - assertNotNull(serviceVfList); - assertEquals(1, serviceVfList.size()); - } - - @Test - public void testServiceNodeTemplatesByNull() { - List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType(null); - assertNotNull(nodeTemplates); - assertEquals(0, nodeTemplates.size()); - } - - @Test - public void testServiceNodeTemplatesByNotFoundProperty() { - List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType("XXX"); - assertNotNull(nodeTemplates); - assertEquals(0, nodeTemplates.size()); - } - //endregion - - //region getTypeOfNodeTemplate - @Test - public void testGetTypeOfNodeTemplate() { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); - String typeOfNodeTemplate = fdntCsarHelper.getTypeOfNodeTemplate(serviceVfList.get(0)); - assertEquals("org.openecomp.resource.vf.Fdnt", typeOfNodeTemplate); - } - - @Test - public void testGetTypeOfNullNodeTemplate() { - String typeOfNodeTemplate = rainyCsarHelperMultiVfs.getTypeOfNodeTemplate(null); - assertNull(typeOfNodeTemplate); - } - //endregion - - //region getAllottedResources - @Test - public void testGetAllottedResources() { - List<NodeTemplate> allottedResources = fdntCsarHelper.getAllottedResources(); - assertEquals(1, allottedResources.size()); - } - - @Test - public void testGetAllottedResourcesZero() { - List<NodeTemplate> allottedResources = rainyCsarHelperMultiVfs.getAllottedResources(); - assertNotNull(allottedResources); - assertEquals(0, allottedResources.size()); - } - //endregion - - //region getVfcListByVf - @Test - public void testGetVfcFromVf() { - List<NodeTemplate> vfcListByVf = fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID); - assertEquals(2, vfcListByVf.size()); - } - - @Test - public void testVfcListByNull() { - List<NodeTemplate> vfcList = rainyCsarHelperMultiVfs.getVfcListByVf(null); - assertNotNull(vfcList); - assertEquals(0, vfcList.size()); - } - - @Test - public void testVfcListByNotFoundProperty() { - List<NodeTemplate> vfcList = rainyCsarHelperMultiVfs.getVfcListByVf("XXX"); - assertNotNull(vfcList); - assertEquals(0, vfcList.size()); - } - //endregion - - //region getCpListByVf - @Test - public void testGetCpFromVf() { - List<NodeTemplate> cpListByVf = fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID); - assertEquals(1, cpListByVf.size()); - NodeTemplate nodeTemplate = cpListByVf.get(0); - assertEquals("DNT_PORT", nodeTemplate.getName()); - } - - @Test - public void testGetCpFromVfByNullId() { - List<NodeTemplate> cpListByVf = rainyCsarHelperMultiVfs.getCpListByVf(null); - assertNotNull(cpListByVf); - assertEquals(0, cpListByVf.size()); - } - - @Test - public void testGetCpFromVfXxx() { - List<NodeTemplate> cpListByVf = rainyCsarHelperMultiVfs.getCpListByVf("XXXXX"); - assertNotNull(cpListByVf); - assertEquals(0, cpListByVf.size()); - } - //endregion - - //region getNodeTemplatePairsByReqName - @Test - public void testGetNodeTemplatePairsByReqName() { - List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding"); - assertNotNull(nodeTemplatePairsByReqName); - assertEquals(1, nodeTemplatePairsByReqName.size()); - Pair<NodeTemplate, NodeTemplate> pair = nodeTemplatePairsByReqName.get(0); - NodeTemplate cp = pair.getLeft(); - NodeTemplate vfc = pair.getRight(); - assertEquals("DNT_PORT", cp.getName()); - assertEquals("DNT_FW_RHRG", vfc.getName()); - } - - @Test - public void testGetNodeTemplatePairsByReqNameWithNullVF() { - List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( - null, fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding"); - assertNotNull(nodeTemplatePairsByReqName); - assertEquals(0, nodeTemplatePairsByReqName.size()); - } - - @Test - public void testGetNodeTemplatePairsByReqNameWithEmptyVF() { - List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( - new ArrayList<>(), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding"); - assertNotNull(nodeTemplatePairsByReqName); - assertEquals(0, nodeTemplatePairsByReqName.size()); - } - - @Test - public void testGetNodeTemplatePairsByReqNameWithNullCap() { - List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( - fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), null, "binding"); - assertNotNull(nodeTemplatePairsByReqName); - assertEquals(0, nodeTemplatePairsByReqName.size()); - } - - @Test - public void testGetNodeTemplatePairsByReqNameWithEmptyCap() { - List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( - fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), new ArrayList<>(), "binding"); - assertNotNull(nodeTemplatePairsByReqName); - assertEquals(0, nodeTemplatePairsByReqName.size()); - } - - @Test - public void testGetNodeTemplatePairsByReqNameWithNullReq() { - List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( - fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), null); - assertNotNull(nodeTemplatePairsByReqName); - assertEquals(0, nodeTemplatePairsByReqName.size()); - } - - @Test - public void testGetNodeTemplatePairsByReqNameWithDummyReq() { - - List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName( - fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "XXX"); - assertNotNull(nodeTemplatePairsByReqName); - assertEquals(0, nodeTemplatePairsByReqName.size()); - } - //endregion - - //region getMembersOfVfModule - @Test - public void testGetMembersOfVfModule() { - NodeTemplate vf = fdntCsarHelper.getServiceVfList().get(0); - List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); - assertEquals(2, vfModulesByVf.size()); - for (Group group : vfModulesByVf) { - List<NodeTemplate> membersOfVfModule = fdntCsarHelper.getMembersOfVfModule(vf, group); - assertNotNull(membersOfVfModule); - if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")) { - assertEquals(1, membersOfVfModule.size()); - NodeTemplate nodeTemplate = membersOfVfModule.get(0); - assertEquals("DNT_FW_RSG_SI_1", nodeTemplate.getName()); - } else { - assertEquals("fdnt1..Fdnt..mod_vmsi_dnt_fw_parent..module-1", group.getName()); - assertEquals(1, membersOfVfModule.size()); - NodeTemplate nodeTemplate = membersOfVfModule.get(0); - assertEquals("DNT_FW_RHRG", nodeTemplate.getName()); - } - } - } - - @Test - public void testMembersOfVfModuleByNullVf() { - List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID); - List<NodeTemplate> nodeTemplates = fdntCsarHelper.getMembersOfVfModule(null, vfModulesByVf.get(0)); - assertNotNull(nodeTemplates); - assertEquals(0, nodeTemplates.size()); - } - - @Test - public void testMembersOfVfModuleByNullGroup() { - List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList(); - List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getMembersOfVfModule(serviceVfList.get(0), null); - assertNotNull(nodeTemplates); - assertEquals(0, nodeTemplates.size()); - } - //endregion - - //region getCpPropertiesFromVfc - @SuppressWarnings("unchecked") - @Test - public void testGetCpPropertiesFromVfc() { - List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - boolean isChecked = false; - - for (NodeTemplate vfc: vfcs) { - - if(vfc.getName().equalsIgnoreCase("abstract_pd_server")) - { - isChecked = true; - Map<String, Map<String, Object>> cps = ipAssignCsarHelper.getCpPropertiesFromVfcAsObject(vfc); - - assertEquals(2,cps.size()); - Map<String, Object> pd01 = cps.get("port_pd01_port"); - assertEquals(5, pd01.size()); - - Map<String, Object> firstIpRequirements = (Map<String, Object>) ((List<Object>)pd01.get("ip_requirements")).get(0); - Map<String, Object> secondIpRequirements = (Map<String, Object>) ((List<Object>)pd01.get("ip_requirements")).get(1); - - assertEquals("subnet_role_4", firstIpRequirements.get("subnet_role")); - assertEquals(4, firstIpRequirements.get("ip_version")); - assertEquals(true, ((Map<String, Object>) firstIpRequirements.get("ip_count_required")).get("is_required")); - assertEquals("get_input:node_count", ((Map<String, Object>) firstIpRequirements.get("ip_count_required")).get("count").toString()); - assertEquals(false, ((Map<String, Object>)((Map<String, Object>)pd01.get("mac_requirements")).get("mac_count_required")).get("is_required")); - assertEquals("test_subnetpoolid", pd01.get("subnetpoolid")); - assertEquals("oam", pd01.get("network_role_tag")); - assertEquals(6, secondIpRequirements.get("ip_version")); - } - - } - assertTrue(isChecked); - } - - @Test - public void testGetCpPropertiesFromVfcForNullVFC() { - Map<String, Map<String, Object>> cps = ipAssignCsarHelper.getCpPropertiesFromVfcAsObject(null); - assertNotNull(cps); - assertEquals(0, cps.size()); - } - //endregion - - //region getNodeTemplatePropertyValueAsObject - @Test - public void testGetNodeTemplatePropertyAsObject() { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); - assertEquals("2", fdntCsarHelper.getNodeTemplatePropertyValueAsObject(serviceVfList.get(0), "availability_zone_max_count")); - assertEquals(3, fdntCsarHelper.getNodeTemplatePropertyValueAsObject(serviceVfList.get(0), "max_instances")); - assertEquals("some code", fdntCsarHelper.getNodeTemplatePropertyValueAsObject(serviceVfList.get(0), "nf_naming_code")); - } - //endregion - - //region getServiceNodeTemplates - @Test - public void testServiceNodeTemplates() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplates(); - assertNotNull(serviceVfList); - assertEquals(3, serviceVfList.size()); - assertEquals(serviceVfList.get(2).getName(), "exVL"); - } - //endregion - - //region filterNodeTemplatePropertiesByValue - @Test - public void testFilterNodeTemplatePropertiesByContains() { - List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - boolean isChecked = false; - for (NodeTemplate vfc: vfcs) { - if(vfc.getName().equalsIgnoreCase("abstract_pd_server")) - { - isChecked = true; - Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfc, FilterType.CONTAINS, "get_input"); - - assertEquals(7, filteredInputs.size()); - assertEquals("get_input:availabilityzone_name", filteredInputs.get("compute_pd_server_availability_zone")); - assertEquals("get_input:[pd_server_names, 0]", filteredInputs.get("compute_pd_server_name")); - assertEquals("get_input:node_count", filteredInputs.get("port_pd01_port_ip_requirements#ip_count_required#count")); - - break; - } - - } - assertTrue(isChecked); - } - - @Test - public void testFilterNodeTemplatePropertiesByDummyContains() { - List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfcs.get(0), FilterType.CONTAINS, "dummy"); - assertNotNull(filteredInputs); - assertEquals(0, filteredInputs.size()); - } - - @Test - public void testFilterNodeTemplatePropertiesByEquals() { - List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - boolean isChecked = false; - for (NodeTemplate vfc: vfcs) { - if(vfc.getName().equalsIgnoreCase("abstract_pd_server")) - { - isChecked = true; - Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfc, FilterType.EQUALS, "oam"); - - assertEquals(2, filteredInputs.size()); - assertEquals("oam", filteredInputs.get("port_pd02_port_network_role_tag")); - assertEquals("oam", filteredInputs.get("port_pd01_port_network_role_tag")); - break; - } - - } - assertTrue(isChecked); - } - - @Test - public void testFilterNodeTemplatePropertiesByDummyEquals() { - List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfcs.get(0), FilterType.EQUALS, "dummy"); - assertNotNull(filteredInputs); - assertEquals(0, filteredInputs.size()); - } - - @Test - public void testFilterNodeTemplatePropertiesByNullFilterType() { - List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfcs.get(0), null, "ddc"); - assertNotNull(filteredInputs); - assertEquals(0, filteredInputs.size()); - } - - @Test - public void testFilterNodeTemplatePropertiesByNullPattern() { - List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfcs.get(0), FilterType.EQUALS, null); - assertNotNull(filteredInputs); - assertEquals(0, filteredInputs.size()); - } - - @Test - public void testFilterNodeTemplatePropertiesByNullVfc() { - Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(null, FilterType.EQUALS, "ddc"); - assertNotNull(filteredInputs); - assertEquals(0, filteredInputs.size()); - } - //endregion - - //region getServiceNodeTemplateBySdcType - @Test - public void testServiceNodeTemplateBySdcType() { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplateBySdcType(SdcTypes.VF); - assertNotNull(serviceVfList); - assertEquals(serviceVfList.size(), 2); - assertEquals(serviceVfList.get(0).getName(), "FDNT 1"); - } - - @Test - public void testServiceNodeTemplateBySdcTypeServiceProxy() { - List<NodeTemplate> serviceProxies = portMirroring.getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY); - assertNotNull(serviceProxies); - assertEquals(serviceProxies.size(), 2); - } - - @Test - public void testServiceNodeTemplateByNullSdcType() { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplateBySdcType(null); - assertNotNull(serviceVfList); - assertEquals(serviceVfList.size(), 0); - } - //endregion - - //region getNodeTemplateBySdcType - @Test - public void testNodeTemplateBySdcType() { - List<NodeTemplate> vfList = fdntCsarHelper.getServiceVfList(); - List<NodeTemplate> vfcList = fdntCsarHelper.getNodeTemplateBySdcType(vfList.get(0), SdcTypes.VFC); - assertNotNull(vfcList); - assertEquals(2, vfcList.size()); - assertEquals("DNT_FW_RSG_SI_1", vfcList.get(0).getName()); - } - - @Test - public void testNodeTemplateByNullSdcType() { - List<NodeTemplate> vfList = fdntCsarHelper.getServiceVfList(); - List<NodeTemplate> vfcList = fdntCsarHelper.getNodeTemplateBySdcType(vfList.get(0), null); - assertNotNull(vfcList); - assertEquals(0, vfcList.size()); - } - - @Test - public void testNodeTemplateBySdcTypeNullNT() { - List<NodeTemplate> vfcList = fdntCsarHelper.getNodeTemplateBySdcType(null, SdcTypes.VFC); - assertNotNull(vfcList); - assertEquals(0, vfcList.size()); - } - //endregion - - //region getVnfConfig - @Test - public void testGetVnfConfig() { - NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("9bb2ef82-f8f6-4391-bc71-db063f15bf57"); - assertNotNull(vnfConfig); - assertEquals("vnfConfiguration", vnfConfig.getMetaData().getValue("name")); - } - - @Test - public void testGetVnfConfigByNonFoundVNF() { - NodeTemplate vnfConfig = ipAssignCsarHelper.getVnfConfig("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - assertNull(vnfConfig); - } - - @Test - public void testGetVnfConfigByDummyUUID() { - NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("XXX"); - assertNull(vnfConfig); - } - - @Test - public void testGetVnfConfigByNullUUID() { - NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig(null); - assertNull(vnfConfig); - } - - @Test - public void testGetVfcTypWithoutVnf() { - List<NodeTemplate> vfcList = nfodCsarHlper.getVfcListByVf("9bb2ef82-f8f6-4391-bc71-db063f15bf57"); - assertNotNull(vfcList); - assertEquals(2, vfcList.size()); - } - //endregion - - //region nested vfc - @Test - public void testNestedVfcByExistCvfc() { - List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("71389f8b-8671-4a43-a991-59fb621d3615"); - assertNotNull(vfcList); - assertEquals(vfcList.size(), 2); - assertEquals("VFC1 DUMMY", vfcList.get(0).getName()); - assertEquals("VF_VNF", vfcList.get(1).getName()); - } - - @Test - public void testNestedVfcByNullVf() { - List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf(null); - assertNotNull(vfcList); - assertEquals(0, vfcList.size()); - } - - @Test - public void testNestedVfcByDummyVf() { - List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("dummy"); - assertNotNull(vfcList); - assertEquals(0, vfcList.size()); - } - //endregion - - //region hasTopology - @Test - public void testHasTopologyByVF() { - List<NodeTemplate> vfList = nestedVfcCsarHlper.getServiceVfList(); - boolean hasTopology = nestedVfcCsarHlper.hasTopology(vfList.get(0)); - assertEquals(true, hasTopology); - } - - @Test - public void testHasTopologyByCVFC() { - List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("71389f8b-8671-4a43-a991-59fb621d3615"); - boolean hasTopology = nestedVfcCsarHlper.hasTopology(vfcList.get(1)); - assertEquals(true, hasTopology); - } - - @Test - public void testHasTopologyByVL() { - List<NodeTemplate> serviceVlList = fdntCsarHelper.getServiceVlList(); - boolean hasTopology = fdntCsarHelper.hasTopology(serviceVlList.get(0)); - assertEquals(false, hasTopology); - } - - @Test - public void testHasTopologyByNull() { - boolean hasTopology = fdntCsarHelper.hasTopology(null); - assertEquals(false, hasTopology); - } - //endregion - - //region getNodeTemplateChildren - @Test - public void testGetNodeTemplatesListOfNodeTemplateByVF() { - List<NodeTemplate> vfList = fdntCsarHelper.getServiceVfList(); - List<NodeTemplate> children = fdntCsarHelper.getNodeTemplateChildren(vfList.get(0)); - assertNotNull(children); - assertEquals(3, children.size()); - - children.sort(Comparator.comparing(NodeTemplate::getName)); - - assertEquals("DNT_FW_RSG_SI_1", children.get(1).getName()); - assertEquals("VFC", children.get(1).getMetaData().getValue("type")); - assertEquals("DNT_PORT", children.get(2).getName()); - assertEquals("CP", children.get(2).getMetaData().getValue("type")); - } - - @Test - public void testGetNodeTemplatesListOfNodeTemplateByVFC() { - List<NodeTemplate> vfList = nestedVfcCsarHlper.getServiceVfList(); - List<NodeTemplate> vfChildren = nestedVfcCsarHlper.getNodeTemplateChildren(vfList.get(0)); - assertNotNull(vfChildren); - assertEquals(vfChildren.size(), 2); - vfChildren.sort(Comparator.comparing(NodeTemplate::getName)); - assertEquals("VFC1 DUMMY", vfChildren.get(0).getName()); - assertEquals("VF_VNF", vfChildren.get(1).getName()); - assertEquals("CVFC", vfChildren.get(1).getMetaData().getValue("type")); - - - List<NodeTemplate> vfcChildren = nestedVfcCsarHlper.getNodeTemplateChildren(vfChildren.get(1)); - assertNotNull(vfcChildren); - assertEquals(vfcChildren.size(), 3); - vfcChildren.sort(Comparator.comparing(NodeTemplate::getName)); - assertEquals("Test NIC 02_wan_port", vfcChildren.get(0).getName()); - assertEquals("Test NIC_wan_port", vfcChildren.get(1).getName()); - assertEquals("VF", vfcChildren.get(2).getName()); - } - - @Test - public void testGetNodeTemplatesListOfNodeTemplateByNull() { - List<NodeTemplate> children = fdntCsarHelper.getNodeTemplateChildren(null); - assertNotNull(children); - assertEquals(0, children.size()); - } - //endregion - - // added by QA - // Get specific VNF properties - @Test - public void testGetVnfConfigGetProperties() { - NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("9bb2ef82-f8f6-4391-bc71-db063f15bf57"); - assertNotNull(vnfConfig); - assertEquals("vnfConfiguration", vnfConfig.getMetaData().getValue("name")); - - String manufacturer_reference_number = nfodCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#ATT_part_12345_for_FortiGate-VM00#vendor_info#manufacturer_reference_number"); - String num_cpus = nfodCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#ATT_part_67890_for_FortiGate-VM01#compute_flavor#num_cpus"); - String sp_part_number = nfodCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#ATT_part_67890_for_FortiGate-VM01#sp_part_number"); - - assertEquals("FortiGate-VM00",manufacturer_reference_number); - assertEquals("10",num_cpus); - assertEquals("ATT_part_67890_for_FortiGate-VM01",sp_part_number); - } - - // added by QA - // Check that get vnfconfiguration not return as VFC - @Test - public void testGetVfcTypWithoutVnfCheckNames() { - List<NodeTemplate> vfcList = nfodCsarHlper.getVfcListByVf("9bb2ef82-f8f6-4391-bc71-db063f15bf57"); - assertNotNull(vfcList); - assertEquals(2, vfcList.size()); - for (int i = 0; i < vfcList.size(); i++) { - - String Name= vfcList.get(i).getName(); - - assertEquals(false, Name.equals("vFW_VNF_Configuration")); - - } - } - - @Test - public void testNewGetVnfConfigGetProperties() { - NodeTemplate vnfConfig = nfodNEWCsarHlper.getVnfConfig("a6587663-b27f-4e88-8a86-604604302ce6"); - assertNotNull(vnfConfig); - assertEquals("vnfConfiguration", vnfConfig.getMetaData().getValue("name")); - - //Deployment flavor 1 - String manufacturer_reference_number = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#123456#vendor_info#manufacturer_reference_number"); - String num_cpus = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#123456#compute_flavor#num_cpus"); - String sp_part_number = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#123456#sp_part_number"); - - assertEquals("234567",manufacturer_reference_number); - assertEquals("2",num_cpus); - assertEquals("123456",sp_part_number); - - //Deployment flavor 2 - manufacturer_reference_number = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#FG_partNumbereJqQjUkteF1#vendor_info#manufacturer_reference_number"); - num_cpus = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#FG_partNumbereJqQjUkteF1#compute_flavor#num_cpus"); - sp_part_number = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#FG_partNumbereJqQjUkteF1#sp_part_number"); - - assertEquals("EP_manufacturerReferenceNumberkbAiqZZNzx1",manufacturer_reference_number); - assertEquals("1",num_cpus); - assertEquals("FG_partNumbereJqQjUkteF1",sp_part_number); - } - - // added by QA - // Check that get vnfconfiguration not return as VFC - @Test - public void testNewGetVfcTypWithoutVnfCheckNames() { - List<NodeTemplate> vfcList = nfodNEWCsarHlper.getVfcListByVf("a6587663-b27f-4e88-8a86-604604302ce6"); - assertNotNull(vfcList); - assertEquals(1, vfcList.size()); - for (int i = 0; i < vfcList.size(); i++) { - - String Name= vfcList.get(i).getName(); - - assertEquals(false, Name.equals("name_6GkVrOjnGp1_VNF_Configuration")); - } - } - - //region getServiceNodeTemplateByNodeName - @Test - public void testGetServiceNodeTemplateByRealNodeName() { - NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1"); - assertNotNull(nodeTemplate); - assertEquals(nodeTemplate.getName(), "FDNT 1"); - assertEquals(nodeTemplate.getMetaData().getValue("type"), "VF"); - } - - @Test - public void testGetServiceNodeTemplateByNullNodeName() { - NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName(null); - assertNull(nodeTemplate); - } - - @Test - public void testGetServiceNodeTemplateByDummyNodeName() { - NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("dummy"); - assertNull(nodeTemplate); - } - - - - //endregion - //region resolve get_input - @SuppressWarnings("rawtypes") - @Test - public void testResolveGetInputForComplexTypeAndList() { - //port_pd01_port_ip_requirements is of type list<org.openecomp.datatypes.network.IpRequirements> - //This test covers: - // 1) "default" resolving - // 2) complex type resolving - // 3) List access resolving - List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_ip_requirements"); - assertTrue(propertyAsObject instanceof ArrayList); - assertEquals(2, ((ArrayList) propertyAsObject).size()); - //port_pd01_port_ip_requirements: - //- get_input: [ip_requirements, 0] - //- get_input: [ip_requirements, 1] - assertEquals("subnet_role_4", ((Map) ((ArrayList) propertyAsObject).get(0)).get("subnet_role")); - assertEquals("subnet_role_6", ((Map) ((ArrayList) propertyAsObject).get(1)).get("subnet_role")); - } - - @Test - public void testResolveGetInputForListOnNetworkCloud() { - final String related_network_role = "related_network_role"; - List<NodeTemplate> serviceVfList = csarHelperServiceNetworkCloud.getServiceVfList(); - assertNotNull(serviceVfList); - assertFalse(serviceVfList.isEmpty()); - List<NodeTemplate> vfcListByVf = csarHelperServiceNetworkCloud.getVfcListByVf(csarHelperServiceNetworkCloud.getNodeTemplateCustomizationUuid(serviceVfList.get(0))); - assertNotNull(vfcListByVf); - assertFalse(vfcListByVf.isEmpty()); - List<NodeTemplate> cpList = csarHelperServiceNetworkCloud.getNodeTemplateChildren(vfcListByVf.get(0)); - assertNotNull(cpList); - assertFalse(cpList.isEmpty()); - final Object propertyValue = cpList.get(0).getPropertyValue("related_networks"); - assertNotNull(propertyValue); - ArrayList<Map<String, String>> relatedNetworkList = (ArrayList)propertyValue; - assertEquals(3, relatedNetworkList.size()); - assertEquals("cor_direct_2", relatedNetworkList.get(0).get(related_network_role)); - assertEquals("sgi_direct_2", relatedNetworkList.get(1).get(related_network_role)); - assertEquals("int_imbl_2", relatedNetworkList.get(2).get(related_network_role)); - } - - @Test - public void testResolveGetInputForPrimitiveTypeString() { - //This test covers "default" resolving of primitive - as Object - List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_network_role_tag"); - assertEquals("oam", propertyAsObject); - } - - @Test - public void testResolveGetInputForPrimitiveTypeInteger() { - //This test covers "default" resolving of primitive - as String - List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - String propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyLeafValue(vfcs.get(0), "port_pd01_port_order"); - assertEquals("1", propertyAsObject); - } - - @SuppressWarnings("rawtypes") - @Test - public void testResolveGetInputForMap() { - //This test covers "default" resolving of primitive - as Map - List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd02_port_ip_requirements#ip_count_required"); - assertTrue(propertyAsObject instanceof Map); - assertEquals(false, ((Map)propertyAsObject).get("is_required")); - } - - @Test - public void testResolveGetInputForAllHierarchy() { - //This test covers "default" resolving from service level - List<NodeTemplate> vfs = resolveGetInputCsar.getServiceVfList(); - Object vfPropertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfs.get(0), "vm_count"); - assertEquals(2, vfPropertyAsObject); - //This test covers property assignment resolving on VFI level (service template), from Vf level - List<NodeTemplate> vfcs = resolveGetInputCsar.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.VFC); - Object vfcPropertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "my_count"); - assertEquals(2, vfcPropertyAsObject); //takes it from upper level (VF) property - } - - @Test - public void testResolveGetInputNoDefValueInnerLevel() { - //This test covers resolving when no "default" value is supplied to the input - should be null - VF/VFCI level - List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - String propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyLeafValue(vfcs.get(0), "index_value"); - assertNull(propertyAsObject); - - } - - @Test - public void testResolveGetInputNoDefValueServiceLevel() { - //This test covers resolving when no "default" value is supplied to the input - should be null - Service/VFI level - List<NodeTemplate> vfs = resolveGetInputCsar.getServiceVfList(); - Object vfPropertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfs.get(0), "port_order"); - assertNull(vfPropertyAsObject); - - } - //endregion - - // region Added by QA - Continue with testings of resolve get_input - - @SuppressWarnings("rawtypes") - @Test - public void testResolveGetInputForComplexTypeAndListWithFalseValue() - { - List<NodeTemplate> vfcs = resolveGetInputCsarFalse.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsarFalse.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_ip_requirements"); - assertTrue(propertyAsObject instanceof ArrayList); - assertEquals(2, ((ArrayList) propertyAsObject).size()); - assertEquals("get_input:[ip_requirements, 0]", ((ArrayList) propertyAsObject).get(0).toString()); - assertEquals("get_input:[ip_requirements, 1]", ((ArrayList) propertyAsObject).get(1).toString()); - } - - @Test - public void testResolveGetInputForPrimitiveTypeStringWithFalseValue() { - List<NodeTemplate> vfcs = resolveGetInputCsarFalse.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsarFalse.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_network_role_tag"); - assertEquals("get_input:role_tag_oam", propertyAsObject.toString()); - } - - @Test - public void testResolveGetInputForPrimitiveTypeListWithFalseValue() { - List<NodeTemplate> vfcs = resolveGetInputCsarFalse.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsarFalse.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "compute_pd_server_name"); - assertEquals("[get_input:[pd_server_names, 0]]", propertyAsObject.toString()); - } - - //@Test // Maybe a bug here.... need to check with Esti - Mait was sent. - public void testResolveGetInputForPrimitiveTypeList() { - List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "compute_pd_server_name"); - assertEquals("\"ZRDM1MOGX01MPD001\"", propertyAsObject.toString()); - } - - @Test - public void testResolveGetInputForPrimitiveNullValue() { - List<NodeTemplate> vfcs = resolveGetInputCsarQA.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - @SuppressWarnings("unchecked") - List<String>propertyAsObject = (List<String>) resolveGetInputCsarQA.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "compute_pd_server_availability_zone"); - assertNull(propertyAsObject.get(0)); - } - @Test - public void testResolveGetInputForPrimitiveIPValue() { - List<NodeTemplate> vfcs = resolveGetInputCsarQA.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsarQA.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "vm_image_name"); - assertEquals("107.239.36.5", propertyAsObject.toString()); - } - - //QA region getServiceNodeTemplateByNodeName tests - - @Test - public void getServiceNodeTemplateByNodeNameTypeVF() { - NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("VF_1_V_port_1 0"); - assertNotNull(nodeTemplate); - assertEquals(nodeTemplate.getName(), "VF_1_V_port_1 0"); - assertEquals(nodeTemplate.getMetaData().getValue("type"), "VF"); - } - - @Test - public void getServiceNodeTemplateByNodeNameTypeVL() { - NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtVL 0"); - assertNotNull(nodeTemplate); - assertEquals(nodeTemplate.getName(), "ExtVL 0"); - assertEquals(nodeTemplate.getMetaData().getValue("type"), "VL"); - } - - @Test - public void getServiceNodeTemplateByNodeNameTypeCP() { - NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtCP 0"); - assertNotNull(nodeTemplate); - assertEquals(nodeTemplate.getName(), "ExtCP 0"); - assertEquals(nodeTemplate.getMetaData().getValue("type"), "CP"); - } - - @Test - public void getServiceNodeTemplateByNodeNameTypePNF() { - NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("PNF TEST 0"); - assertNotNull(nodeTemplate); - assertEquals(nodeTemplate.getName(), "PNF TEST 0"); - assertEquals(nodeTemplate.getMetaData().getValue("type"), "PNF"); - } - - //QA region getServiceNodeTemplateBySdcType tests - - @Test - public void getServiceNodeTemplateBySdcType_VF() { - List<NodeTemplate> vfList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Vf1VPort1"); - assertEquals(2, vfList.size()); - assertEquals("VF_1_V_port_1", vfList.get(0).getMetaData().getValue("name")); - } - // endregion Added by QA - Continue with testings of resolve get_input - - - @SuppressWarnings("rawtypes") - @Test - public void testResolveGetInputArrayStructure() { - List<NodeTemplate> vfcs = resolveGetInputCsarQA.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); - Object propertyAsObject = resolveGetInputCsarQA.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "compute_pd_server_name"); - assertEquals( ((ArrayList)propertyAsObject).get(0).toString(), "\"ZRDM1MOGX01MPD001\""); - propertyAsObject = resolveGetInputCsarQA.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_ip_requirements"); - assertEquals(2, ((ArrayList)propertyAsObject).size()); - } - - @Test - public void testServiceNodeTemplateByCRType() { - List<NodeTemplate> serviceCRList = csarHelperServiceWithCrs.getServiceNodeTemplateBySdcType(SdcTypes.CR); - assertNotNull(serviceCRList); - assertEquals(serviceCRList.size(), 2); - assertEquals(serviceCRList.get(0).getName(), "chaya best cr 1"); - assertEquals(serviceCRList.get(0).getType(), "org.openecomp.resource.cr.ChayaBestCr"); - assertEquals(serviceCRList.get(1).getName(), "chaya best cr 0"); - assertEquals(serviceCRList.get(1).getType(), "org.openecomp.resource.cr.ChayaBestCr"); - } - - @Test - public void testGetCPOfCRNodeTemplate() { - NodeTemplate nodeTemplate = csarHelperServiceWithCrs.getServiceNodeTemplateByNodeName("chaya best cr 0"); - List<NodeTemplate> crCpChildren = csarHelperServiceWithCrs.getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CP); - assertEquals(crCpChildren.get(0).getName(), "ContrailPort 0"); - assertEquals(crCpChildren.get(0).getMetaData().getValue("type"), SdcTypes.CP.name()); - } - - @Test - public void testServiceCRInstanceProps() { - List<NodeTemplate> serviceCrList = csarHelperServiceWithCrs.getServiceNodeTemplateBySdcType(SdcTypes.CR); - assertNotNull(serviceCrList); - NodeTemplate crTemplate = serviceCrList.get(0); - assertNotNull(crTemplate); - assertEquals(crTemplate.getPropertyValue("nf_naming").toString(), ImmutableMap.of("ecomp_generated_naming", "true").toString()); - assertEquals(crTemplate.getPropertyValue("contrailport0_virtual_network"), "chaya"); - } - - @Test - public void testGetPoliciesOfOriginOfNodeTemplate() { - NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0"); - NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"); - List<Policy> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt0); - assertNotNull(policies); - assertEquals(policies.size(), 3); - policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt1); - assertNotNull(policies); - assertEquals(policies.size(), 3); - } - - @Test - public void testGetPoliciesOfOriginOfNodeTemplateByToscaPolicyType() { - NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0"); - NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"); - List<Policy> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate"); - assertNotNull(policies); - assertEquals(policies.size(), 1); - - policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Antilocate"); - assertNotNull(policies); - assertEquals(policies.size(), 1); - - policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.valet.Diversity"); - assertNotNull(policies); - assertEquals(policies.size(), 1); - - policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.Colocate"); - assertNotNull(policies); - assertEquals(policies.size(), 1); - - policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.Antilocate"); - assertNotNull(policies); - assertEquals(policies.size(), 1); - - policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.valet.Diversity"); - assertNotNull(policies); - assertEquals(policies.size(), 1); - } - - @Test - public void testGetPolicyTargetNodeTemplatesFromOrigin() { - List<NodeTemplate> nodeTemplates = csarHelperServicePolicy.getPolicyTargetsFromOrigin(csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"),"policy..Colocate..0"); - assertNotNull(nodeTemplates); - assertEquals(nodeTemplates.size(), 2); - } - - @Test - public void testGetPoliciesOfNodeTemplate() { - NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1"); - List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTarget(nt0); - assertNotNull(policies); - assertEquals(policies.size(), 1); - } - - @Test - public void testGetPoliciesOfNodeTemplateByToscaPolicyType() { - NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1"); - List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTargetByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate"); - assertNotNull(policies); - assertEquals(policies.size(), 1); - } - - @Test - public void testGetPoliciesOfTopologyTemplate() { - List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTopologyTemplate(); - assertNotNull(policies); - assertEquals(policies.size(), 1); - } - - @Test - public void testGetPolicyTargetNodeTemplates() { - List<NodeTemplate> nodeTemplates = csarHelperVfPolicy.getPolicyTargetsFromTopologyTemplate("policy..Colocate..0"); - assertNotNull(nodeTemplates); - assertEquals(nodeTemplates.size(), 2); - } - - @Test - public void testGetGroups() { - NodeTemplate groupsVf = csarHelperServiceGroups.getNodeTemplateByName("GroupsVf 0"); - NodeTemplate vlanGroups = csarHelperServiceGroups.getNodeTemplateByName("VlanGroups 0"); - - ArrayList<Group> groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplate(groupsVf); - assertNotNull(groups); - assertEquals(groups.size(), 5); - - groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplate(vlanGroups); - assertNotNull(groups); - assertEquals(groups.size(), 4); - - groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplateByToscaGroupType(groupsVf, "org.openecomp.groups.VfcInstanceGroup"); - assertNotNull(groups); - assertEquals(groups.size(), 1); - - groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplateByToscaGroupType(vlanGroups, "org.openecomp.groups.VfcInstanceGroup"); - assertNotNull(groups); - assertEquals(groups.size(), 2); - - List<NodeTemplate> members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(groupsVf, "x_group"); - - assertNotNull(members); - assertEquals(members.size(), 3); - Optional<NodeTemplate> memberOpt = (members.stream().filter(m -> m.getName().equals("lb_1"))).findFirst(); - assertTrue(memberOpt.isPresent()); - memberOpt = (members.stream().filter(m -> m.getName().equals("lb_2"))).findFirst(); - assertTrue(memberOpt.isPresent()); - memberOpt = (members.stream().filter(m -> m.getName().equals("mg_4"))).findFirst(); - assertTrue(memberOpt.isPresent()); - - members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(vlanGroups, "oam_group"); - assertNotNull(members); - assertEquals(members.size(), 1); - memberOpt = (members.stream().filter(m -> m.getName().equals("abstract_vdbe_1"))).findFirst(); - assertTrue(memberOpt.isPresent()); - - members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(vlanGroups, "untr_group"); - assertNotNull(members); - assertEquals(members.size(), 1); - memberOpt = (members.stream().filter(m -> m.getName().equals("abstract_vdbe"))).findFirst(); - assertTrue(memberOpt.isPresent()); - } - - @Test - public void testGetGroupsInputsProperties() { - NodeTemplate vdbe0 = csarHelperServiceGroupsInputs.getNodeTemplateByName("vDBE 0"); - ArrayList<Group> groups = csarHelperServiceGroupsInputs.getGroupsOfOriginOfNodeTemplate(vdbe0); - assertNotNull(groups); - assertEquals(groups.size(), 4); - - Optional<Group> groupOpt = (groups.stream().filter(g -> g.getName().equals("oam_group"))).findFirst(); - assertTrue(groupOpt.isPresent()); - Group group = groupOpt.get(); - validateInputsProperties(vdbe0, group); - - groupOpt = (groups.stream().filter(g -> g.getName().equals("untr_group"))).findFirst(); - assertTrue(groupOpt.isPresent()); - group = groupOpt.get(); - validateInputsProperties(vdbe0, group); - } - - @Test - public void testGetGroupsInputsCapabilities() { - NodeTemplate vdbe = csarHelperServiceGroupsCapabilities.getNodeTemplateByName("vdbe_srv_proxy 0"); - CapabilityAssignments capabilities = csarHelperServiceGroupsCapabilities.getCapabilitiesOf(vdbe); - CapabilityAssignment capability = capabilities.getCapabilityByName("vdbe0.oam_group.vlan_assignment"); - assertNotNull(capability); - } - - @Test - public void testGetVfGroupsPolicies() { - List<Policy> policies = csarHelperVfGroupsPolicies.getPoliciesOfTopologyTemplate(); - assertNotNull(policies); - List<Group> groups = csarHelperVfGroupsPolicies.getGroupsOfTopologyTemplate(); - assertNotNull(groups); - } - - @Test - public void testGetServiceGroupsPolicies() { - NodeTemplate nt = csarHelperServiceGroupsPolicies.getNodeTemplateByName("vDBE 0"); - List<Policy> policies = csarHelperServiceGroupsPolicies.getPoliciesOfOriginOfNodeTemplate(nt); - assertNotNull(policies); - List<Group> groups = csarHelperServiceGroupsPolicies.getGroupsOfOriginOfNodeTemplate(nt); - assertNotNull(groups); - } - - @Test - public void testGetResourceInputsWithAnnotations() { - List<Input> inputs = csarHelperServiceAnnotations.getServiceInputs(); - assertNotNull(inputs); - assertEquals(inputs.size(), 19); - assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty()); - - inputs = csarHelperServiceAnnotations.getInputsWithAnnotations(); - assertNotNull(inputs); - assertEquals(inputs.size(), 19); - validateInputsAnnotations(inputs); - } - - @Test - public void testGetServiceInputsWithAnnotations() { - List<Input> inputs = csarHelperServiceAdiodAnnotations.getServiceInputs(); - assertNotNull(inputs); - assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty()); - - inputs = csarHelperServiceAdiodAnnotations.getInputsWithAnnotations(); - assertNotNull(inputs); - validateInputsAnnotations(inputs); - } - - @Test - public void getPropertyValueByNamePathAndNodeTypePathWhenPropertyValueIncludesGetInputAndPropertyHasDataType() { - List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("exCP_naming", - "vDBE 0#abstract_vdbe_1#vdbe_vdbe_untr_port"); - assertEquals(0, propertyValues.size()); - } - - @Test - public void getPropertyValueByNamePathAndNodeTypePathWhenPropertyPathIsComplex() { - List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("exCP_naming#ecomp_generated_naming", - "vDBE 0#abstract_vdbe_1#vdbe_vdbe_untr_port"); - assertEquals(1, propertyValues.size()); - assertEquals("true", propertyValues.get(0)); - } - - @Test - public void getPropertyValueByNamePathAndNodeTypePathWhenNoValueFoundForGetInputProperty() { - List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("virtual_machine_interface_allowed_address_pairs#allowed_address_pair#address_mode", - "vDBE 0#abstract_vdbe_1#vdbe_vdbe_untr_port_nested2#vdbe_0_subint_oam_vmi_0"); - assertEquals(0, propertyValues.size()); - } - - @Test - public void getPropertyValueByNamePathAndNodeTemplatePathSuccess() { - List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("is_default", - "vDBE 0#abstract_vdbe_1#vdbe_vdbe_untr_port_nested2#vdbe_0_subint_oam_vmi_0"); - assertEquals(1, propertyValues.size()); - assertEquals("false", propertyValues.get(0)); - } - - @Test - public void getPropertyValueByNamePathAndEmptyNodeTypePath() { - List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath(null, ""); - assertEquals(0, propertyValues.size()); - } - - @Test - public void getPropertyValueByNamePathAndNullNodeTypePath() { - List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath(null, null); - assertTrue(propertyValues.isEmpty()); - } - - @Test - public void getPropertyValueByNamePathAndNodeTypePathForListOfGetInputs() { - List<String> propertyValues = resolveGetInputCsar.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("port_pd01_port_ip_requirements#subnet_role", - "ipAssign4 0#abstract_pd_server"); - assertEquals(2, propertyValues.size()); - assertTrue(propertyValues.get(0).equals("subnet_role_4") || propertyValues.get(0).equals("subnet_role_6")); - assertTrue(propertyValues.get(1).equals("subnet_role_4") || propertyValues.get(1).equals("subnet_role_6")); - } - - @Test - public void getPropertyValueByNamePathAndNodeTypePathForNetworkCloud() { - List<String> propertyValues = csarHelperServiceNetworkCloud.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("related_networks#related_network_role", - "Network Cloud VNF MOCK 0#abstract_testVM#testVM_testVM_SRIOVtrunk1_port"); - assertEquals(3, propertyValues.size()); - assertTrue(propertyValues.contains("cor_direct_2")); - assertTrue(propertyValues.contains("sgi_direct_2")); - assertTrue(propertyValues.contains("int_imbl_2")); - } - - @Test - public void getPropertyValueByNamePathAndSingleNodeTypeNameForNetworkCloud() { - List<String> propertyValues = csarHelperServiceNetworkCloud.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("nf_naming#ecomp_generated_naming", - "Network Cloud VNF MOCK 0"); - assertEquals(1, propertyValues.size()); - assertEquals("true", propertyValues.get(0)); - } - - @Test - //todo test for port_order on resolveGetInputCsar - public void getPropertyValueByNamePathAndNodeTypePathWithGetInputNotSet() { - List<String> propertyValues = csarHelperServiceNetworkCloud.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath( - "name", "Network Cloud VNF MOCK 0#abstract_testVM#testVM"); - assertTrue(propertyValues.isEmpty()); - } - - - @SuppressWarnings("unchecked") - private void validateInputsProperties(NodeTemplate vdbe0, Group group) { - assertNotNull(group.getPropertiesObjects()); - ArrayList<Property> properties = group.getPropertiesObjects(); - - List<String> inputs = properties.stream() - .filter(p -> p.getValue() instanceof Map) - .map(p -> ((Map<String, String>)p.getValue()).get("get_input")) - .collect(Collectors.toList()); - - assertEquals(inputs.size(), 2); - - inputs.forEach(i -> assertTrue(vdbe0.getProperties().containsKey(i))); - - List<Object> list = vdbe0.getProperties().entrySet().stream() - .filter(e -> inputs.contains(e.getKey())) - .map(e -> e.getValue().getValue()) - .collect(Collectors.toList()); - assertEquals(list.size(), 2); - } - - private void validateInputsAnnotations(List<Input> inputs) { - List<Input> inputsWithAnnotations = inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()); - assertTrue(!inputs.isEmpty()); - inputsWithAnnotations.stream().forEach(i -> validateAnnotations(i)); - } - - private void validateAnnotations(Input input) { - assertNotNull(input.getAnnotations()); - assertEquals(input.getAnnotations().size(), 1); - Annotation annotation = input.getAnnotations().get("source"); - assertEquals(annotation.getName(), "source"); - assertEquals(annotation.getType().toLowerCase(), "org.openecomp.annotations.source"); - assertNotNull(annotation.getProperties()); - Optional<Property> source_type = annotation.getProperties() - .stream() - .filter(p->p.getName().equals("source_type")) - .findFirst(); - assertTrue(source_type.isPresent()); - assertEquals(source_type.get().getValue(), "HEAT"); - } - -} - - diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java deleted file mode 100644 index ea5212a..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.Policy; - -import java.net.URL; -import java.util.List; - -import static org.junit.Assert.assertTrue; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -public class ToscaParserPolicyTest { - - private static ISdcCsarHelper helper = null; - - @BeforeClass - public static void setUpClass() { - try { - URL resource = GetEntityPortMirroringTest.class.getClassLoader() - .getResource("csars/service-CgnatFwVnfNc-csar.csar"); - if (resource != null) { - helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile()); - } - - } catch (SdcToscaParserException e) { - e.printStackTrace(); - } - } - - @Test - public void getPolicyOfTargetByNodeTemplate() { - List<NodeTemplate> vfList = helper.getServiceVfList(); - assertEquals(1, vfList.size()); - List<Policy> policies = helper.getPoliciesOfTarget(vfList.get(0)); - assertNotNull(policies); - assertTrue(policies.isEmpty()); - } - - @Test - public void getPolicyTargetFromOrigin() { - List<NodeTemplate> vfList = helper.getServiceVfList(); - assertEquals(1, vfList.size()); - List<NodeTemplate> targets = helper.getPolicyTargetsFromOrigin(vfList.get(0), "cgnatfwvnf_nc..External..0"); - assertNotNull(targets); - assertTrue(targets.isEmpty()); - } - - -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserReqAndCapTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserReqAndCapTest.java deleted file mode 100644 index 7d4aaf3..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserReqAndCapTest.java +++ /dev/null @@ -1,292 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.onap.sdc.tosca.parser.enums.SdcTypes; -import org.onap.sdc.toscaparser.api.CapabilityAssignments; -import org.onap.sdc.toscaparser.api.CapabilityAssignment; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.RequirementAssignments; -import org.testng.annotations.Test; - -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -public class ToscaParserReqAndCapTest extends SdcToscaParserBasicTest { - - //region getCapabilitiesOf - @Test - public void testGetCapabilitiesOfNodeTemplate() { - List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList(); - CapabilityAssignments capabilityAssignments = fdntCsarHelper.getCapabilitiesOf(vfs.get(0)); - assertNotNull(capabilityAssignments); - assertEquals(13, capabilityAssignments.getAll().size()); - assertNotNull(capabilityAssignments.getCapabilityByName("DNT_FW_RHRG.binding_DNT_FW_INT_DNS_TRUSTED_RVMI")); - assertEquals(6, capabilityAssignments.getCapabilitiesByType("tosca.capabilities.network.Bindable").getAll().size()); - } - - @Test - public void testGetCapabilitiesOfNull() { - CapabilityAssignments capabilityAssignments = fdntCsarHelper.getCapabilitiesOf(null); - assertNull(capabilityAssignments); - } - //endregion - - //region getRequirementsOf - @Test - public void testGetRequirementsOfNodeTemplate() { - List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList(); - List<NodeTemplate> cps = fdntCsarHelper.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP); - RequirementAssignments requirementAssignments = fdntCsarHelper.getRequirementsOf(cps.get(0)); - assertNotNull(requirementAssignments); - assertEquals(1, requirementAssignments.getAll().size()); - assertEquals("DNT_FW_RHRG", requirementAssignments.getRequirementsByName("binding").getAll().get(0).getNodeTemplateName()); - } - - @Test - public void testGetRequirementsOfNull() { - RequirementAssignments requirementAssignments = fdntCsarHelper.getRequirementsOf(null); - assertNull(requirementAssignments); - } - //endregion - - //region getCapabilityPropertyLeafValue - @Test - public void testGetCapabilityPropertyLeafValue() { - NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1"); - CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER"); - assertNotNull(capabilityAssignment); - String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "max_instances#type"); - assertEquals("integer", propValue); - } - - @Test - public void testGetCapabilityHierarchyPropertyLeafValue() { - NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1"); - CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.endpoint_DNT_FW_SERVER"); - assertNotNull(capabilityAssignment); - String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "ports#entry_schema#type"); - assertEquals("PortSpec", propValue); - } - - @Test - public void testGetCapabilityDummyPropertyLeafValue() { - NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1"); - CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER"); - assertNotNull(capabilityAssignment); - String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "dummy"); - assertNull(propValue); - } - - @Test - public void testGetCapabilityNullPropertyLeafValue() { - NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1"); - CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER"); - assertNotNull(capabilityAssignment); - String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, null); - assertNull(propValue); - } - - @Test - public void testGetNullCapabilityPropertyLeafValue() { - String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(null, "max_instances#type"); - assertNull(propValue); - } - //endregion - - //QA tests region for US 319197 -port mirroring- - - //get-CapabilitiesOf (All Types) - @Test - public void getServiceNodeTemplateCapabilitiesOfTypeVF() { - List<NodeTemplate> serviceVfList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.VF); - CapabilityAssignments capabilitiesOfVF = QAServiceForToscaParserTests.getCapabilitiesOf(serviceVfList.get(0)); - assertEquals(capabilitiesOfVF.getAll().size(),12); - assertNotNull(capabilitiesOfVF.getCapabilityByName("neutronport0.network.incoming.packets.rate")); - } - - @Test - public void getServiceNodeTemplateCapabilitiesOfTypeExVL() { - List<NodeTemplate> serviceExtVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vl.extVL"); - CapabilityAssignments capabilitiesOfExtVL = QAServiceForToscaParserTests.getCapabilitiesOf(serviceExtVlList.get(0)); - assertEquals(capabilitiesOfExtVL.getAll().size(),2); - assertNotNull(capabilitiesOfExtVL.getCapabilityByName("virtual_linkable").getProperties()); - } - - @Test - public void getServiceNodeTemplateCapabilitiesOfTypeVL() { - List<NodeTemplate> serviceVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("tosca.nodes.network.Network"); - CapabilityAssignments capabilitiesOfVL = QAServiceForToscaParserTests.getCapabilitiesOf(serviceVlList.get(0)); - assertEquals(capabilitiesOfVL.getAll().size(),2); - assertNotNull(capabilitiesOfVL.getCapabilityByName("link").getProperties()); - } - - @Test - public void getServiceNodeTemplateCapabilitiesOfTypeCP() { - List<NodeTemplate> serviceCpList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP); - CapabilityAssignments capabilitiesOfCP = QAServiceForToscaParserTests.getCapabilitiesOf(serviceCpList.get(0)); - assertEquals(capabilitiesOfCP.getAll().size(),2); - assertNotNull(capabilitiesOfCP.getCapabilityByName("internal_connectionPoint")); - } - - @Test - public void getServiceNodeTemplateCapabilitiesOfTypePNF() { - List<NodeTemplate> servicePnfs = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.PNF); - CapabilityAssignments capabilitiesOfPnf = QAServiceForToscaParserTests.getCapabilitiesOf(servicePnfs.get(0)); - assertEquals(capabilitiesOfPnf.getAll().size(),1); - assertNotNull(capabilitiesOfPnf.getCapabilityByName("feature")); - } - - //get-RequirementsOf (All Types)----------------------------- - - @Test - public void getServiceNodeTemplateRequirementsOfTypeVF() { - List<NodeTemplate> serviceVfList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.VF); - RequirementAssignments requirementsOfVF = QAServiceForToscaParserTests.getRequirementsOf(serviceVfList.get(6)); - assertEquals(requirementsOfVF.getAll().size(),3); -// RequirementAssignments requirementsByName = - assertEquals(requirementsOfVF.getRequirementsByName("dependency").getAll().size(),2 ); - //check that API return empty list if requirement property not exist. - assertEquals(requirementsOfVF.getRequirementsByName("blabla").getAll().size(),0); - } - - @Test - public void getServiceNodeTemplateRequirementsOfTypeExVL() { - List<NodeTemplate> serviceExtVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vl.extVL"); - RequirementAssignments requirementsOfExtVL = QAServiceForToscaParserTests.getRequirementsOf(serviceExtVlList.get(0)); - assertEquals(requirementsOfExtVL.getAll().size(),1); - } - - @Test - public void getServiceNodeTemplateRequirementsOfTypeVL() { - List<NodeTemplate> serviceVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("tosca.nodes.network.Network"); - RequirementAssignments requirementsOfVL = QAServiceForToscaParserTests.getRequirementsOf(serviceVlList.get(1)); - assertEquals(requirementsOfVL.getAll().size(),2); - assertNotNull(requirementsOfVL.getRequirementsByName("dependency")); - } - - @Test - public void getServiceNodeTemplateRequirementsOfTypeCP() { - List<NodeTemplate> serviceCpList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP); - RequirementAssignments requirementsOfCP = QAServiceForToscaParserTests.getRequirementsOf(serviceCpList.get(0)); - assertEquals(requirementsOfCP.getAll().size(),2); - assertEquals(requirementsOfCP.getRequirementsByName("virtualBinding").getAll().size(),1); - } - - @Test - public void getServiceNodeTemplateRequirementsOfTypePNF() { - List<NodeTemplate> servicePnfs = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.PNF); - RequirementAssignments requirementsOfPnf = QAServiceForToscaParserTests.getRequirementsOf(servicePnfs.get(0)); - assertEquals(requirementsOfPnf.getAll().size(),2); - assertNotNull(requirementsOfPnf.getRequirementsByName("feature")); - } - - //QA end region for US 319197 -port mirroring - - // Added by QA CapabilityAssignments - @Test - public void testGetCapabilitiesByType() { - List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList(); - CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0)); - assertNotNull(capabilityAssignments); - CapabilityAssignments capabilitiesByType = capabilityAssignments.getCapabilitiesByType("tosca.capabilities.Scalable"); - int capsQty = capabilitiesByType.getAll().size(); - assertEquals(1, capsQty); - CapabilityAssignment capabilityByName = capabilitiesByType.getCapabilityByName("abstract_pd_server.scalable_pd_server"); - assertNotNull(capabilityByName); - } - - @Test - public void testGetCapabilityByName() { - List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList(); - CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0)); - assertNotNull(capabilityAssignments); - CapabilityAssignment capabilityByName = capabilityAssignments.getCapabilityByName("abstract_pd_server.disk.iops_pd_server"); - assertNotNull(capabilityByName); - String capName = capabilityByName.getName(); - assertEquals(capName, "abstract_pd_server.disk.iops_pd_server"); - } - - @Test - public void testGetCapabilitiesGetAll() { - List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList(); - CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0)); - assertNotNull(capabilityAssignments); - int capsAssignmentSize = capabilityAssignments.getAll().size(); - assertEquals(65, capsAssignmentSize); - } - - // Added by QA RequirementsAssignments - @Test - public void testGetRequirementsByName() { - List<NodeTemplate> vfs = resolveReqsCapsCsarQA.getServiceVfList(); - List<NodeTemplate> cps = resolveReqsCapsCsarQA.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP); - RequirementAssignments requirementAssignments = resolveReqsCapsCsarQA.getRequirementsOf(cps.get(0)); - assertNotNull(requirementAssignments); - assertEquals(2, requirementAssignments.getAll().size()); - assertEquals("DNT_FW_RHRG2", requirementAssignments.getRequirementsByName("binding").getAll().get(1).getNodeTemplateName()); - - } - - @Test - public void testRequirementAssignmentGetNodeGetCapability() { - List<NodeTemplate> vfs = resolveReqsCapsCsarQA.getServiceVfList(); - List<NodeTemplate> cps = resolveReqsCapsCsarQA.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP); - RequirementAssignments requirementAssignments = resolveReqsCapsCsarQA.getRequirementsOf(cps.get(0)); - assertNotNull(requirementAssignments); - String nodeTemplateName = requirementAssignments.getAll().get(0).getNodeTemplateName(); - String capabilityName = requirementAssignments.getAll().get(0).getCapabilityName(); - assertEquals(nodeTemplateName, "DNT_FW_RHRG"); - assertNull(capabilityName); - } - - - @Test - public void testRequirementAssignmentGetCapability() { - List<NodeTemplate> cps = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP); - RequirementAssignments requirementAssignments = QAServiceForToscaParserTests.getRequirementsOf(cps.get(0)); - assertNotNull(requirementAssignments); - String nodeTemplateName = requirementAssignments.getAll().get(0).getNodeTemplateName(); - String capabilityName = requirementAssignments.getAll().get(0).getCapabilityName(); - assertEquals(nodeTemplateName, "ExtVL 0"); - assertEquals(capabilityName,"tosca.capabilities.network.Linkable"); - } - - @Test - public void testGetCapabilityProperties() { - List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList(); - List<NodeTemplate> cps = fdntCsarHelper.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP); - CapabilityAssignments capabilityAssignments = cps.get(0).getCapabilities(); - assertNotNull(capabilityAssignments); - assertEquals(12, capabilityAssignments.getAll().size()); - CapabilityAssignment xxxCapability = capabilityAssignments.getCapabilityByName("xxx"); - //GetInput property - resolved in any case - String getInputProp = fdntCsarHelper.getCapabilityPropertyLeafValue(xxxCapability, "DeploymentFlavor"); - assertEquals("{aaa=bbb}", getInputProp); - //Simple property - String simpleProp = fdntCsarHelper.getCapabilityPropertyLeafValue(xxxCapability, "distribution"); - assertEquals("rhel", simpleProp); - } - -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserServiceInputTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserServiceInputTest.java deleted file mode 100644 index d6bbc93..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserServiceInputTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.testng.annotations.Test; -import org.onap.sdc.toscaparser.api.parameters.Input; - -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -public class ToscaParserServiceInputTest extends SdcToscaParserBasicTest { - - //region getServiceInputs - @Test - public void testGetServiceInputs(){ - List<Input> serviceInputs = fdntCsarHelper.getServiceInputs(); - assertNotNull(serviceInputs); - assertEquals(1, serviceInputs.size()); - } - - @Test - public void testServiceInputs() { - List<Input> inputs = rainyCsarHelperSingleVf.getServiceInputs(); - assertNotNull(inputs); - assertEquals(0, inputs.size()); - } - //endregion - - //region getServiceInputLeafValueOfDefault - @Test - public void testGetServiceInputLeafValue(){ - String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default"); - assertEquals("test service naming", serviceInputLeafValue); - } - -// @Test -// public void testGetServiceInputLeafValueWithGetInput(){ -// String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("my_input#default"); -// assertEquals(null, serviceInputLeafValue); -// } - - @Test - public void testGetServiceInputLeafValueNotExists(){ - String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku"); - assertNull(serviceInputLeafValue); - } - - @Test - public void testGetServiceInputLeafValueNull(){ - String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault(null); - assertNull(serviceInputLeafValue); - } - //endregion - - //region getServiceInputLeafValueOfDefaultAsObject - @Test - public void testGetServiceInputLeafValueOfDefaultAsObject() { - Object serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default"); - assertEquals("test service naming", serviceInputLeafValue); - } - - @Test - public void testGetServiceComplexInputLeafValueOfDefault() { - String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("complex_input#default#ipv4_subnet_default_assignment#cidr_mask"); - assertEquals(serviceInputLeafValue, "24"); - } - - @Test - public void testGetServiceDummyComplexInputLeafValueOfDefault() { - String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("complex_input#default#ipv4_subnet_default_assignment#XXX"); - assertNull(serviceInputLeafValue); - } - - - //endregion -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java deleted file mode 100644 index c9ad332..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import java.util.*; - -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.toscaparser.api.CapabilityAssignment; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.RequirementAssignment; -import org.onap.sdc.toscaparser.api.elements.CapabilityTypeDef; -//import org.testng.ReporterConfig.Property; -import org.testng.annotations.Test; -import org.onap.sdc.toscaparser.api.Property; - -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.assertNull; - -public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest { - - //region getServiceSubstitutionMappingsTypeName - @Test - public void testGetServiceSubstitutionMappingsTypeName() { - String serviceSubstitutionMappingsTypeName = fdntCsarHelper.getServiceSubstitutionMappingsTypeName(); - assertEquals("org.openecomp.service.ServiceFdnt", serviceSubstitutionMappingsTypeName); - } - - @Test - public void testServiceSubstitutionMappingsTypeName() { - String substitutionMappingsTypeName = rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName(); - assertNull(substitutionMappingsTypeName); - } - //endregion - - //Added by QA - Check for Capabilities in VF level (Capabilities QTY and Names). - //@Test // - BUG 283369 -// public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException { -// List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); -// String sName = serviceVfList.get(0).getName(); -// assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0)); -// Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll(); -// List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet()); -// List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size()); -// -// for (int i = 0; i < CPkeys.size(); i++) { -// -// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i)); -// -// CapabilitiesNames.add(cCp.getName()); -// -// assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive???? -// -// //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase())); -// //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase())); -// //System.out.println(String.format("*******%d*******",i)); -// } -// -// for (int i = 0; i < CPkeys.size(); i++) { -// assertEquals(true, CapabilitiesNames.stream().map(String::toLowerCase).collect(Collectors.toList()).contains(fdntCsarHelper_Data.get("FDNT").get("capabilities").get(i).toLowerCase())); // Compare capabilities predefined list to actual one. -// } -// -// assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual -// } - - //Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties). - //@Test -// public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException { -// List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); -// String sName = serviceVfList.get(0).getName(); -// assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0)); -// Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll(); -// -// List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet()); -// List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet()); -// List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size()); -// -// //int iKeysSize = keys.size(); //for debug -// -// for (int i = 0; i < CPkeys.size(); i++) { -// -// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i)); -// CapabilityTypeDef CpDef = cCp.getDefinition(); -// CapabilitiesTypes.add(CpDef.getEntityType()); -// -// //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties(); -// LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties(); -// -// List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet()); -// -// for (int j = 0; j < CP_Propkeys.size(); j++) { -// -// Property p = lPropertiesR.get(CP_Propkeys.get(j)); -// -// if(p != null){ -// String sPType = p.getEntityType(); -// Boolean bPRequired = p.isRequired(); -// -// System.out.println(sPType + " " + bPRequired); -// -// } -// -// } -// -// } -// -// for (int i = 0; i < CPkeys.size(); i++) { -// -// } -// -// assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual -// } - - //@Test // - BUG 283387 - public void testRequirmentsofVF() throws SdcToscaParserException { - List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList(); - String sName = serviceVfList.get(0).getName(); - assertEquals(sName,"FDNT 1"); - - List<String> ActualReqsValues = new ArrayList<>(Arrays.asList( )); - - List<RequirementAssignment> lRequirements = serviceVfList.get(0).getRequirements().getAll(); - - assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(),lRequirements.size()); // - - // Continue from here after bug is fixed ! ! ! ! - Test the Requirements values - } - -} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserValidationIssueTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserValidationIssueTest.java deleted file mode 100644 index e74643f..0000000 --- a/src/test/java/org/onap/sdc/impl/ToscaParserValidationIssueTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.impl; - -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.config.ConfigurationManager; -import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.util.List; -import java.util.stream.Collectors; - -import static org.testng.Assert.assertEquals; - -public class ToscaParserValidationIssueTest extends SdcToscaParserBasicTest { - protected static ConfigurationManager configurationManager = ConfigurationManager.getInstance(); - - @BeforeClass - public void loadJtoscaValidationIssueConfiguration() throws IOException { - //load the tests dedicated configuration - configurationManager.setJtoscaValidationIssueConfiguration( "jtosca-validation-issue-configuration-test.yaml"); - factory.setConfigurationManager(configurationManager); - } - - @AfterClass - public void loadJtoscaValidationIssueOriginalConfiguration() throws IOException { - //load the tests dedicated configuration - configurationManager.setJtoscaValidationIssueConfiguration("jtosca-validation-issue-configuration.yaml"); - factory.setConfigurationManager(configurationManager); - - } - - - @Test - public void testNoValidationIssues() throws SdcToscaParserException { - ISdcCsarHelper rainyCsarHelper = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar");//conformance level 3.0 - - //List<JToscaValidationIssue> notAnalyzedReport = factory.getNotAnalyzadExceptions(); - //assertEquals( notAnalyzedReport.size(),0); - List<JToscaValidationIssue> warningsReport = factory.getWarningExceptions(); - assertEquals( warningsReport.size(),0); - List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions(); - assertEquals( criticalsReport.size(),0); - } - @Test - public void testGetLowSinceConformanceLevel() throws SdcToscaParserException { - ISdcCsarHelper fdntCsarHelperWithInputs = getCsarHelper("csars/service-NfodService-csar.csar");//conformance level 3.0 - //Service level - - List<JToscaValidationIssue> notAnalyzedReport = factory.getNotAnalyzadExceptions(); - assertEquals( notAnalyzedReport.size(),10); - //JE003 high CL 4.0 - assertEquals( notAnalyzedReport.stream().filter(n->n.getCode().equals("JE003")).collect(Collectors.toList()).size(), 2); - assertEquals( notAnalyzedReport.stream().filter(n->n.getCode().equals("JE235")).collect(Collectors.toList()).size(), 7); - assertEquals( notAnalyzedReport.stream().filter(n->n.getCode().equals("JE236")).collect(Collectors.toList()).size(), 1); - List<JToscaValidationIssue> warningsReport = factory.getWarningExceptions(); - assertEquals( warningsReport.size(),14); - assertEquals( warningsReport.stream().filter(w->w.getCode().equals("JE006")).collect(Collectors.toList()).size(), 13); - //JE004 low CL 2.0 - assertEquals( warningsReport.stream().filter(w->w.getCode().equals("JE004")).collect(Collectors.toList()).size(), 1); - List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions(); - assertEquals( criticalsReport.size(),0); - } - - @Test(expectedExceptions = SdcToscaParserException.class) - public void testCriticalIssueThrowsSdcToscaParserException() throws SdcToscaParserException { - getCsarHelper("csars/service-Nfod2images-csar.csar");//conformance level 4.0 - } - - @Test - public void testMultiSinceConformanceLevelIssues() { - try { - ISdcCsarHelper Nfod2images = getCsarHelper("csars/service-Nfod2images-csar.csar");//conformance level 4.0 - } catch (SdcToscaParserException e) { - System.out.println("SdcToscaParserException is caught here - this is WAD in this specific test."); - } - List<JToscaValidationIssue> notAnalyzedReport = factory.getNotAnalyzadExceptions(); - assertEquals(3, notAnalyzedReport.size()); - List<JToscaValidationIssue> warningsReport = factory.getWarningExceptions(); - assertEquals( 0, warningsReport.size()); - List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions(); - assertEquals( 22, criticalsReport.size()); - //JE006 multy values sinceCsarConformanceLevel - assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE006")).collect - (Collectors.toList()).size(), 18); - assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE003")).collect - (Collectors.toList()).size(), 4); - } - - -} diff --git a/src/test/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactoryTest.java b/src/test/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactoryTest.java deleted file mode 100644 index f33e1a7..0000000 --- a/src/test/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactoryTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.tosca.parser.elements; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.sdc.tosca.parser.enums.EntityTemplateType; -import org.onap.sdc.toscaparser.api.Group; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.Policy; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class EntityDetailsFactoryTest { - - @Mock - private NodeTemplate nodeTemplate; - - @Mock - private Group group; - - @Mock - private Policy policy; - - - @Test - public void createNodeTemplateEntityDetailsWhenParentNodeIsNotNull() { - when(nodeTemplate.getParentNodeTemplate()) - .thenReturn(nodeTemplate) - .thenReturn(null); - EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, nodeTemplate); - assertTrue(entityDetails instanceof NodeTemplateEntityDetails); - assertTrue(entityDetails.getParent() instanceof NodeTemplateEntityDetails); - } - - @Test - public void createNodeTemplateEntityDetailsWhenParentNodeIsNull() { - EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, nodeTemplate); - assertTrue(entityDetails instanceof NodeTemplateEntityDetails); - assertEquals(null, entityDetails.getParent()); - } - - @Test - public void createNodeTemplateEntityDetailsWhenNnIsNull() { - assertEquals(null, EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, null)); - } - - @Test - public void createGroupEntityDetailsWhenParentNodeIsNotNull() { - when(group.getParentNodeTemplate()) - .thenReturn(nodeTemplate) - .thenReturn(null); - EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.GROUP, group); - assertTrue(entityDetails instanceof GroupEntityDetails); - assertTrue(entityDetails.getParent() instanceof NodeTemplateEntityDetails); - } - - @Test - public void createGroupEntityDetailsWhenParentNodeIsNull() { - EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.GROUP, group); - assertTrue(entityDetails instanceof GroupEntityDetails); - assertEquals(null, entityDetails.getParent()); - } - - @Test - public void createGroupEntityDetailsWhenNnIsNull() { - assertEquals(null, EntityDetailsFactory.createEntityDetails(EntityTemplateType.GROUP, null)); - } - - @Test - public void createPolicyEntityDetailsWhenParentNodeIsNotNull() { - when(policy.getParentNodeTemplate()) - .thenReturn(nodeTemplate) - .thenReturn(null); - EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, policy); - assertTrue(entityDetails instanceof PolicyEntityDetails); - assertTrue(entityDetails.getParent() instanceof NodeTemplateEntityDetails); - } - - @Test - public void createPolicyEntityDetailsWhenParentNodeIsNull() { - EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, policy); - assertTrue(entityDetails instanceof PolicyEntityDetails); - assertEquals(null, entityDetails.getParent()); - } - - @Test - public void createPolicyEntityDetailsWhenNnIsNull() { - assertEquals(null, EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, null)); - } - - @Test(expected = ClassCastException.class) - public void createWrongEntityDetails() { - EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, group); - } - - - @Test - public void createEntityDetailsWhenTypeIsNull() { - assertEquals(null, EntityDetailsFactory.createEntityDetails(null, group)); - } - -} diff --git a/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java b/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java deleted file mode 100644 index a9af7d9..0000000 --- a/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.tosca.parser.elements.queries; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.sdc.tosca.parser.enums.EntityTemplateType; -import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; -import org.onap.sdc.toscaparser.api.elements.Metadata; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class EntityQueryTest { - @Mock - private Metadata metadata; - - @Test - public void findEntityWhenUuidAndCuudNotSetAndToscaTypeNotSet() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("12345"); - assertTrue(entityQuery.isSearchCriteriaMatched(metadata, "")); - } - - @Test - public void findEntityWhenMetadataIsNull() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .build(); - assertFalse(entityQuery.isSearchCriteriaMatched(null,"abc")); - } - - @Test - public void findEntityWhenMetadataIsNullAndUuidsAreProvided() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE) - .customizationUUID("2345") - .uUID("9700") - .build(); - assertFalse(entityQuery.isSearchCriteriaMatched(null, "")); - } - - @Test - public void findEntityWhenUuidIsSetAndMatchedAndToscaTypeNotSet() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .uUID("123") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("12345"); - - assertTrue(entityQuery.isSearchCriteriaMatched(metadata, "abc")); - } - - @Test - public void findEntityWhenUuidIsSetAndMatchedAndCuuidIsNullAndToscaTypeNotSet() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .uUID("123") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn(null); - - assertTrue(entityQuery.isSearchCriteriaMatched(metadata, "")); - } - - @Test - public void findEntityWhenUuidAndCuuidAreSetAndMatchedAndCuuidIsNullAndToscaTypeNotSet() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .uUID("123") - .customizationUUID("567") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn(null); - - assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "")); - } - - - @Test - public void findEntityWhenUIDsAreSetAndMatchedAndToscaTypeNotSet() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY) - .uUID("123") - .customizationUUID("345") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("345"); - - assertTrue(entityQuery.isSearchCriteriaMatched(metadata, "qwe")); - } - - @Test - public void findEntityWhenUIDsAreSetAndMatchedPartiallyAndToscaTypeNotSet() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY) - .uUID("123") - .customizationUUID("345") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("444"); - - assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "")); - } - - @Test - public void findEntityWhenUuidIsSetAndDoesNotMatchAndToscaTypeNotSet() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP) - .uUID("7890") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("12345"); - - assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "")); - } - - @Test - public void findEntityWhenUIDsAreSetAndMatchedAndToscaTypeIsNull() { - EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY) - .uUID("123") - .customizationUUID("345") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("345"); - - assertTrue(entityQuery.isSearchCriteriaMatched(metadata, null)); - } - - @Test - public void findEntityWhenUIDsAreSetAndMatchedAndToscaTypeIsNotMatched() { - EntityQuery entityQuery = EntityQuery.newBuilder("a.policies.b") - .uUID("123") - .customizationUUID("345") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("345"); - - assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "abc")); - } - - @Test - public void findEntityWhenUIDsAreSetAndMatchedAndToscaTypeIsMatched() { - EntityQuery entityQuery = EntityQuery.newBuilder("a.groups.b") - .uUID("123") - .customizationUUID("345") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("345"); - - assertTrue(entityQuery.isSearchCriteriaMatched(metadata, "a.groups.b")); - } - - @Test - public void findEntityWhenUIDsAreNotMatchedAndToscaTypeIsMatched() { - EntityQuery entityQuery = EntityQuery.newBuilder("a.groups.b") - .uUID("123") - .customizationUUID("345") - .build(); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("12345"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("3456"); - - assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "a.groups.b")); - } -} diff --git a/src/test/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQueryTest.java b/src/test/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQueryTest.java deleted file mode 100644 index 68c4329..0000000 --- a/src/test/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQueryTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.tosca.parser.elements.queries; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.sdc.tosca.parser.enums.SdcTypes; -import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.elements.Metadata; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; -import static org.testng.Assert.assertFalse; - -@RunWith(MockitoJUnitRunner.class) -public class TopologyTemplateQueryTest { - - @Mock - private Metadata metadata; - - @Mock - private NodeTemplate nodeTemplate; - - @Test(expected=IllegalArgumentException.class) - public void objectIsNotTopologyTemplate() { - TopologyTemplateQuery.newBuilder(SdcTypes.CP) - .build(); - } - - @Test - public void templateIsFoundByTypeOnly() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345"); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.SERVICE.getValue()); - assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - @Test - public void templateIsNotFoundWhenMetadataIsNull() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF) - .build(); - when(nodeTemplate.getMetaData()).thenReturn(null); - assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - @Test - public void templateIsFoundIfItIsService() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) - .build(); - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.SERVICE.getValue()); - assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - @Test - public void templateIsFoundByTypeAndCUUID() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .customizationUUID("345") - .build(); - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.CVFC.getValue()); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345"); - assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - @Test - public void templateIsNotFoundWhenTypeIsNotMatchedAndCuuidIsNotSet() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .build(); - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.VF.getValue()); - assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - @Test - public void templateIsFoundWhenTypeIsMatchedCuuidIsProvidedAndCuuidIsNullInMetadata() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF) - .customizationUUID("2345") - .build(); - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn(null); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.VF.getValue()); - assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - @Test - public void templateIsFoundWhenTypeIsMatchedAndCuuidIsNullInMetadata() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF) - .build(); - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn(null); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.VF.getValue()); - assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - @Test - public void templateIsNotFoundWhenTypeIsMatchedAndCuuidIsSet() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC) - .customizationUUID("345") - .build(); - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.CVFC.getValue()); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345"); - assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - @Test - public void templateIsNotFoundWhenTypeIsNotMatchedAndCuuidIsSet() { - TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CR) - .customizationUUID("345") - .build(); - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.CVFC.getValue()); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345"); - assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate)); - } - - -} diff --git a/src/test/java/org/onap/sdc/tosca/parser/impl/ToscaParserNodeTemplateMockTest.java b/src/test/java/org/onap/sdc/tosca/parser/impl/ToscaParserNodeTemplateMockTest.java deleted file mode 100644 index 76b1735..0000000 --- a/src/test/java/org/onap/sdc/tosca/parser/impl/ToscaParserNodeTemplateMockTest.java +++ /dev/null @@ -1,217 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-tosca - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.tosca.parser.impl; - -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.enums.PropertySchemaType; -import org.onap.sdc.tosca.parser.utils.PropertyUtils; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.Property; -import org.onap.sdc.toscaparser.api.ToscaTemplate; -import org.onap.sdc.toscaparser.api.elements.Metadata; - -import java.util.LinkedHashMap; -import java.util.NoSuchElementException; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; -import static org.testng.Assert.assertFalse; - -@RunWith(MockitoJUnitRunner.class) -public class ToscaParserNodeTemplateMockTest { - @Mock - private NodeTemplate nodeTemplate; - - @Mock - private Metadata metadata; - - @Mock - private ToscaTemplate toscaTemplate; - - @Mock - private Property property; - - private static final String dataTypeA = String.format(".%s.aaa", PropertySchemaType.DATATYPE.getSchemaTypeName()); - private static final String dataTypeB = String.format(".%s.bbb", PropertySchemaType.DATATYPE.getSchemaTypeName()); - private static final String dataTypeD = String.format(".%s.ddd", PropertySchemaType.DATATYPE.getSchemaTypeName()); - private static final String dataTypeR = String.format(".%s.rrr", PropertySchemaType.DATATYPE.getSchemaTypeName()); - - @Before - public void setUp() { - when(property.getType()).thenReturn(dataTypeA); - } - - - @Test - public void verifyCorrectPropertyPath() { - String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#"); - LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB); - LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", dataTypeD); - LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "q", PropertySchemaType.STRING.getSchemaTypeName()); - - when(nodeTemplate.getCustomDef()) - .thenReturn(bProp) - .thenReturn(cProp) - .thenReturn(dProp); - - assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property)); - } - - @Test - public void verifyPropertyPathWithMapOfStringsType() { - String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#"); - LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB); - LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.MAP.getSchemaTypeName()); - LinkedHashMap<String, Object> dProp = fillDataTypeEntry(PropertySchemaType.MAP.getSchemaTypeName(), "q", PropertySchemaType.STRING.getSchemaTypeName()); - - when(nodeTemplate.getCustomDef()) - .thenReturn(bProp) - .thenReturn(cProp) - .thenReturn(dProp); - - assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property)); - } - - @Test - public void verifyPropertyPathWithMapType() { - String[] path = String.format("%s#%s#%s", "x", "y", "z").split("#"); - LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB); - LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.MAP.getSchemaTypeName()); - - when(nodeTemplate.getCustomDef()) - .thenReturn(bProp) - .thenReturn(cProp); - - assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property)); - } - - - @Test - public void verifyPropertyPathWithListOfDataTypeShouldBeRejected() { - String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "m").split("#"); - LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB); - LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", dataTypeD); - LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(), dataTypeR); - - when(nodeTemplate.getCustomDef()) - .thenReturn(bProp) - .thenReturn(cProp) - .thenReturn(dProp); - - assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property)); - } - - @Test - public void verifyPropertyPathWithListOfIntegersAsType() { - String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "m").split("#"); - LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB); - LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", dataTypeD); - LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(), PropertySchemaType.INTEGER.getSchemaTypeName()); - - when(nodeTemplate.getCustomDef()) - .thenReturn(bProp) - .thenReturn(cProp) - .thenReturn(dProp); - - assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property)); - } - - @Test - public void propertyPathIsRejectedAsShorterThanExpected() { - String[] path = String.format("%s#%s", "x", "y").split("#"); - LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB); - LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.STRING.getSchemaTypeName()); - - when(nodeTemplate.getCustomDef()) - .thenReturn(bProp) - .thenReturn(dProp); - - assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property)); - } - - @Test(expected = NoSuchElementException.class) - public void propertyPathIsRejectedAsLongerThanExpected() { - String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#"); - LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB); - LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.STRING.getSchemaTypeName()); - - when(nodeTemplate.getCustomDef()) - .thenReturn(bProp) - .thenReturn(dProp); - - PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property); - } - - @Test(expected = NoSuchElementException.class) - public void propertyPathIsRejectedAsPropertyIsNotFound() { - String[] path = String.format("%s#%s", "x", "y").split("#"); - LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "t", dataTypeB); - when(nodeTemplate.getCustomDef()) - .thenReturn(bProp); - - assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property)); - } - - @Test - public void verifyNodeTypeIsNotSupported() { - when(nodeTemplate.getMetaData()).thenReturn(metadata); - when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn("VFC-TEST"); - - ISdcCsarHelper sdcCsarHelper = new SdcCsarHelperImpl(toscaTemplate); - assertFalse(sdcCsarHelper.isNodeTypeSupported(nodeTemplate)); - } - - - private LinkedHashMap<String, Object> fillDataTypeEntry(String dataTypeName, String propertyName, String type) { - return fillDataTypeEntry(dataTypeName, propertyName, type, ""); - } - - private LinkedHashMap<String, Object> fillDataTypeEntry(String dataTypeName, String propertyName, String type, String entrySchemaType) { - LinkedHashMap<String, Object> dataTypes = new LinkedHashMap<>(); - LinkedHashMap<String, Object> properties = new LinkedHashMap<>(); - LinkedHashMap<String, Object> property = new LinkedHashMap<>(); - LinkedHashMap<String, Object> dataType = new LinkedHashMap<>(); - property.put(SdcPropertyNames.PROPERTY_NAME_TYPE, type); - property.put(SdcPropertyNames.PROPERTY_NAME_NAME, propertyName); - - PropertySchemaType propertySchemaType = PropertySchemaType.getEnumByValue(type); - - if (!StringUtils.isEmpty(entrySchemaType) && - (propertySchemaType.getSchemaTypeComplexity() == PropertySchemaType.PropertySchemaComplexity.Complex)) { - LinkedHashMap<String, Object> entry_schema = new LinkedHashMap<>(); - entry_schema.put(SdcPropertyNames.PROPERTY_NAME_TYPE, entrySchemaType); - property.put(SdcPropertyNames.PROPERTY_NAME_ENTRY_SCHEMA, entry_schema); - } - properties.put(propertyName, property); - dataType.put(SdcPropertyNames.PROPERTY_NAME_PROPERTIES, properties); - dataTypes.put(dataTypeName, dataType); - return dataTypes; - } - - - -} diff --git a/src/test/resources/config/configuration.yaml b/src/test/resources/config/configuration.yaml deleted file mode 100644 index f070c1d..0000000 --- a/src/test/resources/config/configuration.yaml +++ /dev/null @@ -1,3 +0,0 @@ -conformanceLevel: - minVersion: '3.0' - maxVersion: '7.0'
\ No newline at end of file diff --git a/src/test/resources/config/error-configuration-test.yaml b/src/test/resources/config/error-configuration-test.yaml deleted file mode 100644 index de603c6..0000000 --- a/src/test/resources/config/error-configuration-test.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# Errors -errors: - FILE_NOT_FOUND: { - code: TP0001, - failOnError: true, - message: "Error: CSAR file not found." - } - BAD_FORMAT: { - code: TP0002, - failOnError: true, - message: "Error: CSAR file bad format. Check the log for details." - } - CONFORMANCE_LEVEL_ERROR: { - code: TP0003, - failOnError: false, - message: "Error: CSAR version is unsupported. Parser supports versions from %s." - } - GENERAL_ERROR: { - code: TP0004, - failOnError: true, - message: "Error: an unexpected internal error occured." - }
\ No newline at end of file diff --git a/src/test/resources/config/error-configuration.yaml b/src/test/resources/config/error-configuration.yaml deleted file mode 100644 index 296c681..0000000 --- a/src/test/resources/config/error-configuration.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# Errors -errors: - FILE_NOT_FOUND: { - code: TP0001, - failOnError: true, - message: "Error: CSAR file not found." - } - BAD_FORMAT: { - code: TP0002, - failOnError: true, - message: "Error: CSAR file bad format. Check the log for details." - } - CONFORMANCE_LEVEL_ERROR: { - code: TP0003, - failOnError: true, - message: "Error: CSAR version is unsupported. Parser supports versions from %s." - } - GENERAL_ERROR: { - code: TP0004, - failOnError: true, - message: "Error: an unexpected internal error occured." - }
\ No newline at end of file diff --git a/src/test/resources/config/jtosca-validation-issue-configuration-test.yaml b/src/test/resources/config/jtosca-validation-issue-configuration-test.yaml deleted file mode 100644 index 1378ca7..0000000 --- a/src/test/resources/config/jtosca-validation-issue-configuration-test.yaml +++ /dev/null @@ -1,57 +0,0 @@ -# jTosca validation issues -#by error code, type the validation issue to be CRITICAL/WARNING -# since Conformance level considered to this type. for example: -#JE001: -# - type: WARNING, -# sinceCsarConformanceLevel: 3.0 -# - type: WARNING, -# sinceCsarConformanceLevel: 5.0 -validationIssues: - # TypeMismatchError - JE001: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - - issueType: CRITICAL - sinceCsarConformanceLevel: 4.0 - - issueType: WARNING - sinceCsarConformanceLevel: 5.0 - # MissingType - JE002: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #MissingRequiredFieldError - JE003: - - issueType: CRITICAL - sinceCsarConformanceLevel: 4.0 - #MissingRequiredFieldError2 - JE004: - - issueType: WARNING - sinceCsarConformanceLevel: 2.0 - #InvalidGroupTargetException - JE005: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #Schema definition of \"%s\" has \"status\" attribute with an invalid value - JE006: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - - issueType: CRITICAL - sinceCsarConformanceLevel: 4.0 - - issueType: WARNING - sinceCsarConformanceLevel: 5.0 - #The unit \"%s\" is not valid - JE007: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #ValidationError - JE008: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #ValueError: Expected max 2 arguments for function \"get_input\" but received \"%s\"",args.size()) - JE009: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #MissingRequiredFieldError3 - JE010: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0
\ No newline at end of file diff --git a/src/test/resources/config/jtosca-validation-issue-configuration.yaml b/src/test/resources/config/jtosca-validation-issue-configuration.yaml deleted file mode 100644 index 3f62953..0000000 --- a/src/test/resources/config/jtosca-validation-issue-configuration.yaml +++ /dev/null @@ -1,57 +0,0 @@ -# jTosca validation issues -#by error code, type the validation issue to be CRITICAL/WARNING -# since Conformance level considered to this type. for example: -#JE001: -# - issueType: WARNING -# sinceCsarConformanceLevel: 3.0 -# - issueType: WARNING -# sinceCsarConformanceLevel: 5.0 -validationIssues: - # TypeMismatchError - JE001: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - # MissingType - JE002: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #MissingRequiredFieldError - JE003: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #MissingRequiredFieldError2 - JE004: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #InvalidGroupTargetException - JE005: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #Schema definition of \"%s\" has \"status\" attribute with an invalid value - JE006: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #The unit \"%s\" is not valid - JE007: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #ValidationError - JE008: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #ValueError: Expected max 2 arguments for function \"get_input\" but received \"%s\"",args.size()) - JE009: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #MissingRequiredFieldError3 - JE010: - - issueType: WARNING - sinceCsarConformanceLevel: 3.0 - #InvalidTypeError - JE136: - - issueType: CRITICAL - sinceCsarConformanceLevel: 3.0 - #Exception from SnakeYAML - JE198: - - issueType: CRITICAL - sinceCsarConformanceLevel: 3.0
\ No newline at end of file diff --git a/src/test/resources/csars/csar-invalid-zip.zip b/src/test/resources/csars/csar-invalid-zip.zip deleted file mode 100644 index 04de055..0000000 --- a/src/test/resources/csars/csar-invalid-zip.zip +++ /dev/null @@ -1,2 +0,0 @@ -SDC-TOSCA-Meta-File-Version: 1.0 -SDC-TOSCA-Definitions-Version: 2.0 diff --git a/src/test/resources/csars/dataTypes-test-service.csar b/src/test/resources/csars/dataTypes-test-service.csar Binary files differdeleted file mode 100644 index b4de177..0000000 --- a/src/test/resources/csars/dataTypes-test-service.csar +++ /dev/null diff --git a/src/test/resources/csars/resource-Policy-csar.csar b/src/test/resources/csars/resource-Policy-csar.csar Binary files differdeleted file mode 100644 index 67cc528..0000000 --- a/src/test/resources/csars/resource-Policy-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/resource-Sirovinputannotation-csar.csar b/src/test/resources/csars/resource-Sirovinputannotation-csar.csar Binary files differdeleted file mode 100644 index 984e052..0000000 --- a/src/test/resources/csars/resource-Sirovinputannotation-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/resource-Vdbe-csar.csar b/src/test/resources/csars/resource-Vdbe-csar.csar Binary files differdeleted file mode 100644 index 0705852..0000000 --- a/src/test/resources/csars/resource-Vdbe-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-AdiodVmxVpeBvService-csar.csar b/src/test/resources/csars/service-AdiodVmxVpeBvService-csar.csar Binary files differdeleted file mode 100644 index 28aa6f4..0000000 --- a/src/test/resources/csars/service-AdiodVmxVpeBvService-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-AlService-csar.csar b/src/test/resources/csars/service-AlService-csar.csar Binary files differdeleted file mode 100644 index 653b80d..0000000 --- a/src/test/resources/csars/service-AlService-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar b/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar Binary files differdeleted file mode 100644 index 60c2589..0000000 --- a/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-CrTestService-csar.csar b/src/test/resources/csars/service-CrTestService-csar.csar Binary files differdeleted file mode 100644 index 445fd2b..0000000 --- a/src/test/resources/csars/service-CrTestService-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-CxSvc-csar.csar b/src/test/resources/csars/service-CxSvc-csar.csar Binary files differdeleted file mode 100644 index ad77cc4..0000000 --- a/src/test/resources/csars/service-CxSvc-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-Groupstest-csar.csar b/src/test/resources/csars/service-Groupstest-csar.csar Binary files differdeleted file mode 100644 index 1d48da0..0000000 --- a/src/test/resources/csars/service-Groupstest-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-Ipassignservice-csar.csar b/src/test/resources/csars/service-Ipassignservice-csar.csar Binary files differdeleted file mode 100644 index 007b96a..0000000 --- a/src/test/resources/csars/service-Ipassignservice-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar b/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar Binary files differdeleted file mode 100644 index 7e8ebb3..0000000 --- a/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar b/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar Binary files differdeleted file mode 100644 index be550f9..0000000 --- a/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-NetworkCloudVnfServiceMock-csar.csar b/src/test/resources/csars/service-NetworkCloudVnfServiceMock-csar.csar Binary files differdeleted file mode 100644 index aabf83c..0000000 --- a/src/test/resources/csars/service-NetworkCloudVnfServiceMock-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-Nfod2images-csar.csar b/src/test/resources/csars/service-Nfod2images-csar.csar Binary files differdeleted file mode 100644 index c735033..0000000 --- a/src/test/resources/csars/service-Nfod2images-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-NfodService-csar.csar b/src/test/resources/csars/service-NfodService-csar.csar Binary files differdeleted file mode 100644 index 329076a..0000000 --- a/src/test/resources/csars/service-NfodService-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-Oren1-csar-4.csar b/src/test/resources/csars/service-Oren1-csar-4.csar Binary files differdeleted file mode 100644 index 1e1f738..0000000 --- a/src/test/resources/csars/service-Oren1-csar-4.csar +++ /dev/null diff --git a/src/test/resources/csars/service-PortMirroring.csar b/src/test/resources/csars/service-PortMirroring.csar Binary files differdeleted file mode 100644 index c3a44a0..0000000 --- a/src/test/resources/csars/service-PortMirroring.csar +++ /dev/null diff --git a/src/test/resources/csars/service-ServiceFdnt-csar-no-vf.csar b/src/test/resources/csars/service-ServiceFdnt-csar-no-vf.csar Binary files differdeleted file mode 100644 index c35baf5..0000000 --- a/src/test/resources/csars/service-ServiceFdnt-csar-no-vf.csar +++ /dev/null diff --git a/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar b/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar Binary files differdeleted file mode 100644 index f3b3a46..0000000 --- a/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar +++ /dev/null diff --git a/src/test/resources/csars/service-ServiceFdnt-csar.csar b/src/test/resources/csars/service-ServiceFdnt-csar.csar Binary files differdeleted file mode 100644 index 983dc9b..0000000 --- a/src/test/resources/csars/service-ServiceFdnt-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-ServiceFdnt-test-csar.csar b/src/test/resources/csars/service-ServiceFdnt-test-csar.csar Binary files differdeleted file mode 100644 index 5a364cd..0000000 --- a/src/test/resources/csars/service-ServiceFdnt-test-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar b/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar Binary files differdeleted file mode 100644 index c5a277b..0000000 --- a/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar +++ /dev/null diff --git a/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar b/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar Binary files differdeleted file mode 100644 index 9afc278..0000000 --- a/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-Servicetosca9-csar.csar b/src/test/resources/csars/service-Servicetosca9-csar.csar Binary files differdeleted file mode 100644 index 0627cfc..0000000 --- a/src/test/resources/csars/service-Servicetosca9-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-VdbePx-csar.csar b/src/test/resources/csars/service-VdbePx-csar.csar Binary files differdeleted file mode 100644 index 3032768..0000000 --- a/src/test/resources/csars/service-VdbePx-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-VdbeSrv-csar.csar b/src/test/resources/csars/service-VdbeSrv-csar.csar Binary files differdeleted file mode 100644 index f911753..0000000 --- a/src/test/resources/csars/service-VdbeSrv-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-VlanD2dSrv-csar.csar b/src/test/resources/csars/service-VlanD2dSrv-csar.csar Binary files differdeleted file mode 100644 index efec4c0..0000000 --- a/src/test/resources/csars/service-VlanD2dSrv-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-consolidated-props-csar.csar b/src/test/resources/csars/service-consolidated-props-csar.csar Binary files differdeleted file mode 100644 index 4a3fde6..0000000 --- a/src/test/resources/csars/service-consolidated-props-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-entry-definition-not-defined.csar b/src/test/resources/csars/service-entry-definition-not-defined.csar Binary files differdeleted file mode 100644 index 47e65b6..0000000 --- a/src/test/resources/csars/service-entry-definition-not-defined.csar +++ /dev/null diff --git a/src/test/resources/csars/service-invalid-conformence-level.csar b/src/test/resources/csars/service-invalid-conformence-level.csar Binary files differdeleted file mode 100644 index 12621f0..0000000 --- a/src/test/resources/csars/service-invalid-conformence-level.csar +++ /dev/null diff --git a/src/test/resources/csars/service-invalid-input-args.csar b/src/test/resources/csars/service-invalid-input-args.csar Binary files differdeleted file mode 100644 index 38a670f..0000000 --- a/src/test/resources/csars/service-invalid-input-args.csar +++ /dev/null diff --git a/src/test/resources/csars/service-invalid-yaml-content-meta.csar b/src/test/resources/csars/service-invalid-yaml-content-meta.csar Binary files differdeleted file mode 100644 index f77af6f..0000000 --- a/src/test/resources/csars/service-invalid-yaml-content-meta.csar +++ /dev/null diff --git a/src/test/resources/csars/service-max-conformence-level.csar b/src/test/resources/csars/service-max-conformence-level.csar Binary files differdeleted file mode 100644 index 0cbb872..0000000 --- a/src/test/resources/csars/service-max-conformence-level.csar +++ /dev/null diff --git a/src/test/resources/csars/service-missing-csar-meta-file.csar b/src/test/resources/csars/service-missing-csar-meta-file.csar Binary files differdeleted file mode 100644 index 7c75314..0000000 --- a/src/test/resources/csars/service-missing-csar-meta-file.csar +++ /dev/null diff --git a/src/test/resources/csars/service-missing-entry-definition.csar b/src/test/resources/csars/service-missing-entry-definition.csar Binary files differdeleted file mode 100644 index 8fd1962..0000000 --- a/src/test/resources/csars/service-missing-entry-definition.csar +++ /dev/null diff --git a/src/test/resources/csars/service-missing-meta-file.csar b/src/test/resources/csars/service-missing-meta-file.csar Binary files differdeleted file mode 100644 index 79348db..0000000 --- a/src/test/resources/csars/service-missing-meta-file.csar +++ /dev/null diff --git a/src/test/resources/csars/service-nested-vfc-csar.csar b/src/test/resources/csars/service-nested-vfc-csar.csar Binary files differdeleted file mode 100644 index 5ee0802..0000000 --- a/src/test/resources/csars/service-nested-vfc-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-resolve-get-input-csar.csar b/src/test/resources/csars/service-resolve-get-input-csar.csar Binary files differdeleted file mode 100644 index d793229..0000000 --- a/src/test/resources/csars/service-resolve-get-input-csar.csar +++ /dev/null diff --git a/src/test/resources/csars/service-resolve-get-input-csar_QA.csar b/src/test/resources/csars/service-resolve-get-input-csar_QA.csar Binary files differdeleted file mode 100644 index a290ff1..0000000 --- a/src/test/resources/csars/service-resolve-get-input-csar_QA.csar +++ /dev/null diff --git a/src/test/resources/csars/service-sunny-flow.csar b/src/test/resources/csars/service-sunny-flow.csar Binary files differdeleted file mode 100644 index 92ae19d..0000000 --- a/src/test/resources/csars/service-sunny-flow.csar +++ /dev/null diff --git a/src/test/resources/csars/service-sunny-flow2.csar b/src/test/resources/csars/service-sunny-flow2.csar Binary files differdeleted file mode 100644 index 0a8af02..0000000 --- a/src/test/resources/csars/service-sunny-flow2.csar +++ /dev/null diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties deleted file mode 100644 index c18c3da..0000000 --- a/src/test/resources/log4j.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Root logger option -log4j.rootLogger=info, stdout - -# Direct log messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n |