1 package org.onap.ccsdk.sli.core.slipluginutils;
3 import org.junit.Before;
5 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
6 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
7 import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils;
8 import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils_ctxSortList;
9 import org.onap.ccsdk.sli.core.slipluginutils.SliTopologyUtils;
10 import org.onap.ccsdk.sli.core.slipluginutils.slitopologyutils.JsonParserHelper;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
14 import java.nio.file.Files;
15 import java.nio.file.Paths;
16 import java.util.HashMap;
19 import static org.junit.Assert.assertTrue;
21 public class SliTopologyUtilsTest {
22 private SvcLogicContext ctx;
23 private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class);
24 private HashMap<String, String> param;
25 private SliTopologyUtils topologyUtil = new SliTopologyUtils();
27 public void setUp() throws Exception {
28 //Loading test logicallinks and pnfs
29 this.ctx = new SvcLogicContext();
30 param = new HashMap<String, String>();
31 String fileName1 = "src/test/resources/Pnfs.json";
32 String fileName2 = "src/test/resources/LogicalLinks.json";
34 byte[] encoded = Files.readAllBytes(Paths.get(fileName1));
35 String fileString = new String(encoded, "UTF-8");
37 Map<String, String> mm = null;
38 mm = JsonParserHelper.convertToProperties(fileString);
40 for (Map.Entry<String, String> entry : mm.entrySet()) {
41 ctx.setAttribute(pp1 + entry.getKey(), entry.getValue());
45 encoded = Files.readAllBytes(Paths.get(fileName2));
46 fileString = new String(encoded, "UTF-8");
47 String pp2 = "LogicalLinks.";
49 mm = JsonParserHelper.convertToProperties(fileString);
51 for (Map.Entry<String, String> entry : mm.entrySet()) {
52 ctx.setAttribute(pp2 + entry.getKey(), entry.getValue());
56 } catch (Exception e ){
57 LOG.trace("Failed to read topology json files" + e.getMessage());
62 public void computePath() throws SvcLogicException {
64 param.put("pnfs-pfx", "Pnfs");
65 param.put("links-pfx", "LogicalLinks");
66 param.put("response-pfx", "prefix");
67 param.put("output-end-to-end-path", "true");
68 param.put("src-node","networkId-providerId-20-clientId-0-topologyId-1-nodeId-10.2.1.2" );
69 param.put("dst-node", "networkId-providerId-10-clientId-0-topologyId-1-nodeId-10.1.1.4");
71 SliTopologyUtils.computePath(param, ctx);
72 SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
73 assertTrue(Integer.parseInt(this.ctx.getAttribute("prefix.solutions_length") ) > 0);