aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java139
1 files changed, 79 insertions, 60 deletions
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java
index 15753cd..ba95a85 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 IBM.
+ * ================================================================================
* 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
@@ -17,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dmaap.dbcapi.model;
import static org.junit.Assert.*;
@@ -26,67 +29,83 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
-
public class MRClientTest {
- private static final String fmt = "%24s: %s%n";
-
- ReflectionHarness rh = new ReflectionHarness();
-
- String d, t, f, c, m;
-
- @Before
- public void setUp() throws Exception {
- d = "central-onap";
- t = "org.onap.dmaap.interestingTopic";
- f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
- c = "publisher";
- m = "m12345";
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
-
- @Test
- public void test1() {
-
- // can't use simple reflection to test for null since null constructor initializes some fields.
- //rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );
- // so brute force instead...
- String[] a = { "put", "view" };
- MR_Client m = new MR_Client();
-
-
- assertTrue( null == m.getDcaeLocationName() );
- assertTrue( null == m.getFqtn() );
- assertTrue( null == m.getClientRole() );
- assertTrue( null == m.getAction() );
-
- }
-
- @Test
- public void test2() {
- String[] a = { "put", "view" };
- MR_Client m = new MR_Client( d, f, c, a );
-
-
- assertTrue( d.equals( m.getDcaeLocationName() ));
- assertTrue( f.equals( m.getFqtn() ));
- assertTrue( c.equals( m.getClientRole() ));
- String[] ma = m.getAction();
- assertTrue( a.length == ma.length );
- for( int i = 0; i < a.length; i++ ) {
- assertTrue( a[i].equals( ma[i] ) );
- }
- }
-
- @Test
- public void test3() {
-
- String v = "Validate";
- rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "set", v );
- }
+ private static final String fmt = "%24s: %s%n";
+
+ ReflectionHarness rh = new ReflectionHarness();
+
+ String d, t, f, c, m;
+
+ @Before
+ public void setUp() throws Exception {
+ d = "central-onap";
+ t = "org.onap.dmaap.interestingTopic";
+ f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
+ c = "publisher";
+ m = "m12345";
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void test1() {
+
+ // can't use simple reflection to test for null since null constructor
+ // initializes some fields.
+ // rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );
+ // so brute force instead...
+ String[] a = { "put", "view" };
+ MR_Client m = new MR_Client();
+
+ assertTrue(null == m.getDcaeLocationName());
+ assertTrue(null == m.getFqtn());
+ assertTrue(null == m.getClientRole());
+ assertTrue(null == m.getAction());
+
+ }
+
+ @Test
+ public void test2() {
+ String[] a = { "put", "view" };
+ MR_Client m = new MR_Client(d, f, c, a);
+
+ assertTrue(d.equals(m.getDcaeLocationName()));
+ assertTrue(f.equals(m.getFqtn()));
+ assertTrue(c.equals(m.getClientRole()));
+ String[] ma = m.getAction();
+ assertTrue(a.length == ma.length);
+ for (int i = 0; i < a.length; i++) {
+ assertTrue(a[i].equals(ma[i]));
+ }
+ }
+
+ @Test
+ public void test3() {
+
+ String v = "Validate";
+ rh.reflect("org.onap.dmaap.dbcapi.model.MR_Client", "set", v);
+ }
+
+ @Test
+ public void test4() {
+ MR_Client mrClient = new MR_Client();
+ String stringArray[] = { "test" };
+ mrClient.setAction(stringArray);
+ mrClient.hasAction("");
+ mrClient.setMrClientId("mrClientId");
+ mrClient.setTopicURL("testTopicURL");
+ mrClient.setClientIdentity("clientIdentity");
+
+ assertEquals("clientIdentity", mrClient.getClientIdentity());
+ assertEquals("testTopicURL", mrClient.getTopicURL());
+ assertEquals("mrClientId", mrClient.getMrClientId());
+ assertEquals(false, mrClient.isPublisher());
+ assertEquals(false, mrClient.isSubscriber());
+ assertEquals("test", mrClient.getAction()[0]);
+
+ }
}