Search in sources :

Example 1 with QueryVfModuleResponse

use of org.onap.so.adapters.vnfrest.QueryVfModuleResponse in project so by onap.

the class VnfAdapterClientImpl method queryVfModule.

@Override
public QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId, String tenantId, String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId) throws VnfAdapterClientException {
    UriBuilder builder = this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId);
    if (cloudSiteId != null) {
        builder.queryParam("cloudSiteId", cloudSiteId);
    }
    if (tenantId != null) {
        builder.queryParam("tenantId", tenantId);
    }
    if (vfModuleName != null) {
        builder.queryParam("vfModuleName", vfModuleName);
    }
    builder.queryParam("skipAAI", skipAAI);
    if (requestId != null) {
        builder.queryParam("msoRequest.requestId", requestId);
    }
    if (serviceInstanceId != null) {
        builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
    }
    try {
        return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON).get(QueryVfModuleResponse.class).get();
    } catch (InternalServerErrorException e) {
        logger.error("InternalServerErrorException in queryVfModule", e);
        throw new VnfAdapterClientException(e.getMessage());
    }
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) QueryVfModuleResponse(org.onap.so.adapters.vnfrest.QueryVfModuleResponse) UriBuilder(javax.ws.rs.core.UriBuilder)

Example 2 with QueryVfModuleResponse

use of org.onap.so.adapters.vnfrest.QueryVfModuleResponse in project so by onap.

the class VnfAdapterClientIT method queryVfModuleTest.

@Test
public void queryVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
    QueryVfModuleResponse mockResponse = new QueryVfModuleResponse();
    mockResponse.setVnfId(AAI_VNF_ID);
    mockResponse.setVfModuleId(AAI_VF_MODULE_ID);
    wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID)).withQueryParam("vfModuleName", equalTo("someName")).withQueryParam("skipAAI", equalTo("true")).withQueryParam("msoRequest.requestId", equalTo("testRequestId")).withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
    QueryVfModuleResponse response = client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID, "someName", true, "testRequestId", "serviceInstanceId");
    assertEquals("Testing QueryVfModule response", AAI_VF_MODULE_ID, response.getVfModuleId());
}
Also used : QueryVfModuleResponse(org.onap.so.adapters.vnfrest.QueryVfModuleResponse) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

QueryVfModuleResponse (org.onap.so.adapters.vnfrest.QueryVfModuleResponse)2 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1 UriBuilder (javax.ws.rs.core.UriBuilder)1 Test (org.junit.Test)1 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)1 AdapterRestClient (org.onap.so.client.adapter.rest.AdapterRestClient)1