summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorMichal Kabaj <michal.kabaj@nokia.com>2018-12-17 17:10:24 +0100
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-01-04 12:02:36 +0000
commit61b78a7d5f1eb8f1c5955d6d1439ce9225a39b46 (patch)
tree4f6ab37c32786ad489f6d8f2130d1b03105f8c32 /bpmn/MSOCommonBPMN/src/test/groovy/org/onap
parent85a47c701c3b34c58d2b121ba466d41ffb4fb7b0 (diff)
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 <michal.kabaj@nokia.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/groovy/org/onap')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy11
2 files changed, 7 insertions, 6 deletions
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())