X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tapi%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Ftapi%2Futils%2FTopologyDataUtils.java;h=dbc82005c03b57d5dc951d0681852c1bdb7bb386;hb=b6ad4ae8cec0ad9e3fa35b1e6e3153f045a97bf1;hp=90c857999e750d330c92426357cdb54d638575a1;hpb=04b9194abd5955a6ce7334a25ee55aa18ed2e776;p=transportpce.git diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/utils/TopologyDataUtils.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/utils/TopologyDataUtils.java index 90c857999..dbc82005c 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/utils/TopologyDataUtils.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/utils/TopologyDataUtils.java @@ -16,9 +16,9 @@ import java.util.Optional; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.WriteTransaction; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.transportpce.common.DataStoreContext; -import org.opendaylight.transportpce.common.converter.XMLDataObjectConverter; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.Network; +import org.opendaylight.transportpce.test.DataStoreContext; +import org.opendaylight.transportpce.test.converter.XMLDataObjectConverter; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.Network; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsInput; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsInputBuilder; @@ -31,20 +31,20 @@ import org.slf4j.LoggerFactory; public final class TopologyDataUtils { private static final Logger LOG = LoggerFactory.getLogger(TopologyDataUtils.class); - private static final String TOPOLOGY_FILE = - "src/test/resources/openroadm-topology2.xml"; - private static final String PORTMAPPING_FILE = - "src/test/resources/portmapping-example.xml"; + public static final String OPENROADM_TOPOLOGY_FILE = "src/test/resources/openroadm-topology2.xml"; + public static final String OTN_TOPOLOGY_FILE = "src/test/resources/otn-topology.xml"; + public static final String PORTMAPPING_FILE = "src/test/resources/portmapping-example.xml"; - public static GetTopologyDetailsInput buildGetTopologyDetailsInput() { + public static GetTopologyDetailsInput buildGetTopologyDetailsInput(String topoName) { GetTopologyDetailsInputBuilder builtInput = new GetTopologyDetailsInputBuilder(); - builtInput.setTopologyIdOrName("topo1"); + builtInput.setTopologyIdOrName(topoName); return builtInput.build(); } - public static void writeTopologyFromFileToDatastore(DataStoreContext dataStoreContextUtil) { - Networks result = null; - File topoFile = new File(TOPOLOGY_FILE); + public static void writeTopologyFromFileToDatastore(DataStoreContext dataStoreContextUtil, String file, + InstanceIdentifier ii) { + Networks networks = null; + File topoFile = new File(file); if (topoFile.exists()) { String fileName = topoFile.getName(); InputStream targetStream; @@ -62,7 +62,7 @@ public final class TopologyDataUtils { if (!dataObject.isPresent()) { throw new IllegalStateException("Could not transform normalized nodes into data object"); } else { - result = (Networks) dataObject.get(); + networks = (Networks) dataObject.get(); } } catch (FileNotFoundException e) { LOG.error("File not found : {} at {}", e.getMessage(), e.getLocalizedMessage()); @@ -70,10 +70,8 @@ public final class TopologyDataUtils { } else { LOG.error("xml file {} not found at {}", topoFile.getName(), topoFile.getAbsolutePath()); } - LOG.info("Storing openroadm-topology in datastore"); - InstanceIdentifier ietfNetworksIID = InstanceIdentifier.builder(Networks.class).build(); - writeTransaction(dataStoreContextUtil.getDataBroker(), ietfNetworksIID, result); - LOG.info("openroadm-topology stored with success in datastore"); + writeTransaction(dataStoreContextUtil.getDataBroker(), ii, networks.getNetwork().get(0)); + LOG.info("extraction from {} stored with success in datastore", topoFile.getName()); } @SuppressWarnings("unchecked") @@ -120,7 +118,6 @@ public final class TopologyDataUtils { } private TopologyDataUtils() { - } }