Search in sources :

Example 1 with AdapterRestClient

use of org.onap.so.client.adapter.rest.AdapterRestClient 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 AdapterRestClient

use of org.onap.so.client.adapter.rest.AdapterRestClient in project so by onap.

the class VnfVolumeAdapterClientIT method updateVolumeGroupTest.

@Test
public void updateVolumeGroupTest() throws VnfAdapterClientException {
    UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
    UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
    mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
    VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
    AdapterRestClient mockClient = mock(AdapterRestClient.class);
    doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
    when(mockClient.put(request, UpdateVolumeGroupResponse.class)).thenReturn(mockResponse);
    MockitoAnnotations.initMocks(this);
    UpdateVolumeGroupResponse response = client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
    assertEquals("Testing DeleteVfModule response", mockResponse.getVolumeGroupId(), response.getVolumeGroupId());
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) UpdateVolumeGroupResponse(org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse) UpdateVolumeGroupRequest(org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Example 3 with AdapterRestClient

use of org.onap.so.client.adapter.rest.AdapterRestClient in project so by onap.

the class VnfVolumeAdapterClientIT method deleteVolumeGroupTestThrowException.

@Test(expected = VnfAdapterClientException.class)
public void deleteVolumeGroupTestThrowException() throws VnfAdapterClientException {
    DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
    request.setCloudSiteId(TESTING_ID);
    DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
    mockResponse.setVolumeGroupDeleted(true);
    VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
    AdapterRestClient mockClient = mock(AdapterRestClient.class);
    doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
    when(mockClient.delete(request, DeleteVolumeGroupResponse.class)).thenThrow(new InternalServerErrorException("Error in delete volume group"));
    MockitoAnnotations.initMocks(this);
    client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) DeleteVolumeGroupRequest(org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) DeleteVolumeGroupResponse(org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Example 4 with AdapterRestClient

use of org.onap.so.client.adapter.rest.AdapterRestClient in project so by onap.

the class VnfVolumeAdapterClientIT method deleteVolumeGroupTest.

@Test
public void deleteVolumeGroupTest() throws VnfAdapterClientException {
    DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
    request.setCloudSiteId(TESTING_ID);
    DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
    mockResponse.setVolumeGroupDeleted(true);
    VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
    AdapterRestClient mockClient = mock(AdapterRestClient.class);
    doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
    when(mockClient.delete(request, DeleteVolumeGroupResponse.class)).thenReturn(mockResponse);
    MockitoAnnotations.initMocks(this);
    DeleteVolumeGroupResponse response = client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
    assertEquals("Testing DeleteVolumeGroup response", mockResponse.getVolumeGroupDeleted(), response.getVolumeGroupDeleted());
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) DeleteVolumeGroupRequest(org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest) DeleteVolumeGroupResponse(org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Example 5 with AdapterRestClient

use of org.onap.so.client.adapter.rest.AdapterRestClient in project so by onap.

the class VnfVolumeAdapterClientIT method createVolumeGroupTest.

@Test
public void createVolumeGroupTest() throws VnfAdapterClientException {
    CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
    request.setCloudSiteId(TESTING_ID);
    CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
    mockResponse.setVolumeGroupCreated(true);
    VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
    AdapterRestClient mockClient = mock(AdapterRestClient.class);
    doReturn(mockClient).when(client).getAdapterRestClient("");
    when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenReturn(mockResponse);
    CreateVolumeGroupResponse response = client.createVNFVolumes(request);
    assertEquals("Testing CreateVolumeGroup response", mockResponse.getVolumeGroupCreated(), response.getVolumeGroupCreated());
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) CreateVolumeGroupResponse(org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Aggregations

AdapterRestClient (org.onap.so.client.adapter.rest.AdapterRestClient)10 Test (org.junit.Test)8 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)8 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)6 UriBuilder (javax.ws.rs.core.UriBuilder)2 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)2 CreateVolumeGroupResponse (org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse)2 DeleteVolumeGroupRequest (org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest)2 DeleteVolumeGroupResponse (org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse)2 RollbackVolumeGroupRequest (org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest)2 RollbackVolumeGroupResponse (org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse)2 UpdateVolumeGroupRequest (org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest)2 UpdateVolumeGroupResponse (org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse)2 QueryNetworkResponse (org.onap.so.adapters.nwrest.QueryNetworkResponse)1 QueryVfModuleResponse (org.onap.so.adapters.vnfrest.QueryVfModuleResponse)1