summaryrefslogtreecommitdiffstats
path: root/common/src/test/java/org
diff options
context:
space:
mode:
authorBenjamin, Max <max.benjamin@att.com>2019-06-26 11:26:55 -0400
committerMax Benjamin <max.benjamin@att.com>2019-06-27 16:09:30 +0000
commit577bd39ac9e9495b0c6a38e6f7c567acfcba1c42 (patch)
tree267d3ce07458957189630ddf015338279256f2a6 /common/src/test/java/org
parent5c58eeca5ffd8b080b9af7619a903eb0acff3a0d (diff)
Update failsafe dependency to 2.0.1
Updated calls to failsafe 2.0.1 API Change-Id: I2c86ca02d56a07262e330ee5f8f088d1a1f5b4a7 Issue-ID: SO-2057 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'common/src/test/java/org')
-rw-r--r--common/src/test/java/org/onap/so/client/RestClientTest.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java
index b550079607..745dee23e8 100644
--- a/common/src/test/java/org/onap/so/client/RestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/RestClientTest.java
@@ -22,24 +22,24 @@ package org.onap.so.client;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriBuilderException;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import org.mockito.ArgumentMatchers;
-import org.onap.so.utils.TargetEntity;
+import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.utils.TargetEntity;
@RunWith(MockitoJUnitRunner.class)
public class RestClientTest {
@@ -49,34 +49,34 @@ public class RestClientTest {
@Mock
private RestProperties props;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
@Test
public void retries() throws Exception {
RestClient spy = buildSpy();
- RestRequest mockCallable = mock(RestRequest.class);
- when(mockCallable.call()).thenThrow(new WebApplicationException(new SocketTimeoutException()));
- doReturn(mockCallable).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull());
+ doThrow(new WebApplicationException(new SocketTimeoutException())).when(spy).buildRequest(any(String.class),
+ ArgumentMatchers.isNull());
try {
spy.get();
} catch (Exception e) {
- // we expect an exception, ignore it
+ // ignore this exception for this test
}
- verify(mockCallable, times(3)).call();
+ verify(spy, times(3)).buildRequest(any(String.class), ArgumentMatchers.isNull());
}
@Test
public void exceptionDoNotRetry() throws Exception {
RestClient spy = buildSpy();
- RestRequest mockCallable = mock(RestRequest.class);
- when(mockCallable.call()).thenThrow(new WebApplicationException(new NotFoundException()));
- doReturn(mockCallable).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull());
+ doThrow(new WebApplicationException(new NotFoundException())).when(spy).buildRequest(any(String.class),
+ ArgumentMatchers.isNull());
try {
spy.get();
} catch (Exception e) {
// we expect an exception, ignore it
}
- verify(mockCallable, times(1)).call();
+ verify(spy, times(1)).buildRequest(any(String.class), ArgumentMatchers.isNull());
}