Removed MSB Dependencies
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / msb / entity / MicroServiceInfoTest.java
1 /**
2  * Copyright 2023 ZTE Corporation.
3  * <p>
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * <p>
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * <p>
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.holmes.common.msb.entity;
18
19 import org.junit.Test;
20
21 import java.util.HashSet;
22 import java.util.Set;
23
24 import static org.junit.Assert.assertEquals;
25
26 public class MicroServiceInfoTest {
27     @Test
28     public void testToString() {
29         MicroServiceInfo microServiceInfo = getMicroServiceInfo();
30
31         String expectedOutput = "MicroService List:\r\n" +
32                 "serviceName:service-name\r\n" +
33                 "version:1.0\r\n" +
34                 "url:http://example.com\r\n" +
35                 "protocol:http\r\n" +
36                 "visualRange:local\r\n" +
37                 "enable_ssl:true\r\n" +
38                 "nodes:\r\n" +
39                 "  ip-127.0.0.1\r\n" +
40                 "  port-8080\r\n" +
41                 "  ttl-300\r\n";
42
43         assertEquals(expectedOutput, microServiceInfo.toString());
44     }
45
46     private static MicroServiceInfo getMicroServiceInfo() {
47         MicroServiceInfo microServiceInfo = new MicroServiceInfo();
48         microServiceInfo.setServiceName("service-name");
49         microServiceInfo.setVersion("1.0");
50         microServiceInfo.setUrl("http://example.com");
51         microServiceInfo.setProtocol("http");
52         microServiceInfo.setVisualRange("local");
53         microServiceInfo.setEnable_ssl(true);
54
55         Set<Node> nodes = new HashSet<>();
56         Node node = new Node();
57         node.setIp("127.0.0.1");
58         node.setPort("8080");
59         node.setTtl("300");
60         nodes.add(node);
61         microServiceInfo.setNodes(nodes);
62         return microServiceInfo;
63     }
64 }