use of org.onap.so.client.grm.beans.ServiceEndPointList 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.ServiceEndPointList 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.ServiceEndPointList in project so by onap.
the class CreateVnfOperationalEnvironment method execute.
public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
try {
setRequest(request);
ObjectMapper objectMapper = new ObjectMapper();
AAIResultWrapper aaiResultWrapper = aaiHelper.getAaiOperationalEnvironment(getEcompManagingEnvironmentId());
if (aaiResultWrapper.isEmpty()) {
throw new NotFoundException(getEcompManagingEnvironmentId() + " not found in A&AI");
}
OperationalEnvironment aaiEnv = aaiResultWrapper.asBean(OperationalEnvironment.class).get();
// Find ECOMP environments in GRM
logger.debug(" Start of GRM findRunningServicesAsString");
String searchKey = getSearchKey(aaiEnv);
String tenantContext = getTenantContext().toUpperCase();
String jsonResponse = getGrmClient().findRunningServicesAsString(searchKey, 1, tenantContext);
ServiceEndPointList sel = objectMapper.readValue(jsonResponse, ServiceEndPointList.class);
if (sel.getServiceEndPointList().size() == 0) {
throw new TenantIsolationException("GRM did not find any matches for " + searchKey + " in " + tenantContext);
}
// Replicate end-point for VNF Operating environment in GRM
List<ServiceEndPointRequest> serviceEndpointRequestList = buildEndPointRequestList(sel);
int ctr = 0;
int total = serviceEndpointRequestList.size();
for (ServiceEndPointRequest requestList : serviceEndpointRequestList) {
logger.debug("Creating endpoint " + ++ctr + " of " + total + ": " + requestList.getServiceEndPoint().getName());
getGrmClient().addServiceEndPoint(requestList);
}
// Create VNF operating in A&AI
aaiHelper.createOperationalEnvironment(aaiClientObjectBuilder.buildAAIOperationalEnvironment("INACTIVE", request));
aaiHelper.createRelationship(request.getOperationalEnvironmentId(), getEcompManagingEnvironmentId());
// Update request database
requestDb.updateInfraSuccessCompletion("SUCCESSFULLY created VNF operational environment", requestId, request.getOperationalEnvironmentId());
} catch (Exception e) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build();
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
throw validateException;
}
}
use of org.onap.so.client.grm.beans.ServiceEndPointList in project so by onap.
the class ServiceEndPointListTest method testUnmarshallServiceEndpointListStartsWithUppercase.
@Test
public void testUnmarshallServiceEndpointListStartsWithUppercase() throws Exception {
String endpointsJson = getFileContentsAsString("__files/grm/endpoints2.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());
}
Aggregations