Search in sources :

Example 1 with ServiceEndPointList

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());
}
Also used : ServiceEndPointList(org.onap.so.client.grm.beans.ServiceEndPointList) ServiceEndPoint(org.onap.so.client.grm.beans.ServiceEndPoint) Test(org.junit.Test)

Example 2 with ServiceEndPointList

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")));
}
Also used : ServiceEndPointList(org.onap.so.client.grm.beans.ServiceEndPointList) ServiceEndPoint(org.onap.so.client.grm.beans.ServiceEndPoint) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 3 with ServiceEndPointList

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;
    }
}
Also used : ServiceEndPointList(org.onap.so.client.grm.beans.ServiceEndPointList) ServiceEndPointRequest(org.onap.so.client.grm.beans.ServiceEndPointRequest) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) AAIClientObjectBuilder(org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder) NotFoundException(javax.ws.rs.NotFoundException) ServiceEndPoint(org.onap.so.client.grm.beans.ServiceEndPoint) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) TenantIsolationException(org.onap.so.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) NotFoundException(javax.ws.rs.NotFoundException) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment) ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TenantIsolationException(org.onap.so.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 4 with ServiceEndPointList

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());
}
Also used : ServiceEndPointList(org.onap.so.client.grm.beans.ServiceEndPointList) ServiceEndPoint(org.onap.so.client.grm.beans.ServiceEndPoint) Test(org.junit.Test)

Aggregations

ServiceEndPoint (org.onap.so.client.grm.beans.ServiceEndPoint)4 ServiceEndPointList (org.onap.so.client.grm.beans.ServiceEndPointList)4 Test (org.junit.Test)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 NotFoundException (javax.ws.rs.NotFoundException)1 OperationalEnvironment (org.onap.aai.domain.yang.OperationalEnvironment)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1 BaseTest (org.onap.so.apihandlerinfra.BaseTest)1 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)1 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)1 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)1 TenantIsolationException (org.onap.so.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException)1 AAIClientObjectBuilder (org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder)1 ServiceEndPointRequest (org.onap.so.client.grm.beans.ServiceEndPointRequest)1