diff options
Diffstat (limited to 'sdc-tosca/src/test/java/org/onap/sdc/impl/GetForwardingPathTest.java')
-rw-r--r-- | sdc-tosca/src/test/java/org/onap/sdc/impl/GetForwardingPathTest.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sdc-tosca/src/test/java/org/onap/sdc/impl/GetForwardingPathTest.java b/sdc-tosca/src/test/java/org/onap/sdc/impl/GetForwardingPathTest.java new file mode 100644 index 0000000..6c910e6 --- /dev/null +++ b/sdc-tosca/src/test/java/org/onap/sdc/impl/GetForwardingPathTest.java @@ -0,0 +1,66 @@ +/*- + * ============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.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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URL; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GetForwardingPathTest { + private ISdcCsarHelper helper; + private static Logger log = LoggerFactory.getLogger(GetForwardingPathTest.class.getName()); + + public void setUp(String path) { + try { + URL resource = GetEntityTest.class.getClassLoader().getResource(path); + if (resource != null) { + helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile()); + } + + } catch (SdcToscaParserException e) { + log.error("Failed to create ISdcCsarHelper object from {}.", path, e); + } + } + + @Test + public void fpTest(){ + setUp("csars/service-Servicefp1-csar.csar"); + + EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.nodes.ForwardingPath") + .build(); + TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) + .build(); + + List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false); + assertThat(entities.size()).isEqualTo(1); + } +} |