summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordglFromAtt <dgl@research.att.com>2018-03-11 23:02:41 -0400
committerdglFromAtt <dgl@research.att.com>2018-03-12 20:19:55 -0400
commitd5d37c0477744cbaa6a9d9fc690c0dafbb2d1868 (patch)
treeaa2b8bf841ca27417a5cab7d3dd5671d9016f429
parentbc9afa1b8ff000d7178dfa2f582775fc2a6613a3 (diff)
More unit tests to pass 50%
Also contains a fix to pom.xml for site deployment Change-Id: Ia419bafea523c8370bae2279076f4f2a170b33e1 Signed-off-by: dglFromAtt <dgl@research.att.com> Issue-ID: DMAAP-326 Signed-off-by: dglFromAtt <dgl@research.att.com>
-rw-r--r--.gitignore4
-rw-r--r--pom.xml1
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/model/DmaapObject.java18
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/model/Feed.java25
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java8
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/model/Topic.java25
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/client/DrProvConnectionTest.java4
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrProvConnectionTest.java3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrTopicConnectionTest.java3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBFieldHandlerTest.java3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBMapTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBSingletonTest.java (renamed from src/test/java/org/onap/dmaap/dbcapi/aaf/DBSingletonTest.java)4
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/database/LoadSchemaTest.java3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/aaf/database/TableHandlerTest.java3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java1
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java1
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java1
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java1
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/ReplicationVectorTest.java1
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java1
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/DR_NodeResourceTest.java (renamed from src/test/java/org/onap/dmaap/dbcapi/resource/DR_NodeResourceTest.java)3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/DcaeLocationResourceTest.java (renamed from src/test/java/org/onap/dmaap/dbcapi/resource/DcaeLocationResourceTest.java)44
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/DmaapResourceTest.java (renamed from src/test/java/org/onap/dmaap/dbcapi/resource/DmaapResourceTest.java)3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/FeedResourceTest.java (renamed from src/test/java/org/onap/dmaap/dbcapi/resource/FeedResourceTest.java)0
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/InfoResourceTest.java (renamed from src/test/java/org/onap/dmaap/dbcapi/resource/InfoResourceTest.java)0
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResourceTest.java (renamed from src/test/java/org/onap/dmaap/dbcapi/resource/MR_ClusterResourceTest.java)98
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java186
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java39
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/DcaeLocationServiceTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/MR_ClientServiceTest.java19
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java15
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/testframework/ReflectionHarness.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java3
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/util/RandomIntegerTest.java3
43 files changed, 448 insertions, 101 deletions
diff --git a/.gitignore b/.gitignore
index 01c0d9e..ad73358 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,7 @@ debug-logs/
logs/
target/
+/bin/
+.checkstyle
+.project
+.settings
diff --git a/pom.xml b/pom.xml
index 5825559..5745a30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -324,6 +324,7 @@
<!-- for Distribution Management -->
<sitePath>/content/sites/site/org/onap/dmaap/buscontroller/${artifact.version}</sitePath>
+ <nexusproxy>https://nexus.onap.org</nexusproxy>
</properties>
<description>Data Movement as a Platform (DMaaP) Bus Controller provides a REST API for other DCAE infrastructure components to provision DMaaP resources. A DMaaP resource is a Data Router Feed or a Message Router Topic, and their associated publishers and subscribers.</description>
</project>
diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/DmaapObject.java b/src/main/java/org/onap/dmaap/dbcapi/model/DmaapObject.java
index 567e042..8e804b2 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/model/DmaapObject.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/model/DmaapObject.java
@@ -63,6 +63,24 @@ public abstract class DmaapObject extends BaseLoggingClass {
this.status = status;
}
+ public void setStatus( String val ) {
+ if ( val == null || val.isEmpty() ) {
+ this.status = DmaapObject_Status.EMPTY;
+ } else if (val.compareToIgnoreCase("new") == 0 ) {
+ this.status = DmaapObject_Status.NEW;
+ } else if ( val.compareToIgnoreCase("staged" ) == 0) {
+ this.status = DmaapObject_Status.STAGED;
+ } else if ( val.compareToIgnoreCase("valid") == 0) {
+ this.status = DmaapObject_Status.VALID;
+ } else if ( val.compareToIgnoreCase("invalid") == 0) {
+ this.status = DmaapObject_Status.INVALID;
+ } else if ( val.compareToIgnoreCase("deleted") == 0) {
+ this.status = DmaapObject_Status.DELETED;
+ } else {
+ this.status = DmaapObject_Status.INVALID;
+ }
+ }
+
public boolean isStatusValid() {
if ( this.status == DmaapObject_Status.VALID ) {
return true;
diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java b/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java
index b327f3a..648812f 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java
@@ -96,7 +96,6 @@ public class Feed extends DmaapObject {
public Feed ( String json ) {
JSONParser parser = new JSONParser();
JSONObject jsonObj;
- logger.info( "templog:Feed at 10" );
try {
jsonObj = (JSONObject) parser.parse( json );
} catch ( ParseException pe ) {
@@ -104,50 +103,29 @@ public class Feed extends DmaapObject {
this.setStatus( DmaapObject_Status.INVALID );
return;
}
- logger.info( "templog:Feed at 11" );
this.setFeedName( (String) jsonObj.get("name"));
- logger.info( "templog:Feed at 12" );
-
this.setFeedVersion( (String) jsonObj.get("version"));
- logger.info( "templog:Feed at 13" );
this.setFeedDescription( (String) jsonObj.get("description"));
- logger.info( "templog:Feed at 14" );
this.setOwner( (String) jsonObj.get("publisher"));
- logger.info( "templog:Feed at 15" );
this.setSuspended( (boolean) jsonObj.get("suspend"));
- logger.info( "templog:Feed at 16" );
JSONObject links = (JSONObject) jsonObj.get("links");
- logger.info( "templog:Feed at 17" );
String url = (String) links.get("publish");
- logger.info( "templog:Feed at 18" );
this.setPublishURL( url );
- logger.info( "templog:Feed at 19" );
this.setFeedId( url.substring( url.lastIndexOf('/')+1, url.length() ));
- logger.info( "templog:Feed at 20" );
logger.info( "feedid="+ this.getFeedId() );
- logger.info( "templog:Feed at 21" );
this.setSubscribeURL( (String) links.get("subscribe") );
- logger.info( "templog:Feed at 22" );
this.setLogURL( (String) links.get("log") );
- logger.info( "templog:Feed at 23" );
JSONObject auth = (JSONObject) jsonObj.get("authorization");
- logger.info( "templog:Feed at 24" );
this.setAsprClassification( (String) auth.get("classification"));
- logger.info( "templog:Feed at 25" );
JSONArray pubs = (JSONArray) auth.get( "endpoint_ids");
- logger.info( "templog:Feed at 26" );
int i;
- logger.info( "templog:Feed at 27" );
ArrayList<DR_Pub> dr_pub = new ArrayList<DR_Pub>();
- logger.info( "templog:Feed at 28" );
this.subs = new ArrayList<DR_Sub>();
for( i = 0; i < pubs.size(); i++ ) {
- logger.info( "templog:Feed at 29 " + i );
JSONObject entry = (JSONObject) pubs.get(i);
- logger.info( "templog:Feed at 30" );
dr_pub.add( new DR_Pub( "someLocation",
(String) entry.get("id"),
(String) entry.get("password"),
@@ -155,12 +133,9 @@ public class Feed extends DmaapObject {
this.getFeedId() + "." + DR_Pub.nextKey() ));
}
- logger.info( "templog:Feed at 31" );
this.setPubs( dr_pub );
- logger.info( "templog:Feed at 32" );
this.setStatus( DmaapObject_Status.VALID );
- logger.info( "templog:Feed at 33" );
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java b/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java
index 46279ee..79de9ba 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java
@@ -20,8 +20,6 @@
package org.onap.dmaap.dbcapi.model;
-import java.util.Date;
-
import javax.xml.bind.annotation.XmlRootElement;
import org.onap.dmaap.dbcapi.util.DmaapTimestamp;
@@ -63,22 +61,16 @@ public class MR_Cluster extends DmaapObject {
String[] h ) {
this.dcaeLocationName = dLN;
this.fqdn = f;
-logger.info( "templog:MR_Cluster at 10" );
this.hosts = new String[3];
this.hosts[0] = h[0];
-logger.info( "templog:MR_Cluster at 20" );
this.hosts[1] = h[1];
-logger.info( "templog:MR_Cluster at 30" );
this.hosts[2] = h[2];
-logger.info( "templog:MR_Cluster at 40" );
this.topicProtocol = defaultTopicProtocol;
-logger.info( "templog:MR_Cluster at 50" );
this.topicPort = defaultTopicPort;
this.lastMod = new DmaapTimestamp();
this.lastMod.mark();
debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
-logger.info( "templog:MR_Cluster at 60" );
}
public String getDcaeLocationName() {
diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/Topic.java b/src/main/java/org/onap/dmaap/dbcapi/model/Topic.java
index 7c957dc..6364382 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/model/Topic.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/model/Topic.java
@@ -23,7 +23,8 @@ package org.onap.dmaap.dbcapi.model;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
-
+import org.json.simple.*;
+import org.json.simple.parser.*;
import javax.xml.bind.annotation.XmlRootElement;
@@ -123,6 +124,28 @@ public class Topic extends DmaapObject {
this.fqtnStyle = FqtnType.Validator("none");
logger.debug( "Topic constructor " + this.getLastMod() );
}
+
+ // expects a String in JSON format, with known fields to populate Topic object
+ public Topic ( String json ) {
+ JSONParser parser = new JSONParser();
+ JSONObject jsonObj;
+ try {
+ jsonObj = (JSONObject) parser.parse( json );
+ } catch ( ParseException pe ) {
+ logger.error( "Error parsing provisioning data: " + json );
+ this.setStatus( DmaapObject_Status.INVALID );
+ return;
+ }
+ this.setFqtn( (String) jsonObj.get( "fqtn" ) );
+ this.setTopicName( (String) jsonObj.get( "topicName" ) );
+ this.setTopicDescription( (String) jsonObj.get( "topicDescription" ));
+ this.setOwner( (String) jsonObj.get( "owner" ) );
+ //this.setLastMod();
+ this.setStatus( (String) jsonObj.get( "status" ) );
+ this.setReplicationCase( ReplicationType.Validator( (String) jsonObj.get( "replicationCase" ) ));
+ this.setFqtnStyle( FqtnType.Validator( (String) jsonObj.get( "fqtnStyle" ) ) );
+
+ }
public String getFqtn() {
return fqtn;
}
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/DrProvConnectionTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/DrProvConnectionTest.java
index 643b319..7dec442 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/DrProvConnectionTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/DrProvConnectionTest.java
@@ -18,8 +18,12 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.client;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrProvConnectionTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrProvConnectionTest.java
index 4995813..b96e173 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrProvConnectionTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrProvConnectionTest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.client;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrTopicConnectionTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrTopicConnectionTest.java
index 5bbb6a1..548c24a 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrTopicConnectionTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/client/MrTopicConnectionTest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.client;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBFieldHandlerTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBFieldHandlerTest.java
index fc17ac6..99022b4 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBFieldHandlerTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBFieldHandlerTest.java
@@ -19,7 +19,10 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBMapTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBMapTest.java
index 3fdcb52..46138ab 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBMapTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBMapTest.java
@@ -18,7 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.util.Singleton;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/DBSingletonTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBSingletonTest.java
index f403da7..e2b3653 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/DBSingletonTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/DBSingletonTest.java
@@ -19,7 +19,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
+import org.onap.dmaap.dbcapi.aaf.database.DBSingleton;
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/LoadSchemaTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/LoadSchemaTest.java
index d93ffd2..3650a6e 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/LoadSchemaTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/LoadSchemaTest.java
@@ -18,7 +18,10 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/TableHandlerTest.java b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/TableHandlerTest.java
index 266bf24..ac6b336 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/aaf/database/TableHandlerTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/aaf/database/TableHandlerTest.java
@@ -18,7 +18,10 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.aaf.database;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java
index 4e9a022..a3dddaf 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/FeedTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import java.util.ArrayList;
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 dd57348..15753cd 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/MRClientTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MRClientTest {
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..26bca4c 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,6 +28,7 @@ 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;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java
index 6c35b93..ba4b028 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/MirrorMakerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import java.util.ArrayList;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/ReplicationVectorTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/ReplicationVectorTest.java
index 0655b75..dde3b49 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/model/ReplicationVectorTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/ReplicationVectorTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import java.util.ArrayList;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java
index 1f8b3b2..5180b99 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/TopicTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class TopicTest {
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/DR_NodeResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/DR_NodeResourceTest.java
index 64ca39d..01ef6ae 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resource/DR_NodeResourceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/DR_NodeResourceTest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/DcaeLocationResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/DcaeLocationResourceTest.java
index dd2525f..31faa38 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resource/DcaeLocationResourceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/DcaeLocationResourceTest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
import static org.junit.Assert.*;
import org.junit.After;
@@ -76,13 +79,52 @@ public class DcaeLocationResourceTest extends JerseyTest {
Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
- assertTrue( resp.getStatus() == 201 );
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
+
+ resp = target( "dcaeLocations").
+ path( loc.getDcaeLocationName()).request().get( Response.class );
+ System.out.println( "GET feed resp=" + resp.getStatus() );
+
+ assertTrue( resp.getStatus() == 200 );
}
@Test
public void PutTest() {
+ DcaeLocation loc = factory.genDcaeLocation( "edge" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ 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 );
+ }
+
+
+ loc.setClli("ATLCTYNJ9999");
+ reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ resp = target( "dcaeLocations").
+ path( loc.getDcaeLocationName()).request().put( reqEntity, Response.class );
+ System.out.println( "PUT dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 201 );
+
}
+ @Test
+ public void DelTest() {
+ DcaeLocation loc = factory.genDcaeLocation( "edge" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ 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 );
+ }
+
+ resp = target( "dcaeLocations").
+ path( loc.getDcaeLocationName()).request().delete( Response.class );
+ System.out.println( "DELETE dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 204 );
+ }
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/DmaapResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/DmaapResourceTest.java
index 4f8f602..9dea317 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resource/DmaapResourceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/DmaapResourceTest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/FeedResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/FeedResourceTest.java
index 89dca8a..89dca8a 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resource/FeedResourceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/FeedResourceTest.java
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/InfoResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/InfoResourceTest.java
index 3f57f58..3f57f58 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resource/InfoResourceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/InfoResourceTest.java
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resource/MR_ClusterResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResourceTest.java
index 1f78c3f..7a57794 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resource/MR_ClusterResourceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResourceTest.java
@@ -18,24 +18,20 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.resources;
-import org.onap.dmaap.dbcapi.model.*;
-import org.onap.dmaap.dbcapi.service.*;
-import static org.junit.Assert.*;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import java.util.*;
-import java.sql.*;
+import static org.junit.Assert.assertTrue;
-import org.glassfish.jersey.test.JerseyTest;
-import org.glassfish.jersey.server.ResourceConfig;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.Path;
-import javax.ws.rs.GET;
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Test;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
public class MR_ClusterResourceTest extends JerseyTest {
@@ -44,7 +40,10 @@ public class MR_ClusterResourceTest extends JerseyTest {
@Override
protected Application configure() {
- return new ResourceConfig( MR_ClusterResource.class );
+
+ return new ResourceConfig()
+ .register( MR_ClusterResource.class )
+ .register( DcaeLocationResource.class );
}
private static final String fmt = "%24s: %s%n";
@@ -75,29 +74,41 @@ public class MR_ClusterResourceTest extends JerseyTest {
Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
Response resp = target( "mr_clusters").request().post( reqEntity, Response.class );
System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
- assertTrue( resp.getStatus() == 201 );
+ if (resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201);
+ }
+ resp = target( "mr_clusters").
+ path( cluster.getDcaeLocationName()).request().get( Response.class );
+ System.out.println( "GET MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+
+ assertTrue( resp.getStatus() >= 200 && resp.getStatus() < 300 );
+
}
@Test
public void PutTest() {
-/*
+
try {
DcaeLocation loc = factory.genDcaeLocation( "central" );
Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ));
- assertTrue( resp.getStatus() == 201 );
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
} catch (Exception e ) {
}
-*/
+
String h[] = {"host4", "host5", "host6" };
- MR_Cluster cluster = factory.genMR_Cluster( "edge" );
+ MR_Cluster cluster = factory.genMR_Cluster( "central" );
Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
Response resp = target( "mr_clusters").request().post( reqEntity, Response.class );
// first, add it
System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
- assertTrue( resp.getStatus() == 201 );
+ if( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 200 );
+ }
// now change a field
cluster.setHosts( h );
@@ -105,11 +116,11 @@ public class MR_ClusterResourceTest extends JerseyTest {
// update with incorrect key
resp = target( "mr_clusters")
- .path( cluster.getFqdn())
+ .path( cluster.getDcaeLocationName())
.request()
.put( reqEntity, Response.class );
System.out.println( "PUT MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity(String.class));
- assertTrue( resp.getStatus() == 404 );
+ assertTrue( resp.getStatus() == 200 );
// update with correct key
resp = target( "mr_clusters")
@@ -120,6 +131,49 @@ public class MR_ClusterResourceTest extends JerseyTest {
assertTrue( resp.getStatus() == 200 );
}
+ @Test
+ public void DelTest() {
+
+ try {
+ DcaeLocation loc = factory.genDcaeLocation( "edge" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ 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 );
+ }
+ } catch (Exception e ) {
+ }
+
+
+ MR_Cluster cluster = factory.genMR_Cluster( "edge" );
+
+ Response resp = target( "mr_clusters").
+ path( cluster.getDcaeLocationName()).
+ request().
+ delete( Response.class );
+
+ // confirm cluster is not there
+ System.out.println( "DELETE MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 404 );
+
+ // now, add it
+ Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
+ resp = target( "mr_clusters").request().post( reqEntity, Response.class );
+
+
+ System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 201 );
+
+ // now really delete it
+ resp = target( "mr_clusters").
+ path( cluster.getDcaeLocationName()).
+ request().
+ delete( Response.class );
+ System.out.println( "DELETE MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 204 );
+
+ }
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java
new file mode 100644
index 0000000..43cf523
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/TopicResourceTest.java
@@ -0,0 +1,186 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.resources;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.model.Topic;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
+
+public class TopicResourceTest extends JerseyTest {
+
+ static DmaapObjectFactory factory = new DmaapObjectFactory();
+
+ @Override
+ protected Application configure() {
+
+ return new ResourceConfig()
+ .register( TopicResource.class )
+ .register( MR_ClusterResource.class )
+ .register( DcaeLocationResource.class );
+ }
+
+ private static final String fmt = "%24s: %s%n";
+
+
+
+
+ @Before
+ public void preTest() throws Exception {
+ try {
+ DcaeLocation loc = factory.genDcaeLocation( "central" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ 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 );
+ }
+ } catch (Exception e ) {
+ }
+ try {
+ MR_Cluster cluster = factory.genMR_Cluster( "central" );
+ Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
+ 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);
+ }
+ } catch (Exception e ) {
+
+ }
+
+ }
+ /* may conflict with test framework!
+ @After
+ public void tearDown() throws Exception {
+ }
+*/
+
+
+ @Test
+ public void GetTest() {
+ Response resp = target( "topics").request().get( Response.class );
+ System.out.println( "GET feed resp=" + resp.getStatus() );
+
+ assertTrue( resp.getStatus() == 200 );
+ }
+ @Test
+ public void PostTest() {
+ Topic topic = factory.genSimpleTopic( "test1" );
+ Entity<Topic> reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+ Response resp = target( "topics").request().post( reqEntity, Response.class );
+ System.out.println( "POST Topic resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ if (resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201);
+ }
+ resp = target( "topics").
+ path( topic.genFqtn() ).request().get( Response.class );
+ System.out.println( "GET Topic resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+
+ assertTrue( resp.getStatus() == 200 );
+
+ }
+
+ @Test
+ public void PutTest() {
+
+ Topic topic = factory.genSimpleTopic( "test2" );
+ Entity<Topic> reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+ Response resp = target( "topics").request().post( reqEntity, Response.class );
+ String json = resp.readEntity(String.class);
+ System.out.println( "POST Topic resp=" + resp.getStatus() + " " + json );
+ if (resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201);
+ }
+
+
+ // now change a field
+ topic.setOwner( "newbody" );
+ reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+
+ // update with incorrect key
+ resp = target( "topics")
+ .path( "org.onap.dmaap.notATopic" )
+ .request()
+ .put( reqEntity, Response.class );
+
+ System.out.println( "PUT Topic resp=" + resp.getStatus() + " expect 400" );
+ assertTrue( resp.getStatus() == 400 );
+
+ // update with correct key
+ topic = new Topic( json );
+ reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+ resp = target( "topics")
+ .path( topic.getFqtn())
+ .request()
+ .put( reqEntity, Response.class );
+ System.out.println( "PUT Topic resp=" + resp.getStatus() + " " + resp.readEntity(String.class));
+ assertTrue( resp.getStatus() == 400 ); // PUT is not allowed even with the right key
+ }
+
+ @Test
+ public void DelTest() {
+
+ Topic topic = factory.genSimpleTopic( "test3" );
+ topic.setFqtn( "org.onap.unittest.test3" );
+
+ Response resp = target( "topics").
+ path( topic.getFqtn() ).
+ request().
+ delete( Response.class );
+
+ // confirm topic is not there
+ System.out.println( "DELETE Topic resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 404 );
+
+ // now, add it
+ Entity<Topic> reqEntity = Entity.entity( topic, MediaType.APPLICATION_JSON );
+ resp = target( "topics").request().post( reqEntity, Response.class );
+ String json = resp.readEntity( String.class );
+ System.out.println( "POST Topic resp=" + resp.getStatus() + " " + json );
+ assertTrue( resp.getStatus() == 201 );
+
+ topic = new Topic( json );
+ // now really delete it
+ resp = target( "topics").
+ path( topic.getFqtn()).
+ request().
+ delete( Response.class );
+ System.out.println( "DELETE Topic resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
+ assertTrue( resp.getStatus() == 204 );
+
+ }
+
+
+
+}
+
diff --git a/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java b/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java
index 26ba3a6..655d0a0 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/server/JettyServerTest.java
@@ -18,7 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.server;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java b/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java
index 496a93d..b10c472 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/server/MainTest.java
@@ -18,7 +18,10 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.server;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java
index e429fbd..f29d985 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/ApiServiceTest.java
@@ -18,9 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.aaf.*;
import org.onap.dmaap.dbcapi.resources.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.aaf.authentication.AuthenticationErrorException;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java
index 4f92bcd..3f29d42 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/DR_NodeServiceTest.java
@@ -18,7 +18,10 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
@@ -33,6 +36,7 @@ public class DR_NodeServiceTest {
private static final String fmt = "%24s: %s%n";
ReflectionHarness rh = new ReflectionHarness();
+ static DmaapObjectFactory factory = new DmaapObjectFactory();
DR_NodeService ns;
@@ -67,7 +71,7 @@ public class DR_NodeServiceTest {
String locname = "central-demo";
DcaeLocationService dls = new DcaeLocationService();
- DcaeLocation loc = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" );
+ DcaeLocation loc = factory.genDcaeLocation( "central" );
dls.addDcaeLocation( loc );
ApiError err = new ApiError();
@@ -89,38 +93,5 @@ public class DR_NodeServiceTest {
}
-/*
- @Test
- public void test4() {
- List<MR_Client> l = cls.getAllMr_Clients();
-
- ArrayList<MR_Client> al = cls.getAllMrClients( "foo" );
-
- ArrayList<MR_Client> al2 = cls.getClientsByLocation( "central" );
- }
-
- @Test
- public void test5() {
- Topic topic = new Topic();
- ApiError err = new ApiError();
- topic.setTopicName( "test3" );
- topic.setFqtnStyle( FqtnType.Validator("none") );
- topic.getFqtn();
- Topic nTopic = ts.addTopic( topic, err );
- if ( nTopic != null ) {
- assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
- }
- String[] actions = { "pub", "view" };
- MR_Client c = new MR_Client( "central-onap", "org.onap.dmaap.demo.interestingTopic2", "org.onap.clientApp.publisher", actions );
-
- c = cls.addMr_Client( c, topic, err );
- if ( c != null ) {
- actions[0] = "sub";
- c.setAction( actions );
- c = cls.updateMr_Client( c, err );
- assertTrue( err.getCode() == 200 );
- }
- }
-*/
}
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/DcaeLocationServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/DcaeLocationServiceTest.java
index e8c7229..370fa82 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/DcaeLocationServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/DcaeLocationServiceTest.java
@@ -18,7 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java
index e40488e..7029bd2 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/DmaapServiceTest.java
@@ -18,7 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.aaf.*;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java
index 5c93dbf..451cfff 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/Dr_PubServiceTest.java
@@ -18,7 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java
index 832237e..1827594 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/FeedServiceTest.java
@@ -18,9 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.aaf.*;
import org.onap.dmaap.dbcapi.resources.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import org.onap.dmaap.dbcapi.aaf.authentication.AuthenticationErrorException;
import static org.junit.Assert.*;
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 470ca6c..4d79b74 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
@@ -18,15 +18,22 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
-import org.onap.dmaap.dbcapi.model.*;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.util.List;
-import java.util.ArrayList;
+import org.onap.dmaap.dbcapi.model.ApiError;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.MR_Client;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.model.Topic;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MR_ClientServiceTest {
@@ -114,11 +121,11 @@ public class MR_ClientServiceTest {
if ( nTopic != null ) {
assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
}
- MR_Client c = factory.genPublisher( "edge", topic.getFqtn() );
+ MR_Client c = factory.genPublisher( "central", topic.getFqtn() );
c = cls.addMr_Client( c, topic, err );
if ( c != null ) {
- c = factory.genSubscriber( "edge", topic.getFqtn() );
+ c = factory.genSubscriber( "central", topic.getFqtn() );
c = cls.updateMr_Client( c, err );
assertTrue( err.getCode() == 200 );
}
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java
index cbf9931..285647a 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java
@@ -18,7 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java
index 5757522..5997ab1 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/TopicServiceTest.java
@@ -18,7 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.service;
+
import org.onap.dmaap.dbcapi.model.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java b/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java
index 44b3e41..9d3c868 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java
@@ -17,8 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.dmaap.dbcapi.model;
-
+package org.onap.dmaap.dbcapi.testframework;
+
+import org.onap.dmaap.dbcapi.model.DR_Node;
+import org.onap.dmaap.dbcapi.model.DR_Sub;
+import org.onap.dmaap.dbcapi.model.DcaeLocation;
+import org.onap.dmaap.dbcapi.model.Dmaap;
+import org.onap.dmaap.dbcapi.model.FqtnType;
+import org.onap.dmaap.dbcapi.model.MR_Client;
+import org.onap.dmaap.dbcapi.model.MR_Cluster;
+import org.onap.dmaap.dbcapi.model.Topic;
import org.onap.dmaap.dbcapi.util.RandomInteger;
import static org.junit.Assert.*;
@@ -87,7 +95,8 @@ public class DmaapObjectFactory {
Topic t = new Topic();
t.setTopicName( tname );
t.setFqtnStyle( FqtnType.Validator("none") );
- t.getFqtn();
+ t.setTopicDescription( "a simple Topic named " + tname );
+ t.setOwner( "ut");
return t;
}
diff --git a/src/test/java/org/onap/dmaap/dbcapi/testframework/ReflectionHarness.java b/src/test/java/org/onap/dmaap/dbcapi/testframework/ReflectionHarness.java
index 8f70eca..931ee28 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/testframework/ReflectionHarness.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/testframework/ReflectionHarness.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.dmaap.dbcapi.model;
+package org.onap.dmaap.dbcapi.testframework;
import static org.junit.Assert.*;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java b/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java
index 29de17d..2b10ae7 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/util/DmaapConfigTest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.util;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java b/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java
index 2d5b429..7cedfac 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/util/GraphTest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.util;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/util/RandomIntegerTest.java b/src/test/java/org/onap/dmaap/dbcapi/util/RandomIntegerTest.java
index b489608..bd5f9cd 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/util/RandomIntegerTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/util/RandomIntegerTest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.util;
+
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
+
import static org.junit.Assert.*;
import org.junit.After;