summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsunil.unnava <sunil.unnava@att.com>2019-04-02 18:56:40 -0400
committersunil.unnava <sunil.unnava@att.com>2019-04-02 18:56:57 -0400
commit49924c6b07a7f9418f04d09f9c94fac8e7d44485 (patch)
tree4284dc7af194cc0e74b556a25e624d2030ed241b /src
parentdeaef554cc6ac0025a088b6c11ce82b85fd89083 (diff)
add testcases
Issue-ID: DMAAP-1140 Change-Id: Ib2a91bd5961050c11f20f8a10f856d21bcda7e30 Signed-off-by: sunil.unnava <sunil.unnava@att.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/beans/DMaaPKafkaMetaBroker.java5
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java32
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest.java17
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java25
4 files changed, 68 insertions, 11 deletions
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/beans/DMaaPKafkaMetaBroker.java b/src/main/java/org/onap/dmaap/dmf/mr/beans/DMaaPKafkaMetaBroker.java
index 1e20ee2..03a1bd5 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/beans/DMaaPKafkaMetaBroker.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/beans/DMaaPKafkaMetaBroker.java
@@ -39,7 +39,7 @@ import org.apache.kafka.common.KafkaFuture;
import org.json.JSONObject;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Qualifier;
-
+import org.springframework.util.StringUtils;
import org.onap.dmaap.dmf.mr.CambriaApiException;
import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
import org.onap.dmaap.dmf.mr.metabroker.Broker1;
@@ -53,6 +53,7 @@ import com.att.nsa.configs.ConfigDb;
import com.att.nsa.configs.ConfigDbException;
import com.att.nsa.configs.ConfigPath;
import com.att.nsa.drumlin.service.standards.HttpStatusCodes;
+import com.att.nsa.drumlin.till.data.stringUtils;
import com.att.nsa.drumlin.till.nv.rrNvReadable;
import com.att.nsa.security.NsaAcl;
import com.att.nsa.security.NsaAclUtils;
@@ -75,7 +76,7 @@ public class DMaaPKafkaMetaBroker implements Broker1 {
final Properties props = new Properties ();
String fkafkaBrokers = com.att.ajsc.filemonitor.AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,
"kafka.metadata.broker.list");
- if (null == fkafkaBrokers) {
+ if (StringUtils.isEmpty(fkafkaBrokers)) {
fkafkaBrokers = "localhost:9092";
}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java
index 35f3064..0f4702a 100644
--- a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
- package org.onap.dmaap.mr.cambria.beans;
+package org.onap.dmaap.mr.cambria.beans;
import static org.junit.Assert.assertTrue;
@@ -41,6 +41,7 @@ import org.onap.dmaap.dmf.mr.CambriaApiException;
import org.apache.kafka.clients.admin.AdminClient;
import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker.KafkaTopic;
import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
import org.onap.dmaap.dmf.mr.metabroker.Topic;
import org.onap.dmaap.dmf.mr.metabroker.Broker1.TopicExistsException;
@@ -48,9 +49,8 @@ import com.att.nsa.configs.ConfigDb;
import com.att.nsa.configs.ConfigDbException;
import com.att.nsa.configs.ConfigPath;
-
@RunWith(PowerMockRunner.class)
-@PrepareForTest({ AdminClient.class})
+@PrepareForTest({ AdminClient.class })
public class DMaaPKafkaMetaBrokerTest {
@InjectMocks
@@ -74,11 +74,28 @@ public class DMaaPKafkaMetaBrokerTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
PowerMockito.mockStatic(AdminClient.class);
- //PowerMockito.when(AdminClient.create (any(Properties.class) )).thenReturn(fKafkaAdminClient);
-
- //PowerMockito.mockStatic(AdminUtils.class);
+ // PowerMockito.when(AdminClient.create (any(Properties.class)
+ // )).thenReturn(fKafkaAdminClient);
+
+ // PowerMockito.mockStatic(AdminUtils.class);
PowerMockito.when(configDb.parse("/topics")).thenReturn(fBaseTopicData);
-
+
+ }
+
+ @Test
+ public void testBrokercreate() {
+ DMaaPKafkaMetaBroker broker = new DMaaPKafkaMetaBroker();
+
+ }
+
+ @Test
+ public void testcreateTopicEntry() {
+ try {
+ KafkaTopic kafkaTopic = new KafkaTopic("topics", configDb, fBaseTopicData);
+ dMaaPKafkaMetaBroker.createTopicEntry("name", "desc", "owner", true);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
}
@@ -108,7 +125,6 @@ public class DMaaPKafkaMetaBrokerTest {
}
}
-
@Test
public void testcreateTopic_wrongPartition() {
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest.java
index 8d83821..8cab96a 100644
--- a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest.java
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest.java
@@ -65,6 +65,23 @@ public class LogDetailsTest {
assertEquals(details.getSubscriberGroupId(),"1");
}
+ @Test
+ public void testPublisherdetails(){
+ LogDetails details = new LogDetails();
+ assertNotNull(details.getPublisherLogDetails());
+ assertNull(details.getTransactionIdTs());
+ assertFalse(details.isTransactionEnabled());
+ assertEquals(details.getMessageLengthInBytes(),0);
+ assertNotNull(details.getPublishTimestamp());
+ assertNull(details.getMessageTimestamp());
+ assertNull(details.getMessageSequence());
+ assertNull(details.getMessageBatchId());
+ assertNull(details.getPublisherIp());
+ assertNull(details.getTopicId());
+
+
+ }
+
}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java
index 970bc60..3b556fb 100644
--- a/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java
@@ -22,6 +22,9 @@
import static org.junit.Assert.*;
+import java.io.IOException;
+
+import org.json.JSONException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -29,6 +32,7 @@ import org.junit.Test;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream;
+import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream.operation;
public class CambriaOutboundEventStreamTest {
@@ -63,7 +67,26 @@ public class CambriaOutboundEventStreamTest {
@Test
public void testForEachMessage() {
- //fail("Not yet implemented");
+ try {
+ coes.forEachMessage(new operation(){
+
+ @Override
+ public void onWait() throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onMessage(int count, String msg, String transId, long offSet)
+ throws IOException, JSONException {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ }
}
@Test