X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fmodel%2FMR_ClusterTest.java;h=514e0d1a1a2c672853a3997e90b5e944d1499db9;hb=bfe1f5204aa40a4178c005f23e530401b991ac58;hp=ac7f9c43a17f1094efedb509a46caecd6873d705;hpb=503da874ce876dbe463bcc1a03f63ea0f48fe650;p=dmaap%2Fdbcapi.git diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java index ac7f9c4..514e0d1 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java @@ -28,8 +28,9 @@ import java.lang.reflect.Method; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class MR_ClusterTest { - String d, fqdn, a; + String d, fqdn, repGrp, p1, p2, prot, p0; ReflectionHarness rh = new ReflectionHarness(); @@ -37,7 +38,14 @@ public class MR_ClusterTest { public void setUp() throws Exception { d = "central-onap"; fqdn = "mr.onap.org"; - a = "ignore"; + repGrp = "zeppelin"; + prot = "http"; + p0 = "3904"; + p1 = "9092"; + p2 = "2323"; + + + } @After @@ -58,26 +66,62 @@ public class MR_ClusterTest { @Test public void testMR_ClusterClassConstructor() { - String[] h = { "host1", "host2", "host3" }; - MR_Cluster t = new MR_Cluster( d, fqdn, a, h ); + MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0); + + assertTrue( t.getDcaeLocationName() == d ); + assertTrue( t.getFqdn() == fqdn ); + assertTrue( t.getTopicProtocol() == prot ); + assertTrue( t.getTopicPort() == p0 ); + + // pass null params to trigger default settings + t = new MR_Cluster( d, fqdn, null, null ); + + assertTrue( t.getDcaeLocationName() == d ); + assertTrue( t.getFqdn() == fqdn ); + assertTrue( t.getTopicProtocol() != null ); + assertTrue( t.getTopicPort() != null ); + } + + @Test + public void testMR_ClusterManyArgsClassConstructor() { - t.getHosts(); + MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0, repGrp, p1, p2 ); assertTrue( t.getDcaeLocationName() == d ); assertTrue( t.getFqdn() == fqdn ); + assertTrue( t.getTopicProtocol() == prot ); + assertTrue( t.getTopicPort() == p0 ); + assertTrue( t.getReplicationGroup() == repGrp ); + assertTrue( t.getSourceReplicationPort() == p1 ); + assertTrue( t.getTargetReplicationPort() == p2 ); + + // pass null params to trigger default settings + t = new MR_Cluster( d, fqdn, null, null, null, null, null ); + + assertTrue( t.getDcaeLocationName() == d ); + assertTrue( t.getFqdn() == fqdn ); + assertTrue( t.getTopicProtocol() != null ); + assertTrue( t.getTopicPort() != null ); + assertTrue( t.getReplicationGroup() != null ); + assertTrue( t.getSourceReplicationPort() != null ); + assertTrue( t.getTargetReplicationPort() != null ); } @Test public void testw3() { MR_Cluster t = new MR_Cluster(); - String[] h = { "host1", "host2", "host3" }; - t.setHosts( h ); assertTrue( t.getDcaeLocationName() == null ); assertTrue( t.getFqdn() == null ); - String fqtn = t.genTopicURL( "cluster2.onap.org", "org.onap.topic2" ); + String override = "cluster2.onap.org"; + String topic2 = "org.onap.topic2"; + String fqtn = t.genTopicURL( override, topic2 ); + assertTrue( fqtn.contains( override) && fqtn.contains(topic2)); + + fqtn = t.genTopicURL( null, "org.onap.topic2" ); + assertTrue(fqtn.contains(topic2)); }