Merge "50% Code Coverage-MSB Java SDK"
[msb/java-sdk.git] / src / test / java / org / onap / msb / sdk / httpclient / ServiceHttpEndPointObjectTest.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package org.onap.msb.sdk.httpclient;
15
16 import java.util.HashSet;
17 import java.util.Set;
18
19 import org.junit.Assert;
20 import org.junit.Test;
21 import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
22 import org.onap.msb.sdk.discovery.entity.NodeInfo;
23
24 public class ServiceHttpEndPointObjectTest {
25
26     @Test
27     public void testBean() {
28         NodeInfo nodeInfo = new NodeInfo();
29         nodeInfo.setIp("127.0.0.1");
30         nodeInfo.setPort("80");
31         MicroServiceFullInfo cloneFullInfo = new MicroServiceFullInfo();
32         cloneFullInfo.setUrl("/aai/v8");
33         cloneFullInfo.setServiceName("aai");
34         cloneFullInfo.setVersion("v8");
35         cloneFullInfo.setVisualRange("1");
36         
37         Set<NodeInfo> nodes=new HashSet<NodeInfo>();
38         nodes.add(nodeInfo);
39         cloneFullInfo.setNodes(nodes);
40
41         ServiceHttpEndPointObject endPointOjb = new ServiceHttpEndPointObject("aai", "v8", nodeInfo, cloneFullInfo);
42         Assert.assertEquals(endPointOjb.getIp(), "127.0.0.1");
43         Assert.assertEquals(endPointOjb.getPort(), "80");
44         Assert.assertEquals(endPointOjb.getServiceName(), "aai");
45         Assert.assertEquals(endPointOjb.getServiceVersion(), "v8");
46         
47         System.out.println(endPointOjb.hashCode());
48         ServiceHttpEndPointObject endPointOjb2 = new ServiceHttpEndPointObject("aai", "v8", nodeInfo, cloneFullInfo);
49         Assert.assertTrue(endPointOjb2.equals(endPointOjb));
50         
51         endPointOjb.setProtocl("HTTP");
52         endPointOjb.setNameSpace("ns");
53         System.out.println(endPointOjb.toString());
54         Assert.assertEquals("HTTP", endPointOjb.getProtocl());
55         Assert.assertEquals("ns", endPointOjb.getNameSpace());
56     
57     }
58
59 }