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;
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.LoopElementModel;
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() {
41 LoopElementModel msModel = new LoopElementModel("testMs", LoopElementModel.MICRO_SERVICE_TYPE, "");
42 MicroServicePolicy ms1 =
43 new MicroServicePolicy("ms1", new PolicyModel("org.onap.ms1", "", "1.0.0", "short.ms1"),
44 false,null,msModel,null,null);
45 MicroServicePolicy ms2 =
46 new MicroServicePolicy("ms2", new PolicyModel("org.onap.ms2", "", "1.0.0", "short.ms2"),
47 false, null,msModel,null,null);
48 LoopElementModel opModel = new LoopElementModel("testOp", LoopElementModel.OPERATIONAL_POLICY_TYPE, "");
49 OperationalPolicy opPolicy = new OperationalPolicy("OperationalPolicy", new JsonObject(),new JsonObject(),
50 new PolicyModel("org.onap.opolicy", null, "1.0.0", "short.OperationalPolicy"), opModel, null, null);
51 Loop loop = new Loop();
52 loop.addMicroServicePolicy(ms1);
53 loop.addMicroServicePolicy(ms2);
54 loop.addOperationalPolicy(opPolicy);
59 * Test a Svg rendering with all objects.
61 * @throws IOException In case of isssues
62 * @throws ParserConfigurationException In case of isssues
63 * @throws SAXException In case of isssues
66 public void getAsSvgTest() throws IOException, ParserConfigurationException, SAXException {
67 String xml = SvgLoopGenerator.getSvgImage(getLoop());
68 assertThat(xml).contains("data-element-id=\"VES\"");
69 assertThat(xml).contains(">VES<");
70 assertThat(xml).contains("data-element-id=\"ms1\"");
71 assertThat(xml).contains("data-element-id=\"ms2\"");
72 assertThat(xml).contains("data-grouping-id=\"testMs\"");
73 assertThat(xml).contains("data-grouping-id=\"testOp\"");
74 assertThat(xml).contains("data-for-ui=\"testMs\"");
75 assertThat(xml).contains("data-for-ui=\"testOp\"");
76 assertThat(xml).contains(">short.ms1<");
77 assertThat(xml).contains(">short.ms2<");
78 assertThat(xml).contains("data-element-id=\"OperationalPolicy\"");
79 assertThat(xml).contains(">short.OperationalPolicy<");