54a7a4a72471e76b1a12f751a493405eaaae6511
[clamp.git] / src / test / java / org / onap / clamp / clds / model / prop / ModelPropertiesTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License"); 
9  * you may not use this file except in compliance with the License. 
10  * You may obtain a copy of the License at
11  * 
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software 
15  * distributed under the License is distributed on an "AS IS" BASIS, 
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17  * See the License for the specific language governing permissions and 
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.model.prop;
25
26 import org.onap.clamp.clds.transform.TransformUtil;
27 import org.junit.Assert;
28 import org.junit.Test;
29
30 import java.io.IOException;
31
32 /**
33  * Test org.onap.clamp.ClampDesigner.model.prop package using ModelProperties.
34  */
35 public class ModelPropertiesTest {
36
37     @Test
38     public void testJsonParse() throws IOException {
39         String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json");
40         String modelProp = TransformUtil.getResourceAsString("example/modelProp.json");
41         String modName = "example-model-name";
42         String controlName = "example-control-name";
43
44         ModelProperties prop = new ModelProperties(modName, controlName, null, modelBpmnProp, modelProp);
45         Assert.assertEquals(modName, prop.getModelName());
46         Assert.assertEquals(controlName, prop.getControlName());
47         Assert.assertEquals(null, prop.getActionCd());
48
49         Global g = prop.getGlobal();
50         Assert.assertEquals("df6fcd2b-1932-429e-bb13-0cd0d32113cb", g.getService());
51         Assert.assertEquals("[SNDGCA64, ALPRGAED]", g.getLocation().toString());
52         Assert.assertEquals("[4b49acee-cf70-4b20-b956-a4fe0c1a8239]", g.getResourceVf().toString());
53
54         Collector c = prop.getCollector();
55         Assert.assertEquals("Collector_", c.getId());
56         Assert.assertEquals("DCAE-COLLECTOR-UCSNMP", c.getTopicPublishes());
57
58         StringMatch sm = prop.getStringMatch();
59         Assert.assertEquals("StringMatch_", sm.getId());
60         Assert.assertEquals("DCAE-CL-EVENT", sm.getTopicPublishes());
61
62         Policy p = prop.getPolicy();
63         Assert.assertEquals("Policy_", p.getId());
64         Assert.assertEquals(null, p.getTopicPublishes());
65         Assert.assertEquals("DCAE-CL-EVENT", p.getTopicSubscribes());
66         Assert.assertEquals(500, p.getTimeout().intValue());
67         
68         Tca t = prop.getTca();
69         Assert.assertEquals("Narra", t.getTcaItems().get(0).getTcaName());
70         Assert.assertEquals(Integer.valueOf(4), t.getTcaItems().get(0).getTcaThreshholds().get(0).getThreshhold());
71     }
72
73 }