+ @Test
+ public void testDeleteWhiteListMirrorMakerPermissionError() {
+ prepareForTestCommon();
+ PowerMockito
+ .when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf.create"))
+ .thenReturn(null);
+ String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
+ InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
+ try {
+ mmRestService.deleteWhiteList(inputSteam);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ }
+
+
+ @Test
+ public void testDeleteWhiteListMirrorMakerAafPermissionError() {
+ prepareForTestCommon();
+ PowerMockito
+ .when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf"))
+ .thenReturn(null);
+ String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
+ InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
+ try {
+ mmRestService.deleteWhiteList(inputSteam);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ }
+
+
+ @Test
+ public void testDeleteWhiteListJsonError() {
+ prepareForTestCommon();
+
+ String sampleJson = "{ namespace:\"test\", whitelistTopicName:\"test\"}}";
+ InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
+ try {
+ mmRestService.deleteWhiteList(inputSteam);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testDeleteWhiteListJsonFormattingError() {
+ prepareForTestCommon();
+
+ String sampleJson = "{ : namespace:\"test\", whitelistTopicName:\"test\"}}";
+ InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
+ try {
+ mmRestService.deleteWhiteList(inputSteam);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testCallPubSubForWhitelist() {
+ prepareForTestCommon();
+
+ String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
+ try {
+ PowerMockito.when(mmservice.subscribe(any(), anyString(), anyString(), anyString())).thenReturn(msgSubscribe);
+ mmRestService.callPubSubForWhitelist("test123", dmaapContext, inputSteam, new JSONObject (sampleJson)) ;
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testCallPubSub() {
+ prepareForTestCommon();
+
+ String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
+ try {
+ PowerMockito.when(mmservice.subscribe(any(), anyString(), anyString(), anyString())).thenReturn(msgSubscribe);
+ mmRestService.callPubSub("test123", dmaapContext, inputSteam, "test", false) ;
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testCallPubSubForWhitelistNoMsgFromSubscribe() {
+ prepareForTestCommon();
+
+ String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
+ InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
+ try {
+ PowerMockito.when(mmservice.subscribe(any(), anyString(), anyString(), anyString())).thenReturn(null);
+ mmRestService.callPubSubForWhitelist("test123", dmaapContext, inputSteam, new JSONObject (sampleJson)) ;
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testGetListMirrorMaker() {
+ prepareForTestCommon();
+
+ String sampleJson = "[{ messageID:\"test123\", listMirrorMaker:[\"test\"]}]";
+ try {
+ mmRestService.getListMirrorMaker(sampleJson, "test123");
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+