import org.mockserver.model.HttpRequest.request
import org.mockserver.model.HttpResponse.response
import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BaseBlueprintWebClientService
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import java.nio.charset.Charset
import java.util.Base64
-class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties) : BlueprintWebClientService {
+class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties) :
+ BaseBlueprintWebClientService<RestClientProperties>() {
+
private var mockServer: ClientAndServer
private var port: String = if (restClientProperties.url.split(":")[2].isEmpty()) "8080"
else restClientProperties.url.split(":")[2]
headers = defaultHeaders()
// Create expected requests and responses
- setRequest("GET", "/aai/v14/network/generic-vnfs/generic-vnf/123456")
+ setRequest("GET", "/aai/v22/network/generic-vnfs/generic-vnf/123456")
setRequest(
- "GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" +
- "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name"
+ "GET",
+ "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" +
+ "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name"
)
setRequestWithPayload(
"PUT", "/query",
)
}
+ override fun getRestClientProperties(): RestClientProperties {
+ return restClientProperties
+ }
+
override fun defaultHeaders(): Map<String, String> {
val encodedCredentials = this.setBasicAuth("admin", "aaiTest")
return mapOf(
)
}
- override fun host(uri: String): String {
- return restClientProperties.url + uri
- }
-
fun tearDown() {
mockServer.close()
}
- override fun exchangeResource(method: String, path: String, payload: String): BlueprintWebClientService.WebClientResponse<String> {
+ override fun exchangeResource(
+ method: String,
+ path: String,
+ payload: String
+ ): BlueprintWebClientService.WebClientResponse<String> {
val header = arrayOf(BasicHeader(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
return when (method) {
"POST" -> {