use of org.onap.so.client.grm.beans.ServiceEndPoint in project so by onap.
the class ServiceEndPointListTest method testUnmarshall.
@Test
public void testUnmarshall() throws Exception {
String endpointsJson = getFileContentsAsString("__files/grm/endpoints.json");
ServiceEndPointList sel = mapper.readValue(endpointsJson, ServiceEndPointList.class);
List<ServiceEndPoint> list = sel.getServiceEndPointList();
ServiceEndPoint se = list.get(0);
assertEquals(3, list.size());
assertEquals("dummy.pod.ns.dummy-pod3", se.getName());
assertEquals(Integer.valueOf(1), Integer.valueOf(se.getVersion().getMajor()));
assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getMinor()));
assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getPatch()));
assertEquals("192.168.120.218", se.getHostAddress());
assertEquals("32004", se.getListenPort());
assertEquals("37.7022", se.getLatitude());
assertEquals("121.9358", se.getLongitude());
assertEquals("/", se.getContextPath());
assertEquals("edge", se.getOperationalInfo().getCreatedBy());
assertEquals("edge", se.getOperationalInfo().getUpdatedBy());
assertEquals("Environment", se.getProperties().get(0).getName());
assertEquals("DEV", se.getProperties().get(0).getValue());
}
use of org.onap.so.client.grm.beans.ServiceEndPoint in project so by onap.
the class ServiceEndPointRequestTest method testMarshall.
@Test
public void testMarshall() throws Exception {
String expected = "{\"serviceEndPoint\":{\"name\":\"TEST.ECOMP_PSL.Inventory\",\"version\":{\"major\":1,\"minor\":0,\"patch\":\"0\"}," + "\"hostAddress\":\"127.0.0.1\",\"listenPort\":\"8080\",\"latitude\":\"37.7022\",\"longitude\":\"121.9358\"," + "\"contextPath\":\"/\",\"routeOffer\":\"TEST\",\"operationalInfo\":{\"createdBy\":\"edge\",\"updatedBy\":\"edge\"}," + "\"properties\":[{\"name\":\"Environment\",\"value\":\"TEST\"},{\"name\":\"cpfrun_cluster_name\"," + "\"value\":\"testcase_cluster_no_cluster\"}]},\"env\":\"DEV\"}";
Version ver = new Version();
ver.setMajor(1);
ver.setMinor(0);
ver.setPatch("0");
ServiceEndPoint sep = new ServiceEndPoint();
sep.setName("TEST.ECOMP_PSL.Inventory");
sep.setVersion(ver);
sep.setHostAddress("127.0.0.1");
sep.setListenPort("8080");
sep.setLatitude("37.7022");
sep.setLongitude("121.9358");
sep.setContextPath("/");
sep.setRouteOffer("TEST");
OperationalInfo operInfo = new OperationalInfo();
operInfo.setCreatedBy("edge");
operInfo.setUpdatedBy("edge");
sep.setOperationalInfo(operInfo);
Property prop1 = new Property();
prop1.setName("Environment");
prop1.setValue("TEST");
Property prop2 = new Property();
prop2.setName("cpfrun_cluster_name");
prop2.setValue("testcase_cluster_no_cluster");
List<Property> props = new ArrayList<Property>();
props.add(prop1);
props.add(prop2);
sep.setProperties(props);
ServiceEndPointRequest request = new ServiceEndPointRequest();
request.setEnv("DEV");
request.setServiceEndPoint(sep);
assertEquals(expected, mapper.writeValueAsString(request));
}
use of org.onap.so.client.grm.beans.ServiceEndPoint in project so by onap.
the class CreateVnfOperationalEnvironment method buildEndPointRequestList.
private List<ServiceEndPointRequest> buildEndPointRequestList(ServiceEndPointList serviceEndPointList) throws TenantIsolationException {
List<ServiceEndPoint> endpointList = serviceEndPointList.getServiceEndPointList();
logger.debug("Number of service endpoints from GRM: {}", endpointList.size());
List<ServiceEndPointRequest> serviceEndPointRequestList = new ArrayList<>();
for (ServiceEndPoint serviceEndpoint : endpointList) {
serviceEndPointRequestList.add(buildServiceEndpoint(serviceEndpoint));
}
return serviceEndPointRequestList;
}
use of org.onap.so.client.grm.beans.ServiceEndPoint in project so by onap.
the class GRMClientTest method testFind.
@Test
public void testFind() throws Exception {
TestAppender.events.clear();
String endpoints = getFileContentsAsString("__files/grm/endpoints.json");
wireMockServer.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", MediaType.APPLICATION_JSON).withBody(endpoints)));
MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, "/test");
GRMClient client = new GRMClient();
ServiceEndPointList sel = client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST");
List<ServiceEndPoint> list = sel.getServiceEndPointList();
assertEquals(3, list.size());
wireMockServer.verify(postRequestedFor(urlEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning")).withHeader(ONAPLogConstants.Headers.INVOCATION_ID.toString(), matching(uuidRegex)).withHeader(ONAPLogConstants.Headers.REQUEST_ID.toString(), matching(uuidRegex)).withHeader(ONAPLogConstants.Headers.PARTNER_NAME.toString(), equalTo("SO.APIH")));
}
use of org.onap.so.client.grm.beans.ServiceEndPoint in project so by onap.
the class CreateVnfOperationalEnvironment method buildServiceEndpoint.
private ServiceEndPointRequest buildServiceEndpoint(ServiceEndPoint serviceEndpoint) throws TenantIsolationException {
// @TODO: handle nulls? Put in a ServiceEndpointWrapper class which will check for nulls and flatten access to
// fields
Version ver = new Version();
ver.setMajor(serviceEndpoint.getVersion().getMajor());
ver.setMinor(serviceEndpoint.getVersion().getMinor());
ver.setPatch(serviceEndpoint.getVersion().getPatch());
ServiceEndPoint endpoint = new ServiceEndPoint();
endpoint.setName(buildServiceNameForVnf(serviceEndpoint.getName()));
endpoint.setVersion(ver);
endpoint.setHostAddress(serviceEndpoint.getHostAddress());
endpoint.setListenPort(serviceEndpoint.getListenPort());
endpoint.setLatitude(serviceEndpoint.getLatitude());
endpoint.setLongitude(serviceEndpoint.getLongitude());
endpoint.setContextPath(serviceEndpoint.getContextPath());
endpoint.setRouteOffer(serviceEndpoint.getRouteOffer());
OperationalInfo operInfo = new OperationalInfo();
operInfo.setCreatedBy(serviceEndpoint.getOperationalInfo().getCreatedBy());
operInfo.setUpdatedBy(serviceEndpoint.getOperationalInfo().getUpdatedBy());
endpoint.setOperationalInfo(operInfo);
endpoint.setProperties(serviceEndpoint.getProperties());
String env = getEnvironmentName(serviceEndpoint.getProperties());
ServiceEndPointRequest serviceEndPontRequest = new ServiceEndPointRequest();
serviceEndPontRequest.setEnv(env);
serviceEndPontRequest.setServiceEndPoint(endpoint);
return serviceEndPontRequest;
}
Aggregations