aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
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 /src/main
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>
Diffstat (limited to 'src/main')
-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
4 files changed, 42 insertions, 34 deletions
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;
}