X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Frest%2Futil%2FMsModelUtilsTest.java;fp=ONAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Frest%2Futil%2FMSModelUtilsTest.java;h=59115b95934ff4437590fd40140e81cf843d75d0;hp=34d555062511a287a1db645ac0d24339bc3ed573;hb=779125e31adbcc59a9864843b523bd6ed2751cbb;hpb=a2ab61f0ad39970ad35c3e47ff8429f59850c469 diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MsModelUtilsTest.java similarity index 82% rename from ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java rename to ONAP-REST/src/test/java/org/onap/policy/rest/util/MsModelUtilsTest.java index 34d555062..59115b959 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MsModelUtilsTest.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +26,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -32,6 +34,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; + import org.apache.commons.lang.StringUtils; import org.junit.Before; import org.junit.Test; @@ -39,12 +42,17 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.DictionaryData; -import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE; +import org.onap.policy.rest.util.MsModelUtils.ModelType; -public class MSModelUtilsTest { - private static Logger logger = FlexLogger.getLogger(MSModelUtilsTest.class); +public class MsModelUtilsTest { + private static Logger logger = FlexLogger.getLogger(MsModelUtilsTest.class); private static CommonClassDao commonClassDao; + /** + * Set tests up. + * + * @throws Exception on setup failures + */ @Before public void setUp() throws Exception { List dictionaryData = new ArrayList(); @@ -55,28 +63,28 @@ public class MSModelUtilsTest { logger.info("setUp: Entering"); commonClassDao = mock(CommonClassDao.class); when(commonClassDao.getDataById(DictionaryData.class, "dictionaryName", "GocVNFType")) - .thenReturn(dictionaryData); + .thenReturn(dictionaryData); } @Test - public void testMSModelUtils() { - HashMap classMap = new HashMap<>(); + public void testMsModelUtils() { + HashMap classMap = new HashMap<>(); ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource("DKaTVESPolicy-v1802.xmi").getFile()); - MSModelUtils utils = new MSModelUtils("http://org.onap", "http://org.onap.policy"); - Map tempMap = - utils.processEpackage(file.getAbsolutePath().toString(), MODEL_TYPE.XMI); + MsModelUtils utils = new MsModelUtils("http://org.onap", "http://org.onap.policy"); + Map tempMap = utils.processEpackage(file.getAbsolutePath().toString(), + ModelType.XMI); classMap.putAll(tempMap); - MSAttributeObject mainClass = classMap.get("StandardDeviationThreshold"); - String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "}, - new String[] {"", "", ""}); + MsAttributeObject mainClass = classMap.get("StandardDeviationThreshold"); + String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] + { "[", "]", " " }, new String[] + { "", "", "" }); List dependency = new ArrayList(Arrays.asList(dependTemp.split(","))); dependency = utils.getFullDependencyList(dependency, classMap); String subAttribute = utils.createSubAttributes(dependency, classMap, "StandardDeviationThreshold"); assertTrue(subAttribute != null); } - /** * Run the void stringBetweenDots(String, String) method test. */ @@ -85,25 +93,24 @@ public class MSModelUtilsTest { public void testStringBetweenDots() { // expect: uniqueKeys should contain a string value - MSModelUtils controllerA = new MSModelUtils(); + MsModelUtils controllerA = new MsModelUtils(); String str = "testing\\.byCorrectWay\\.OfDATA"; assertEquals(1, controllerA.stringBetweenDots(str)); // expect: uniqueKeys should not contain a string value str = "testing\byWrongtWay.\\OfDATA"; - MSModelUtils controllerB = new MSModelUtils(); + MsModelUtils controllerB = new MsModelUtils(); assertEquals(0, controllerB.stringBetweenDots(str)); } /** - * Run the Map load(String) method test. + * Run the load method test. */ - @Test public void testLoad() { boolean isLocalTesting = true; - MSModelUtils controller = new MSModelUtils(); + MsModelUtils controller = new MsModelUtils(); String fileName = null; Map result = null; try { @@ -146,7 +153,7 @@ public class MSModelUtilsTest { logger.error("Exception Occured while loading file" + e1); } - MSModelUtils controller = new MSModelUtils(commonClassDao); + MsModelUtils controller = new MsModelUtils(commonClassDao); if (isLocalTesting) { try { controller.parseTosca(fileName);