summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2018-08-20 15:45:03 +0200
committerWojciech Sliwka <wojciech.sliwka@nokia.com>2018-08-24 12:26:03 +0200
commit17e8b54e83547d8dc37c335c5df1b989f8b5ff3c (patch)
tree87201581f26048e7c88a1d9339392f7c11d05b8e /vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java
parent5adc0b0ee92d1e39ddaacd27e67a327dd5988f11 (diff)
Replace sdc client
Replace old SDC client to use genericRestClient Change-Id: I9b3b567871ac3f319742fca9457e42b6d4db0a8a Issue-ID: VID-268 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java69
1 files changed, 0 insertions, 69 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java
deleted file mode 100644
index 75b84b2d..00000000
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.onap.vid.asdc.rest;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.onap.vid.testUtils.TestUtils;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.client.Client;
-import java.net.URI;
-import java.util.UUID;
-import java.util.function.Consumer;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-import static org.testng.AssertJUnit.fail;
-
-public class RestfulAsdcClientTest {
-
- @DataProvider
- public static Object[][] javaxExceptions() {
-
- return new Object[][] {
- {NotFoundException.class, (Consumer<Client>) javaxClientMock ->
- when(javaxClientMock.target(any(URI.class))).thenThrow(
- new NotFoundException("HTTP 404 Not Found"))},
- {ProcessingException.class, (Consumer<Client>) javaxClientMock ->
- when(javaxClientMock.target(any(URI.class))).thenThrow(
- new ProcessingException("java.net.ConnectException: Connection refused: connect"))},
- };
- }
-
-
- @Test(dataProvider = "javaxExceptions")
- public void whenJavaxClientThrowException_thenExceptionRethrown(Class<? extends Throwable> expectedType, Consumer<Client> setupMocks) throws Exception {
- /*
- Call chain is like:
- this test -> RestfulAsdcClient -> javax's Client
-
- In this test, *RestfulAsdcClient* is under test (actual implementation is used), while javax's Client is
- mocked to return pseudo-responses or - better - throw exceptions.
- */
-
- // prepare mocks
- TestUtils.JavaxRsClientMocks mocks = new TestUtils.JavaxRsClientMocks();
- Client javaxClientMock = mocks.getFakeClient();
-
- // prepare real RestfulAsdcClient (Under test)
- RestfulAsdcClient restfulAsdcClient = new RestfulAsdcClient.Builder(javaxClientMock, new URI(""))
- .auth("")
- .build();
-
- /// TEST:
- setupMocks.accept(javaxClientMock);
-
- try {
- restfulAsdcClient.getServiceToscaModel(UUID.randomUUID());
- } catch (Exception e) {
- assertThat("root cause incorrect for " + ExceptionUtils.getStackTrace(e), ExceptionUtils.getRootCause(e), instanceOf(expectedType));
- return; //OK
- }
-
- fail("exception shall rethrown by getServiceToscaModel once javax client throw exception ");
- }
-
-}