Search in sources :

Example 6 with AdapterRestClient

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

the class VnfVolumeAdapterClientIT method rollbackVolumeGroupTestThrowException.

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

Example 7 with AdapterRestClient

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

the class VnfVolumeAdapterClientIT method rollbackVolumeGroupTest.

@Test
public void rollbackVolumeGroupTest() throws VnfAdapterClientException {
    RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
    RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
    mockResponse.setVolumeGroupRolledBack(true);
    VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
    AdapterRestClient mockClient = mock(AdapterRestClient.class);
    doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
    when(mockClient.delete(request, RollbackVolumeGroupResponse.class)).thenReturn(mockResponse);
    MockitoAnnotations.initMocks(this);
    RollbackVolumeGroupResponse response = client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
    assertEquals("Testing RollbackVolumeGroup response", mockResponse.getVolumeGroupRolledBack(), response.getVolumeGroupRolledBack());
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) RollbackVolumeGroupRequest(org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest) RollbackVolumeGroupResponse(org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Example 8 with AdapterRestClient

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

the class VnfVolumeAdapterClientIT method updateVolumeGroupTestThrowException.

@Test(expected = VnfAdapterClientException.class)
public void updateVolumeGroupTestThrowException() 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)).thenThrow(new InternalServerErrorException("Error in update volume group"));
    MockitoAnnotations.initMocks(this);
    client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) UpdateVolumeGroupResponse(org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) UpdateVolumeGroupRequest(org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Example 9 with AdapterRestClient

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

the class VnfVolumeAdapterClientIT method createVolumeGroupTestThrowException.

@Test(expected = VnfAdapterClientException.class)
public void createVolumeGroupTestThrowException() 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)).thenThrow(new InternalServerErrorException("Error in create volume group"));
    client.createVNFVolumes(request);
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) CreateVolumeGroupResponse(org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Example 10 with AdapterRestClient

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

the class NetworkAdapterClientImpl method queryNetwork.

@Override
public QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId, String networkStackId, boolean skipAAI, String requestId, String serviceInstanceId) throws NetworkAdapterClientException {
    UriBuilder builder = this.getUri("/" + aaiNetworkId);
    if (cloudSiteId != null) {
        builder.queryParam("cloudSiteId", cloudSiteId);
    }
    if (tenantId != null) {
        builder.queryParam("tenantId", tenantId);
    }
    if (networkStackId != null) {
        builder.queryParam("networkStackId", networkStackId);
    }
    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_XML, MediaType.APPLICATION_XML).get(QueryNetworkResponse.class).get();
    } catch (InternalServerErrorException e) {
        throw new NetworkAdapterClientException(e.getMessage());
    }
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) QueryNetworkResponse(org.onap.so.adapters.nwrest.QueryNetworkResponse) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) UriBuilder(javax.ws.rs.core.UriBuilder)

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