summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDriptaroop Das <driptaroop.das@in.ibm.com>2019-01-17 16:17:05 +0530
committerDriptaroop Das <driptaroop.das@in.ibm.com>2019-01-17 16:49:19 +0530
commitff320e967ab3bdd9770314f9012ecb9eb3cdfa6c (patch)
treef920b7e5428830cd7d57b1b6e9b35c44aa889b99 /src
parent274a042cbc88a65a922e24cde69d9b7b55c25b2c (diff)
Junit for UpdateMirrorMaker.java
Junit for UpdateMirrorMaker.java Issue-ID: DMAAP-972 Change-Id: I7939d254236b317804adcd131b915a99533c9a26 Signed-off-by: Driptaroop Das <driptaroop.das@in.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/test/java/org/onap/dmaap/mmagent/UpdateMirrorMakerTest.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/java/org/onap/dmaap/mmagent/UpdateMirrorMakerTest.java b/src/test/java/org/onap/dmaap/mmagent/UpdateMirrorMakerTest.java
index 1826026..6fceff1 100644
--- a/src/test/java/org/onap/dmaap/mmagent/UpdateMirrorMakerTest.java
+++ b/src/test/java/org/onap/dmaap/mmagent/UpdateMirrorMakerTest.java
@@ -22,14 +22,43 @@
import static org.junit.Assert.*;
+import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+@RunWith(PowerMockRunner.class)
public class UpdateMirrorMakerTest {
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ MirrorMaker mirrorMaker;
+ UpdateMirrorMaker updateMirrorMaker;
+ JSONObject jsonObject;
+
@Before
public void setUp() throws Exception {
+ mirrorMaker = new MirrorMaker();
+ updateMirrorMaker = new UpdateMirrorMaker();
+ jsonObject = PowerMockito.mock(JSONObject.class);
+
+ mirrorMaker.setConsumer("test");
+ PowerMockito.when(jsonObject.has("consumer")).thenReturn(true);
+
+ mirrorMaker.setProducer("test");
+ PowerMockito.when(jsonObject.has("producer")).thenReturn(true);
+
+ mirrorMaker.setNumStreams(1);
+ PowerMockito.when(jsonObject.has("numStreams")).thenReturn(true);
+
+ PowerMockito.when(jsonObject.has("whitelist")).thenReturn(true);
}
@After
@@ -77,5 +106,32 @@ public class UpdateMirrorMakerTest {
}
+ @Test(expected = CambriaApiException.class)
+ public void testValidateJSONNullConsumer() throws CambriaApiException {
+ mirrorMaker.setConsumer(null);
+ updateMirrorMaker.setUpdateMirrorMaker(mirrorMaker);
+ updateMirrorMaker.validateJSON(jsonObject);
+ }
+ @Test(expected = CambriaApiException.class)
+ public void testValidateJSONNullProducer() throws CambriaApiException {
+ mirrorMaker.setProducer(null);
+ updateMirrorMaker.setUpdateMirrorMaker(mirrorMaker);
+ updateMirrorMaker.validateJSON(jsonObject);
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testValidateJSONNoNumStreams() throws CambriaApiException {
+ mirrorMaker.setNumStreams(0);
+ updateMirrorMaker.setUpdateMirrorMaker(mirrorMaker);
+ updateMirrorMaker.validateJSON(jsonObject);
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testValidateJSONWhitelist() throws CambriaApiException {
+ PowerMockito.when(jsonObject.has("whitelist")).thenReturn(true);
+
+ updateMirrorMaker.setUpdateMirrorMaker(mirrorMaker);
+ updateMirrorMaker.validateJSON(jsonObject);
+ }
} \ No newline at end of file