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