a320131c488c4be57dbdd3c9fb20ab03b086ae1b
[clamp.git] / src / test / java / org / onap / clamp / clds / util / drawing / SvgLoopGeneratorTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2019 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  *
22  */
23
24 package org.onap.clamp.clds.util.drawing;
25
26 import static org.assertj.core.api.Assertions.assertThat;
27 import com.google.gson.JsonObject;
28 import java.io.IOException;
29 import javax.xml.parsers.ParserConfigurationException;
30 import org.junit.Test;
31 import org.onap.clamp.loop.Loop;
32 import org.onap.clamp.loop.template.PolicyModel;
33 import org.onap.clamp.policy.microservice.MicroServicePolicy;
34 import org.onap.clamp.policy.operational.OperationalPolicy;
35 import org.xml.sax.SAXException;
36
37 public class SvgLoopGeneratorTest {
38     private Loop getLoop() {
39         MicroServicePolicy ms1 =
40                 new MicroServicePolicy("ms1", new PolicyModel("org.onap.ms1", "", "1.0.0", "short.ms1"),
41                         false,
42                         null);
43         MicroServicePolicy ms2 =
44                 new MicroServicePolicy("ms2", new PolicyModel("org.onap.ms2", "", "1.0.0", "short.ms2"),
45                         false, null);
46         OperationalPolicy opPolicy = new OperationalPolicy("OperationalPolicy", new Loop(), new JsonObject(),
47                 new PolicyModel("org.onap.opolicy", null, "1.0.0", "short.OperationalPolicy"), null, null, null);
48         Loop loop = new Loop();
49         loop.addMicroServicePolicy(ms1);
50         loop.addMicroServicePolicy(ms2);
51         loop.addOperationalPolicy(opPolicy);
52         return loop;
53     }
54
55     /**
56      * Test a Svg rendering with all objects.
57      *
58      * @throws IOException In case of isssues
59      * @throws ParserConfigurationException In case of isssues
60      * @throws SAXException In case of isssues
61      */
62     @Test
63     public void getAsSvgTest() throws IOException, ParserConfigurationException, SAXException {
64         String xml = SvgLoopGenerator.getSvgImage(getLoop());
65         assertThat(xml).contains("data-element-id=\"VES\"");
66         assertThat(xml).contains(">VES<");
67         assertThat(xml).contains("data-element-id=\"ms1\"");
68         assertThat(xml).contains("data-element-id=\"ms2\"");
69         assertThat(xml).contains(">short.ms1<");
70         assertThat(xml).contains(">short.ms2<");
71         assertThat(xml).contains("data-element-id=\"OperationalPolicy\"");
72         assertThat(xml).contains(">short.OperationalPolicy<");
73
74     }
75 }