summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/vfc/src
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-impl/vfc/src')
-rw-r--r--models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java43
1 files changed, 17 insertions, 26 deletions
diff --git a/models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java b/models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java
index 7874d2514..8db3438cc 100644
--- a/models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java
+++ b/models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* vfc
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.. All rights reserved.
* Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved.
* ================================================================================
@@ -23,12 +23,13 @@
package org.onap.policy.vfc;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.endsWith;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.startsWith;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
@@ -50,7 +51,6 @@ public class VfcManagerTest implements VfcCallback {
private RestManager mockedRestManager;
private Pair<Integer, String> httpResponsePutOk;
- private Pair<Integer, String> httpResponseGetOk;
private Pair<Integer, String> httpResponseBadResponse;
private Pair<Integer, String> httpResponseErr;
@@ -65,7 +65,6 @@ public class VfcManagerTest implements VfcCallback {
mockedRestManager = mock(RestManager.class);
httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response));
- httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response));
httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null));
httpResponseErr = mockedRestManager.new Pair<>(200, null);
}
@@ -131,9 +130,6 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "Exception");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(
startsWith(SOME_URL),
eq(DOROTHY),
@@ -143,7 +139,9 @@ public class VfcManagerTest implements VfcCallback {
anyString()))
.thenThrow(new RuntimeException("OzException"));
- managerThread.join();
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -151,14 +149,13 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "Null");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOME_URL),
eq(DOROTHY), eq("Null"), anyMap(), anyString(), anyString()))
.thenReturn(null);
- managerThread.join();
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -166,14 +163,13 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "Error0");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOME_URL),
eq(DOROTHY), eq("Error0"), anyMap(), anyString(), anyString()))
.thenReturn(httpResponseErr);
- managerThread.join();
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -181,14 +177,13 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "BadResponse");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOME_URL),
eq(DOROTHY), eq("OK"), anyMap(), anyString(), anyString()))
.thenReturn(httpResponseBadResponse);
- managerThread.join();
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -196,17 +191,13 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "Ok");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOME_URL),
eq(DOROTHY), eq("OK"), anyMap(), anyString(), anyString()))
.thenReturn(httpResponsePutOk);
- when(mockedRestManager.get(endsWith("1234"), eq(DOROTHY), eq("OK"), anyMap()))
- .thenReturn(httpResponseGetOk);
+ manager.run();
- managerThread.join();
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Override