aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-REST/src/test/java/org/onap/policy/rest/util
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-REST/src/test/java/org/onap/policy/rest/util')
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java86
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java190
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java82
3 files changed, 179 insertions, 179 deletions
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java
index 85a11d4d5..1064b240d 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java
@@ -27,47 +27,47 @@ import org.junit.Test;
public class MSAttributeObjectTest {
- @Test
- public void testMSAttributeObject(){
- MSAttributeObject data = new MSAttributeObject();
- data.setClassName("Test");
- assertTrue("Test".equals(data.getClassName()));
- data.setRefAttribute(new HashMap<>());
- assertTrue(data.getRefAttribute()!=null);
- data.setAttribute(new HashMap<>());
- assertTrue(data.getAttribute()!=null);
- data.setEnumType(new HashMap<>());
- assertTrue(data.getEnumType()!=null);
- data.addAttribute("test", "test");
- data.addRefAttribute("test", "test");
- data.addAllAttribute(new HashMap<>());
- data.addAllRefAttribute(new HashMap<>());
- data.setSubClass(new HashMap<>());
- assertTrue(data.getSubClass()!=null);
- data.addAllSubClass(new HashMap<>());
- data.setDependency("Test");
- assertTrue("Test".equals(data.getDependency()));
- data.addSingleEnum("test", "test");
- data.setMatchingSet(new HashMap<>());
- assertTrue(data.getMatchingSet()!=null);
- data.addMatchingSet("test", "test");
- data.addMatchingSet(new HashMap<>());
- data.setPolicyTempalate(true);
- assertTrue(data.isPolicyTempalate());
- }
-
- @Test
- public void testMSAttributeValue(){
- MSAttributeValue data = new MSAttributeValue();
- data.setName("Test");
- assertTrue("Test".equals(data.getName()));
- data.setType("Test");
- assertTrue("Test".equals(data.getType()));
- data.setRequired(true);
- assertTrue(data.getRequired());
- data.setArrayValue(true);
- assertTrue(data.getArrayValue());
- data.setDefaultValue("Test");
- assertTrue("Test".equals(data.getDefaultValue()));
- }
+ @Test
+ public void testMSAttributeObject(){
+ MSAttributeObject data = new MSAttributeObject();
+ data.setClassName("Test");
+ assertTrue("Test".equals(data.getClassName()));
+ data.setRefAttribute(new HashMap<>());
+ assertTrue(data.getRefAttribute()!=null);
+ data.setAttribute(new HashMap<>());
+ assertTrue(data.getAttribute()!=null);
+ data.setEnumType(new HashMap<>());
+ assertTrue(data.getEnumType()!=null);
+ data.addAttribute("test", "test");
+ data.addRefAttribute("test", "test");
+ data.addAllAttribute(new HashMap<>());
+ data.addAllRefAttribute(new HashMap<>());
+ data.setSubClass(new HashMap<>());
+ assertTrue(data.getSubClass()!=null);
+ data.addAllSubClass(new HashMap<>());
+ data.setDependency("Test");
+ assertTrue("Test".equals(data.getDependency()));
+ data.addSingleEnum("test", "test");
+ data.setMatchingSet(new HashMap<>());
+ assertTrue(data.getMatchingSet()!=null);
+ data.addMatchingSet("test", "test");
+ data.addMatchingSet(new HashMap<>());
+ data.setPolicyTempalate(true);
+ assertTrue(data.isPolicyTempalate());
+ }
+
+ @Test
+ public void testMSAttributeValue(){
+ MSAttributeValue data = new MSAttributeValue();
+ data.setName("Test");
+ assertTrue("Test".equals(data.getName()));
+ data.setType("Test");
+ assertTrue("Test".equals(data.getType()));
+ data.setRequired(true);
+ assertTrue(data.getRequired());
+ data.setArrayValue(true);
+ assertTrue(data.getArrayValue());
+ data.setDefaultValue("Test");
+ assertTrue("Test".equals(data.getDefaultValue()));
+ }
}
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
index 6a9c4c4ec..e06103fcb 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
@@ -36,102 +36,102 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
public class MSModelUtilsTest {
- private static Logger logger = FlexLogger.getLogger(MSModelUtilsTest.class);
- @Test
- public void testMSModelUtils(){
- HashMap<String, MSAttributeObject> 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<String, MSAttributeObject> tempMap = utils.processEpackage(file.getAbsolutePath().toString(), MODEL_TYPE.XMI);
- classMap.putAll(tempMap);
- MSAttributeObject mainClass = classMap.get("StandardDeviationThreshold");
- String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""});
- List<String> dependency = new ArrayList<String>(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
- */
-
- @Test
- public void testStringBetweenDots() {
-
- //expect: uniqueKeys should contain a string value
- 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();
- assertEquals(0, controllerB.stringBetweenDots(str));
- }
-
- /**
- * Run the Map<String,String> load(String) method test
- */
-
- @Test
- public void testLoad() {
-
- boolean isLocalTesting = true;
- MSModelUtils controller = new MSModelUtils();
- String fileName = null;
- Map<String,String> result = null;
- try {
- ClassLoader classLoader = getClass().getClassLoader();
- fileName = new File(classLoader.getResource("policy_tosca_tca-v1707.yml").getFile()).getAbsolutePath();
- } catch (Exception e1) {
- logger.error("Exception Occured while loading file"+e1);
- }
- if(isLocalTesting){
- try {
- result = controller.load(fileName);
- } catch (IOException e) {
- logger.error("testLoad", e);
- result = null;
- }catch(ParserException e){
- logger.error("testLoad", e);
- }
-
- assertTrue(result != null && !result.isEmpty());
- logger.debug("result : " + result);
- }
-
- logger.debug("testLoad: exit");
- }
-
- /**
- * Run the void parseTosca(String) method test
- */
-
- @Test
- public void testParseTosca() {
-
- logger.debug("testParseTosca: enter");
- boolean isLocalTesting = true;
- String fileName = null;
- try {
- ClassLoader classLoader = getClass().getClassLoader();
- fileName = new File(classLoader.getResource("policy_tosca_tca-v1707.yml").getFile()).getAbsolutePath();
- } catch (Exception e1) {
- logger.error("Exception Occured while loading file"+e1);
- }
-
- MSModelUtils controller = new MSModelUtils();
+ private static Logger logger = FlexLogger.getLogger(MSModelUtilsTest.class);
+ @Test
+ public void testMSModelUtils(){
+ HashMap<String, MSAttributeObject> 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<String, MSAttributeObject> tempMap = utils.processEpackage(file.getAbsolutePath().toString(), MODEL_TYPE.XMI);
+ classMap.putAll(tempMap);
+ MSAttributeObject mainClass = classMap.get("StandardDeviationThreshold");
+ String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""});
+ List<String> dependency = new ArrayList<String>(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
+ */
+
+ @Test
+ public void testStringBetweenDots() {
+
+ //expect: uniqueKeys should contain a string value
+ 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();
+ assertEquals(0, controllerB.stringBetweenDots(str));
+ }
+
+ /**
+ * Run the Map<String,String> load(String) method test
+ */
+
+ @Test
+ public void testLoad() {
+
+ boolean isLocalTesting = true;
+ MSModelUtils controller = new MSModelUtils();
+ String fileName = null;
+ Map<String,String> result = null;
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ fileName = new File(classLoader.getResource("policy_tosca_tca-v1707.yml").getFile()).getAbsolutePath();
+ } catch (Exception e1) {
+ logger.error("Exception Occured while loading file"+e1);
+ }
+ if(isLocalTesting){
+ try {
+ result = controller.load(fileName);
+ } catch (IOException e) {
+ logger.error("testLoad", e);
+ result = null;
+ }catch(ParserException e){
+ logger.error("testLoad", e);
+ }
+
+ assertTrue(result != null && !result.isEmpty());
+ logger.debug("result : " + result);
+ }
+
+ logger.debug("testLoad: exit");
+ }
+
+ /**
+ * Run the void parseTosca(String) method test
+ */
+
+ @Test
+ public void testParseTosca() {
+
+ logger.debug("testParseTosca: enter");
+ boolean isLocalTesting = true;
+ String fileName = null;
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ fileName = new File(classLoader.getResource("policy_tosca_tca-v1707.yml").getFile()).getAbsolutePath();
+ } catch (Exception e1) {
+ logger.error("Exception Occured while loading file"+e1);
+ }
+
+ MSModelUtils controller = new MSModelUtils();
if(isLocalTesting){
- try {
- controller.parseTosca(fileName);
- }catch (Exception e) {
- fail("parseTosca caused error: " + e);
- }
+ try {
+ controller.parseTosca(fileName);
+ }catch (Exception e) {
+ fail("parseTosca caused error: " + e);
+ }
}
- logger.debug("testParseTosca: exit");
- }
+ logger.debug("testParseTosca: exit");
+ }
} \ No newline at end of file
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java
index fb51c2871..6051db4c3 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java
@@ -31,50 +31,50 @@ import org.onap.policy.api.PolicyParameters;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
public class PolicyValidationTest {
-
- @Before
- public void setUp() throws Exception {
- }
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void microServicePolicyTests() throws Exception{
- PolicyValidation validation = new PolicyValidation();
- PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
- PolicyParameters policyParameters = new PolicyParameters();
-
- policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
- policyParameters.setPolicyName("Test.junitPolicy");
- policyParameters.setPolicyDescription("This is a sample Micro Service policy Create example");
- policyParameters.setOnapName("DCAE");
- policyParameters.setPriority("1");
- String MSjsonString = "{\"service\":\"TOSCA_namingJenny\",\"location\":\"Test DictMSLoc\",\"uuid\":\"testDict DCAEUIID\",\"policyName\":\"testModelValidation\",\"description\":\"test\",\"configName\":\"testDict MSConfName\",\"templateVersion\":\"1607\",\"version\":\"gw12181031\",\"priority\":\"5\",\"policyScope\":\"resource=ResourcetypeVenktest1,service=ServiceName1707,type=Name1707,closedLoopControlName=Retest_retest1\",\"riskType\":\"Test\",\"riskLevel\":\"3\",\"guard\":\"True\",\"content\":{\"police-instance-name\":\"testing\",\"naming-models\":[{\"naming-properties\":[{\"property-value\":\"test\",\"source-endpoint\":\"test\",\"property-name\":\"testPropertyname\",\"increment-sequence\":{\"scope\":\"VNF\",\"start-value\":\"1\",\"length\":\"3\",\"increment\":\"2\"},\"source-system\":\"TOSCA\"}],\"naming-type\":\"testNamingType\",\"naming-recipe\":\"testNamingRecipe\"}]}}";;
- policyParameters.setConfigBody(MSjsonString);
- policyParameters.setRequestID(UUID.randomUUID());
- SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateformat3.parse("15/10/2016");
- policyParameters.setTtlDate(date);
- policyParameters.setGuard(true);
- policyParameters.setRiskLevel("5");
- policyParameters.setRiskType("TEST");
- policyParameters.setRequestID(UUID.randomUUID());
+ @Before
+ public void setUp() throws Exception {
+ }
-
- PolicyRestAdapter policyData = wrapper.populateRequestParameters(policyParameters);
- StringBuilder responseString = validation.validatePolicy(policyData);
-
- assertNotSame("success", responseString.toString());
+ @After
+ public void tearDown() throws Exception {
+ }
- }
+ @Test
+ public void microServicePolicyTests() throws Exception{
+ PolicyValidation validation = new PolicyValidation();
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+ PolicyParameters policyParameters = new PolicyParameters();
- @Test
- public final void testEmailValidation() {
- PolicyValidation validation = new PolicyValidation();
- String result = validation.emailValidation("testemail@test.com", "SUCCESS");
- assertEquals("success", result);
- }
+ policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
+ policyParameters.setPolicyName("Test.junitPolicy");
+ policyParameters.setPolicyDescription("This is a sample Micro Service policy Create example");
+ policyParameters.setOnapName("DCAE");
+ policyParameters.setPriority("1");
+ String MSjsonString = "{\"service\":\"TOSCA_namingJenny\",\"location\":\"Test DictMSLoc\",\"uuid\":\"testDict DCAEUIID\",\"policyName\":\"testModelValidation\",\"description\":\"test\",\"configName\":\"testDict MSConfName\",\"templateVersion\":\"1607\",\"version\":\"gw12181031\",\"priority\":\"5\",\"policyScope\":\"resource=ResourcetypeVenktest1,service=ServiceName1707,type=Name1707,closedLoopControlName=Retest_retest1\",\"riskType\":\"Test\",\"riskLevel\":\"3\",\"guard\":\"True\",\"content\":{\"police-instance-name\":\"testing\",\"naming-models\":[{\"naming-properties\":[{\"property-value\":\"test\",\"source-endpoint\":\"test\",\"property-name\":\"testPropertyname\",\"increment-sequence\":{\"scope\":\"VNF\",\"start-value\":\"1\",\"length\":\"3\",\"increment\":\"2\"},\"source-system\":\"TOSCA\"}],\"naming-type\":\"testNamingType\",\"naming-recipe\":\"testNamingRecipe\"}]}}";;
+ policyParameters.setConfigBody(MSjsonString);
+ policyParameters.setRequestID(UUID.randomUUID());
+ SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateformat3.parse("15/10/2016");
+ policyParameters.setTtlDate(date);
+ policyParameters.setGuard(true);
+ policyParameters.setRiskLevel("5");
+ policyParameters.setRiskType("TEST");
+ policyParameters.setRequestID(UUID.randomUUID());
+
+
+ PolicyRestAdapter policyData = wrapper.populateRequestParameters(policyParameters);
+ StringBuilder responseString = validation.validatePolicy(policyData);
+
+ assertNotSame("success", responseString.toString());
+
+ }
+
+ @Test
+ public final void testEmailValidation() {
+ PolicyValidation validation = new PolicyValidation();
+ String result = validation.emailValidation("testemail@test.com", "SUCCESS");
+ assertEquals("success", result);
+ }
}