From 61b78a7d5f1eb8f1c5955d6d1439ce9225a39b46 Mon Sep 17 00:00:00 2001 From: Michal Kabaj Date: Mon, 17 Dec 2018 17:10:24 +0100 Subject: HttpClientFactory to create HttpClient instances -Replace constructor calls with existing factory -Add create methods to factory for each required Media Type Change-Id: Ibd03c10230c87a0413c0ec529e0ea9ac800444f9 Issue-ID: SO-1344 Signed-off-by: Michal Kabaj --- .../org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy | 2 +- .../onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'bpmn/MSOCommonBPMN/src/test/groovy/org') diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy index 723fb9e32e..d6a7cf0634 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy @@ -127,7 +127,7 @@ class CatalogDbUtilsTest { private void mockGetResponseFromCatalogDb(String queryEndpoint) { Environment environmentMock = createEnvironmentMock() when(environmentMock.getProperty("mso.catalog.db.endpoint")).thenReturn("http://testUrl") - when(httpClientFactoryMock.create(new URL(queryEndpoint), MediaType.APPLICATION_JSON, TargetEntity.CATALOG_DB)).thenReturn(httpClientMock) + when(httpClientFactoryMock.newJsonClient(new URL(queryEndpoint), TargetEntity.CATALOG_DB)).thenReturn(httpClientMock) Response responseMock = mock(Response.class) when(httpClientMock.get()).thenReturn(responseMock) diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy index 5f428f1f9f..db11cb6044 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy @@ -53,7 +53,7 @@ class ExternalAPIUtilTest { HttpClient httpClient = mock(HttpClient.class) given(httpClient.get()).willReturn(expectedResponse) HttpClientFactory httpClientFactory = mock(HttpClientFactory.class) - given(httpClientFactory.create(new URL(URL), MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL)).willReturn(httpClient) + given(httpClientFactory.newJsonClient(new URL(URL), TargetEntity.EXTERNAL)).willReturn(httpClient) // WHEN ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(httpClientFactory, new DummyMsoUtils(UUID_STR), new ExceptionUtil()) @@ -75,13 +75,14 @@ class ExternalAPIUtilTest { HttpClient httpClient = mock(HttpClient.class) willThrow(new RuntimeException("error occurred")).given(httpClient).get() HttpClientFactory httpClientFactory = mock(HttpClientFactory.class) - given(httpClientFactory.create(new URL(URL), MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL)).willReturn(httpClient) + given(httpClientFactory.newJsonClient(new URL(URL), TargetEntity.EXTERNAL)).willReturn(httpClient) DelegateExecution delegateExecution = createDelegateExecution() DummyExceptionUtil exceptionUtil = new DummyExceptionUtil() // WHEN ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(httpClientFactory, new DummyMsoUtils(UUID_STR), exceptionUtil) - BpmnError bpmnError = catchThrowableOfType({ -> externalAPIUtil.executeExternalAPIGetCall(delegateExecution, URL) + BpmnError bpmnError = catchThrowableOfType({ -> + externalAPIUtil.executeExternalAPIGetCall(delegateExecution, URL) }, BpmnError.class) // THEN @@ -96,7 +97,7 @@ class ExternalAPIUtilTest { HttpClient httpClient = mock(HttpClient.class) willThrow(new RuntimeException("error occurred")).given(httpClient).post(BODY_PAYLOAD) HttpClientFactory httpClientFactory = mock(HttpClientFactory.class) - given(httpClientFactory.create(new URL(URL), MediaType.APPLICATION_JSON, TargetEntity.AAI)).willReturn(httpClient) + given(httpClientFactory.newJsonClient(new URL(URL), TargetEntity.AAI)).willReturn(httpClient) DelegateExecution delegateExecution = createDelegateExecution() DummyExceptionUtil exceptionUtil = new DummyExceptionUtil() @@ -119,7 +120,7 @@ class ExternalAPIUtilTest { HttpClient httpClient = mock(HttpClient.class) given(httpClient.post(BODY_PAYLOAD)).willReturn(expectedResponse) HttpClientFactory httpClientFactory = mock(HttpClientFactory.class) - given(httpClientFactory.create(new URL(URL), MediaType.APPLICATION_JSON, TargetEntity.AAI)).willReturn(httpClient) + given(httpClientFactory.newJsonClient(new URL(URL), TargetEntity.AAI)).willReturn(httpClient) // WHEN ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(httpClientFactory, new DummyMsoUtils(UUID_STR), new ExceptionUtil()) -- cgit 1.2.3-korg