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);
}
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());
}
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);
}
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);
}
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());
}
}
Aggregations