aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/AafRoleTest.java47
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/AafUserRoleTest.java31
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/BrTopicTest.java59
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java4
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java139
5 files changed, 215 insertions, 65 deletions
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/AafRoleTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/AafRoleTest.java
new file mode 100644
index 0000000..c53d8c6
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/AafRoleTest.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dmaap.dbcapi.aaf;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class AafRoleTest {
+
+ AafRole aafRole;
+
+ @Before
+ public void setUp() {
+ aafRole = new AafRole("testNs", "testRole");
+ }
+
+ @Test
+ public void testAafRole() {
+ aafRole.setNamespace("namespace");
+ aafRole.setRole("role");
+ assertEquals("namespace", aafRole.getNamespace());
+ assertEquals("role", aafRole.getRole());
+ assertEquals("namespace.role", aafRole.getFullyQualifiedRole());
+ assertNotNull(aafRole.toJSON());
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/AafUserRoleTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/AafUserRoleTest.java
index 6328c21..88fff87 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/AafUserRoleTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/AafUserRoleTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2019 IBM 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
@@ -20,16 +22,37 @@
package org.onap.dmaap.dbcapi.aaf;
-import org.junit.Test;
-
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
public class AafUserRoleTest {
+ AafUserRole aafUserRole;
+
+ @Before
+ public void setUp() {
+ aafUserRole = new AafUserRole("xyz", "admin");
+ }
+
+ @Test
+ public void testGetIdentity() {
+ aafUserRole.setIdentity("xyz");
+ assertEquals("xyz", aafUserRole.getIdentity());
+ }
+
+ @Test
+ public void testGetRole() {
+ aafUserRole.setRole("admin");
+ assertEquals("admin", aafUserRole.getRole());
+ }
+
@Test
public void toJSON() {
- AafUserRole role = new AafUserRole("test","admin");
+ AafUserRole role = new AafUserRole("test", "admin");
assertThat(role.toJSON(), is(" { \"user\": \"test\", \"role\": \"admin\" }"));
}
} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/BrTopicTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/BrTopicTest.java
new file mode 100644
index 0000000..11e7c85
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/BrTopicTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dmaap.dbcapi.model;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class BrTopicTest {
+
+ BrTopic brTopic;
+
+ @Before
+ public void setUp() {
+ brTopic = new BrTopic();
+ }
+
+ @Test
+ public void testGetBrSource() {
+ brTopic.setBrSource("brSource");
+ assertEquals("brSource", brTopic.getBrSource());
+ }
+
+ @Test
+ public void testGetBrTarget() {
+ brTopic.setBrTarget("brTarget");
+ assertEquals("brTarget", brTopic.getBrTarget());
+ }
+
+ @Test
+ public void testGetTopicCount() {
+ brTopic.setTopicCount(1);
+ assertEquals(1, brTopic.getTopicCount());
+ }
+
+ @Test
+ public void testGetMmAgentName() {
+ brTopic.setMmAgentName("Test");
+ assertEquals("Test", brTopic.getMmAgentName());
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java
index 480ff07..59a4023 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/DRSubTest.java
@@ -69,7 +69,7 @@ public class DRSubTest {
assertTrue( t.isGuaranteedDelivery() == false );
assertTrue( t.isGuaranteedSequence() == false );
assertTrue( t.isPrivilegedSubscriber() == false );
-
+ assertTrue( t.isDecompressData() == false );
}
@Test
@@ -113,6 +113,8 @@ public class DRSubTest {
assertTrue( t.isGuaranteedSequence() == v );
t.setPrivilegedSubscriber(v);
assertTrue( t.isPrivilegedSubscriber() == v );
+ t.setDecompressData(v);
+ assertTrue( t.isDecompressData() == v );
}
@Test
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]);
+
+ }
}