* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
+import com.att.ajsc.beans.PropertiesMapBean;
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.NsaAcl;
+import com.att.nsa.security.NsaApiKey;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
import java.io.ByteArrayInputStream;
-
-//import static org.mockito.Matchers.anyString;
-//import static org.mockito.Mockito.when;
-
-import java.io.IOException;
import java.io.InputStream;
-
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
-import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
import org.onap.dmaap.dmf.mr.metabroker.Topic;
import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator;
import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticatorImpl;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import com.att.ajsc.beans.PropertiesMapBean;
-import com.att.ajsc.filemonitor.AJSCPropertiesMap;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.NsaAcl;
-import com.att.nsa.security.NsaApiKey;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;
-
//@RunWith(MockitoJUnitRunner.class)
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("jdk.internal.reflect.*")
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
try {
prepareForTestCommon();
} catch (Exception e) {
-
+
}
// String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallCreateMirrorMaker_error1() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
+
}
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallListAllMirrorMaker() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallUpdateMirrorMaker() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallUpdateMirrorMaker_error1() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
public void testCallUpdateMirrorMaker_error2() {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
public void testCallUpdateMirrorMaker_error3() {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
public void testCallUpdateMirrorMaker_error4() {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeradmin.aaf"))
.thenReturn(null);
-
+
String sampleJson = "{ messageID:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
try {
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallDeleteMirrorMaker() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCallDeleteMirrorMakerAafPermissionError() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
-
+
+
@Test
public void testListWhiteList() {
prepareForTestCommon();
String sampleJson = "{ name:\"test\", namespace:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
try {
PowerMockito.when(mmservice.subscribe(any(), anyString(), anyString(), anyString())).thenReturn(msgSubscribe);
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
String sampleJson = "{ name:\"test\", namespace:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
try {
PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf"))
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
String sampleJson = "{ name:\"test\", namespace:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
try {
PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf.create"))
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
public void testListWhiteListJSONError() {
String sampleJson = "{ namespace:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
try {
mmRestService.listWhiteList(inputSteam);
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
-
-
-
+
+
+
+
@Test
public void testCreateWhiteList() {
prepareForTestCommon();
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
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());
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testCreateWhiteListAafPermissionError() {
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());
} catch (Exception e) {
assertTrue(true);
}
-
- }
-
+
+ }
+
@Test
public void testCreateWhiteListJSONError() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
- }
-
+
+ }
+
@Test
public void testDeleteWhiteList() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
+
}
@Test
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
+
@Test
public void testDeleteWhiteListMirrorMakerAafPermissionError() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
+
}
-
-
+
+
@Test
public void testDeleteWhiteListJsonError() {
prepareForTestCommon();
} catch (Exception e) {
assertTrue(true);
}
-
- }
-
+
+ }
+
@Test
public void testDeleteWhiteListJsonFormattingError() {
prepareForTestCommon();
} 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\"}]}]";
+ String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"test\"}]}]";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
try {
PowerMockito.when(mmservice.subscribe(any(), anyString(), anyString(), anyString())).thenReturn(msgSubscribe);
assertTrue(true);
}
}
-
+
@Test
public void testCallPubSub() {
prepareForTestCommon();
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
- String msgSubscribe = "[{ messageID:\"test123\", listMirrorMaker:[ {name: \"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);
assertTrue(true);
}
}
-
+
@Test
public void testCallPubSubForWhitelistNoMsgFromSubscribe() {
prepareForTestCommon();
-
+
String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
try {
@Test
public void testGetListMirrorMaker() {
prepareForTestCommon();
-
- String sampleJson = "[{ messageID:\"test123\", listMirrorMaker:[\"test\"]}]";
+
+ String sampleJson = "[{ messageID:\"test123\", listMirrorMaker:[\"test\"]}]";
try {
mmRestService.getListMirrorMaker(sampleJson, "test123");
} catch (Exception e) {
assertTrue(true);
- }
+ }
}
-
+
private void prepareForTestCommon() {
Assert.assertNotNull(mmRestService);
try {
PowerMockito.when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);
} catch (ConfigDbException e) {
-
+
}
}