Replaced all tabs with spaces in java and pom.xml
[so.git] / common / src / test / java / org / onap / so / client / grm / ServiceEndPointRequestTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.client.grm;
22
23 import static org.junit.Assert.assertEquals;
24 import java.util.ArrayList;
25 import java.util.List;
26 import org.junit.Test;
27 import org.onap.so.client.grm.beans.OperationalInfo;
28 import org.onap.so.client.grm.beans.Property;
29 import org.onap.so.client.grm.beans.ServiceEndPoint;
30 import org.onap.so.client.grm.beans.ServiceEndPointRequest;
31 import org.onap.so.client.grm.beans.Version;
32 import com.fasterxml.jackson.databind.ObjectMapper;
33
34 public class ServiceEndPointRequestTest {
35
36     private ObjectMapper mapper = new ObjectMapper();
37
38     @Test
39     public void testMarshall() throws Exception {
40
41         String expected =
42                 "{\"serviceEndPoint\":{\"name\":\"TEST.ECOMP_PSL.Inventory\",\"version\":{\"major\":1,\"minor\":0,\"patch\":\"0\"},"
43                         + "\"hostAddress\":\"127.0.0.1\",\"listenPort\":\"8080\",\"latitude\":\"37.7022\",\"longitude\":\"121.9358\","
44                         + "\"contextPath\":\"/\",\"routeOffer\":\"TEST\",\"operationalInfo\":{\"createdBy\":\"edge\",\"updatedBy\":\"edge\"},"
45                         + "\"properties\":[{\"name\":\"Environment\",\"value\":\"TEST\"},{\"name\":\"cpfrun_cluster_name\","
46                         + "\"value\":\"testcase_cluster_no_cluster\"}]},\"env\":\"DEV\"}";
47
48         Version ver = new Version();
49         ver.setMajor(1);
50         ver.setMinor(0);
51         ver.setPatch("0");
52
53         ServiceEndPoint sep = new ServiceEndPoint();
54         sep.setName("TEST.ECOMP_PSL.Inventory");
55         sep.setVersion(ver);
56         sep.setHostAddress("127.0.0.1");
57         sep.setListenPort("8080");
58         sep.setLatitude("37.7022");
59         sep.setLongitude("121.9358");
60         sep.setContextPath("/");
61         sep.setRouteOffer("TEST");
62
63         OperationalInfo operInfo = new OperationalInfo();
64         operInfo.setCreatedBy("edge");
65         operInfo.setUpdatedBy("edge");
66
67         sep.setOperationalInfo(operInfo);
68
69         Property prop1 = new Property();
70         prop1.setName("Environment");
71         prop1.setValue("TEST");
72
73         Property prop2 = new Property();
74         prop2.setName("cpfrun_cluster_name");
75         prop2.setValue("testcase_cluster_no_cluster");
76
77         List<Property> props = new ArrayList<Property>();
78         props.add(prop1);
79         props.add(prop2);
80
81         sep.setProperties(props);
82
83         ServiceEndPointRequest request = new ServiceEndPointRequest();
84         request.setEnv("DEV");
85         request.setServiceEndPoint(sep);
86
87         assertEquals(expected, mapper.writeValueAsString(request));
88     }
89 }