2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.client.grm;
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;
34 public class ServiceEndPointRequestTest {
36 private ObjectMapper mapper = new ObjectMapper();
39 public void testMarshall() throws Exception {
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\"}";
48 Version ver = new Version();
53 ServiceEndPoint sep = new ServiceEndPoint();
54 sep.setName("TEST.ECOMP_PSL.Inventory");
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");
63 OperationalInfo operInfo = new OperationalInfo();
64 operInfo.setCreatedBy("edge");
65 operInfo.setUpdatedBy("edge");
67 sep.setOperationalInfo(operInfo);
69 Property prop1 = new Property();
70 prop1.setName("Environment");
71 prop1.setValue("TEST");
73 Property prop2 = new Property();
74 prop2.setName("cpfrun_cluster_name");
75 prop2.setValue("testcase_cluster_no_cluster");
77 List<Property> props = new ArrayList<Property>();
81 sep.setProperties(props);
83 ServiceEndPointRequest request = new ServiceEndPointRequest();
84 request.setEnv("DEV");
85 request.setServiceEndPoint(sep);
87 assertEquals(expected, mapper.writeValueAsString(request));