2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ===================================================================
24 package org.onap.clamp.clds.util.drawing;
26 import static org.assertj.core.api.Assertions.assertThat;
28 import com.google.gson.JsonObject;
29 import java.io.IOException;
30 import javax.xml.parsers.ParserConfigurationException;
31 import org.junit.Test;
32 import org.onap.clamp.loop.Loop;
33 import org.onap.clamp.loop.template.PolicyModel;
34 import org.onap.clamp.policy.microservice.MicroServicePolicy;
35 import org.onap.clamp.policy.operational.OperationalPolicy;
36 import org.xml.sax.SAXException;
38 public class SvgLoopGeneratorTest {
39 private Loop getLoop() {
40 MicroServicePolicy ms1 =
41 new MicroServicePolicy("ms1", new PolicyModel("org.onap.ms1", "", "1.0.0", "short.ms1"),
42 false,null,null,null,null);
43 MicroServicePolicy ms2 =
44 new MicroServicePolicy("ms2", new PolicyModel("org.onap.ms2", "", "1.0.0", "short.ms2"),
45 false, null,null,null,null);
46 OperationalPolicy opPolicy = new OperationalPolicy("OperationalPolicy", new JsonObject(),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);
56 * Test a Svg rendering with all objects.
58 * @throws IOException In case of isssues
59 * @throws ParserConfigurationException In case of isssues
60 * @throws SAXException In case of isssues
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<");