public class AaiGetServiceInstanceClient implements
AaiHttpClient<AaiServiceInstanceQueryModel, HttpResponse> {
- //variables for query "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}"
private static final String CUSTOMER = "customer";
private static final String SERVICE_TYPE = "serviceType";
private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
}
private String getUri(final String endpoint) {
- return new URI.URIBuilder().path(configuration.pnfUrl() + endpoint).build().toString();
+ return new URI.URIBuilder().path(configuration.baseUrl() + endpoint).build().toString();
}
}
.keyStorePasswordPath("/server.pass")
.enableAaiCertAuth(secure)
.aaiHeaders(headers)
- .aaiServiceInstancePath("sample-instance-path")
+ .aaiServiceInstancePath("/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}")
.build();
}
}
\ No newline at end of file
class AaiGetServiceInstanceClientTest extends AbstractHttpClientTest {
+ public static final String SERVICE_INSTANCE_PATH = "https://aai.onap.svc.cluster.local:8443/aai/v12/business/customers/customer/Demonstration/"
+ + "service-subscriptions/service-subscription/VCPE/service-instances/service-instance/df018f76-7fc8-46ab-8444-7d67e1efc284";
+
@Test
void getAaiResponse_shouldCallGetMethod_withGivenAaiHeaders() {
AaiGetServiceInstanceClient cut = new AaiGetServiceInstanceClient(secureConfiguration(headers.toJavaMap()),
httpClient);
+ given(model.customerId()).willReturn("Demonstration");
+ given(model.serviceInstanceId()).willReturn("df018f76-7fc8-46ab-8444-7d67e1efc284");
+ given(model.serviceType()).willReturn("VCPE");
+
given(httpClient.call(any(HttpRequest.class)))
.willReturn(Mono.just(response));
//then
verify(httpClient)
- .call(argThat(httpRequest -> httpRequest.customHeaders().equals(headers)));
+ .call(argThat(httpRequest -> httpRequest.customHeaders().equals(headers) &&
+ httpRequest.url().equals(SERVICE_INSTANCE_PATH)));
}
}