diff options
author | dglFromAtt <dgl@research.att.com> | 2019-04-10 18:48:26 -0400 |
---|---|---|
committer | dglFromAtt <dgl@research.att.com> | 2019-04-10 19:05:58 -0400 |
commit | 0654d98f69b80b8d932dd33a5dcc56dbecc6a64e (patch) | |
tree | af0231a8b527f1c8f48eb44234047f0b3c234918 /src/test/java/org/onap | |
parent | 479c7a5645b6f3f9bf478f925fa2009597871a7b (diff) |
Fix some things I broke
patchset2: use is2xx() in TopicResourceTest
Change-Id: Icb6711f290164c4a2c952d5250746f274a048a73
Signed-off-by: dglFromAtt <dgl@research.att.com>
Issue-ID: DMAAP-1095
Signed-off-by: dglFromAtt <dgl@research.att.com>
Diffstat (limited to 'src/test/java/org/onap')
3 files changed, 54 insertions, 44 deletions
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java index 88840fe..04c1bda 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java @@ -54,6 +54,12 @@ public class TopicResourceTest extends JerseyTest { private static final String fmt = "%24s: %s%n"; + private boolean is2xx(int val ) { + if ( val >= 200 && val < 300 ) { + return true; + } + return false; + } @Before public void preTest() throws Exception { @@ -62,9 +68,10 @@ public class TopicResourceTest extends JerseyTest { Dmaap dmaap = factory.genDmaap(); Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON ); - Response resp = target( "dmaap").request().put( reqEntity, Response.class ); - System.out.println( resp.getStatus() ); - assertTrue( resp.getStatus() == 200 ); + Response resp = target( "dmaap").request().post( reqEntity, Response.class ); + System.out.println( "POST dmaap resp=" + resp.getStatus() ); + assertTrue( is2xx( resp.getStatus()) ); + }catch (Exception e ) { } try { @@ -73,7 +80,7 @@ public class TopicResourceTest extends JerseyTest { Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class ); System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class )); if ( resp.getStatus() != 409 ) { - assertTrue( resp.getStatus() == 201 ); + assertTrue( is2xx( resp.getStatus()) ); } } catch (Exception e ) { } @@ -83,7 +90,7 @@ public class TopicResourceTest extends JerseyTest { Response resp = target( "mr_clusters").request().post( reqEntity, Response.class ); System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) ); if (resp.getStatus() != 409 ) { - assertTrue( resp.getStatus() == 200 ); + assertTrue( is2xx( resp.getStatus()) ); } } catch (Exception e ) { diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java index dcdfcdf..bfa4126 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java @@ -97,7 +97,7 @@ public class MR_ClientServiceTest { if ( nTopic != null ) { assertTrue( nTopic.getTopicName().equals( topic.getTopicName() )); } - String[] actions = { "pub", "view" }; + MR_Client c = factory.genPublisher( "edge", topic.getFqtn() ); c = cls.addMr_Client( c, topic, err ); @@ -114,7 +114,7 @@ public class MR_ClientServiceTest { } @Test - public void test5() { + public void AddSubscriberToTopic() { Topic topic = factory.genSimpleTopic( "test5" ); ApiError err = new ApiError(); Topic nTopic = ts.addTopic( topic, err, false ); @@ -124,11 +124,13 @@ public class MR_ClientServiceTest { MR_Client c = factory.genPublisher( "central", topic.getFqtn() ); c = cls.addMr_Client( c, topic, err ); - if ( c != null ) { - c = factory.genSubscriber( "central", topic.getFqtn() ); - c = cls.updateMr_Client( c, err ); - assertTrue( err.getCode() == 200 ); - } - } + assertTrue( c != null ); + c = factory.genSubscriber( "central", topic.getFqtn() ); + c = cls.addMr_Client( c, topic, err ); + assertTrue( err.getCode() == 200 ); + + + } + } diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTest.java index 787d232..f247bad 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/service/MirrorMakerServiceTest.java @@ -42,6 +42,9 @@ public class MirrorMakerServiceTest { private MR_ClusterService mcs; private MR_ClientService cls; private DcaeLocationService dls; + + private Topic replicationTopic; + DmaapService ds; String locname; @@ -73,6 +76,24 @@ public class MirrorMakerServiceTest { mcs.addMr_Cluster( node, err); node = factory.genMR_Cluster("edge" ); mcs.addMr_Cluster(node, err); + + + String t = "org.onap.dmaap.bridgingTopic"; + replicationTopic = factory.genSimpleTopic(t); + replicationTopic.setReplicationCase( ReplicationType.REPLICATION_EDGE_TO_CENTRAL ); + + String c = "publisher"; + String[] a = { "sub", "view" }; + MR_Client sub = factory.genMR_Client("central", replicationTopic.getFqtn(), c, a ); + String[] b = { "pub", "view" }; + MR_Client pub = factory.genMR_Client( "edge", replicationTopic.getFqtn(), c, b ); + ArrayList<MR_Client> clients = new ArrayList<MR_Client>(); + + clients.add( sub ); + clients.add( pub ); + + replicationTopic.setClients( clients ); + } @After @@ -101,23 +122,8 @@ public class MirrorMakerServiceTest { public void CreateMirrorMakerWithSingleTopic() { ApiError err = new ApiError(); - String t = "org.onap.dmaap.bridgingTopic"; - Topic topic = factory.genSimpleTopic(t); - topic.setReplicationCase( ReplicationType.REPLICATION_EDGE_TO_CENTRAL ); - - String c = "publisher"; - String[] a = { "sub", "view" }; - MR_Client sub = factory.genMR_Client("central", topic.getFqtn(), c, a ); - String[] b = { "pub", "view" }; - MR_Client pub = factory.genMR_Client( "edge", topic.getFqtn(), c, b ); - ArrayList<MR_Client> clients = new ArrayList<MR_Client>(); - - clients.add( sub ); - clients.add( pub ); - - topic.setClients( clients ); - Topic nTopic = ts.updateTopic( topic, err ); + Topic nTopic = ts.addTopic(replicationTopic, err, true ); assertTrue( err.getCode() == 200 ); @@ -127,6 +133,13 @@ public class MirrorMakerServiceTest { @Test public void DeleteMirrorMakerWithSingleTopic() { + ApiError err = new ApiError(); + Topic nTopic = ts.addTopic(replicationTopic, err, true ); + replicationTopic.setTopicDescription("modified topic"); + nTopic = ts.updateTopic( replicationTopic, err ); + + assertTrue( err.getCode() == 200 ); + List<String> mma = mms.getAllMirrorMakers(); @@ -149,23 +162,11 @@ public class MirrorMakerServiceTest { ApiError err = new ApiError(); - String t = "org.onap.dmaap.bridgingTopic"; - Topic topic = factory.genSimpleTopic(t); - topic.setReplicationCase( ReplicationType.REPLICATION_EDGE_TO_CENTRAL ); - - String c = "publisher"; - String[] a = { "sub", "view" }; - MR_Client sub = factory.genMR_Client("central", topic.getFqtn(), c, a ); - String[] b = { "pub", "view" }; - MR_Client pub = factory.genMR_Client( "edge", topic.getFqtn(), c, b ); - ArrayList<MR_Client> clients = new ArrayList<MR_Client>(); - - clients.add( sub ); - clients.add( pub ); - topic.setClients( clients ); + Topic nTopic = ts.addTopic( replicationTopic, err, true ); + replicationTopic.setTopicDescription("modified topic"); + nTopic = ts.updateTopic( replicationTopic, err ); - Topic nTopic = ts.updateTopic( topic, err ); assertTrue( err.getCode() == 200 ); List<String> mma = mms.getAllMirrorMakers(); |