aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authordglFromAtt <dgl@research.att.com>2018-09-19 17:44:28 -0400
committerdglFromAtt <dgl@research.att.com>2018-09-19 17:52:23 -0400
commitfc6779b17daf8673fd87f9da7e731dba11914875 (patch)
tree06b6164efb1bca84ca350382103b58f690c92603 /src/main/java/org
parentcea5c305eed3eb466ed46ee4d3e16729c7c828b1 (diff)
Raise unit test coverage over 50%
Change-Id: I54ac2797b5a02e41e2c066829b029a8ede4ed1de Signed-off-by: dglFromAtt <dgl@research.att.com> Issue-ID: DMAAP-800 Signed-off-by: dglFromAtt <dgl@research.att.com>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java10
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/DR_SubService.java17
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/FeedService.java32
3 files changed, 43 insertions, 16 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
index 03a8e2f..41a491d 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
@@ -20,11 +20,6 @@
package org.onap.dmaap.dbcapi.resources;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
import java.util.ArrayList;
import java.util.List;
@@ -50,6 +45,11 @@ import org.onap.dmaap.dbcapi.service.ApiService;
import org.onap.dmaap.dbcapi.service.DR_SubService;
import org.onap.dmaap.dbcapi.service.FeedService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
@Path("/dr_subs")
@Api( value= "dr_subs", description = "Endpoint for a Data Router client that implements a Subscriber" )
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/DR_SubService.java b/src/main/java/org/onap/dmaap/dbcapi/service/DR_SubService.java
index 138ff57..d6012a7 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/DR_SubService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/DR_SubService.java
@@ -96,6 +96,7 @@ public class DR_SubService extends BaseLoggingClass {
String resp = prov.doPostDr_Sub( sub, apiError );
if ( unit_test.equals( "Yes" ) ) {
resp = simulateResp( sub, "POST" );
+ apiError.setCode(200);
}
logger.debug( "addDr_Sub resp=" + resp );
@@ -147,6 +148,10 @@ public class DR_SubService extends BaseLoggingClass {
DrProvConnection prov = new DrProvConnection();
prov.makeSubPutConnection( obj.getSubId() );
String resp = prov.doPutDr_Sub( obj, apiError );
+ if ( unit_test.equals( "Yes" ) ) {
+ resp = simulateResp( obj, "PUT" );
+ apiError.setCode(200);
+ }
logger.debug( "resp=" + resp );
DR_Sub snew = null;
@@ -179,7 +184,7 @@ public class DR_SubService extends BaseLoggingClass {
String resp = prov.doDeleteDr_Sub( sub, apiError );
logger.debug( "resp=" + resp );
- if ( apiError.is2xx() ) {
+ if ( apiError.is2xx() || unit_test.equals( "Yes" ) ) {
dr_subs.remove(key);
}
}
@@ -198,8 +203,14 @@ public class DR_SubService extends BaseLoggingClass {
} else {
subid = "99";
}
- String ret = String.format("{\"delivery\": {\"url\": \"https://%s/delivery/%s\", \"user\": \"joe\", \"password\": \"secret\", \"use100\": true}, \"metadataOnly\": false, \"groupid\": \"0\" , \"follow_redirect\": true }",
- server, subid );
+ String ret = String.format("{\"suspend\": false, \"delivery\": {\"url\": \"https://%s/delivery/%s\", \"user\": \"%s\", \"password\": \"%s\", \"use100\": true}, \"metadataOnly\": false, \"groupid\": \"0\" , \"follow_redirect\": true, ",
+ server, subid, sub.getUsername(), sub.getUserpwd());
+ String links = String.format( "\"links\": {\"feed\": \"https://dr-prov/feedlog/%s\", \"self\": \"https://dr-prov/sub/%s\", \"log\": \"https://dr-prov/sublog/%s\" }",
+ sub.getFeedId(),
+ sub.getSubId(),
+ sub.getSubId() );
+ ret += links + "}";
+ logger.info( "DR_SubService:simulateResp=" + ret);
return ret;
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/FeedService.java b/src/main/java/org/onap/dmaap/dbcapi/service/FeedService.java
index 18ca2c7..baf6f2f 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/FeedService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/FeedService.java
@@ -299,6 +299,7 @@ public class FeedService extends BaseLoggingClass {
if ( unit_test.equals( "Yes" ) ) {
// assume resp is null, so need to simulate it
resp = simulateResp( req, "PUT" );
+ err.setCode(200);
}
logger.info( "resp=" + resp );
if ( resp == null ) {
@@ -425,15 +426,30 @@ public class FeedService extends BaseLoggingClass {
feedid = "99";
}
String ret = String.format(
-"{\"suspend\":false,\"groupid\":0,\"description\":\"%s\",\"version\":\"1.0\",\"authorization\":{\"endpoint_addrs\":[],\"classification\":\"unclassified\",\"endpoint_ids\":[{\"password\":\"topSecret123\",\"id\":\"sim\"}]},\"name\":\"%s\",\"business_description\":\"\",\"publisher\":\"sim\",\"links\":{\"subscribe\":\"https://%s/subscribe/%s\",\"log\":\"https://%s/feedlog/%s\",\"publish\":\"https://%s/publish/%s\",\"self\":\"https://%s/feed/%s\"}}",
- f.getFeedDescription(),
- f.getFeedName(),
- server, feedid,
- server, feedid,
- server, feedid,
- server, feedid
+"{\"suspend\":false,\"groupid\":0,\"description\":\"%s\",\"version\":\"1.0\",\"authorization\":",
+ f.getFeedDescription() );
- );
+ String endpoints = "{\"endpoint_addrs\":[],\"classification\":\"unclassified\",\"endpoint_ids\":[";
+ String sep = "";
+ for( DR_Pub pub: f.getPubs()) {
+ endpoints += String.format( "%s{\"password\":\"%s\",\"id\":\"%s\"}",
+ sep, pub.getUserpwd(), pub.getUsername() );
+ sep = ",";
+
+ }
+ endpoints += "]},";
+ ret += endpoints;
+
+ ret += String.format(
+ "\"name\":\"%s\",\"business_description\":\"\",\"publisher\":\"sim\",\"links\":{\"subscribe\":\"https://%s/subscribe/%s\",\"log\":\"https://%s/feedlog/%s\",\"publish\":\"https://%s/publish/%s\",\"self\":\"https://%s/feed/%s\"}}",
+
+ f.getFeedName(),
+ server, feedid,
+ server, feedid,
+ server, feedid,
+ server, feedid
+ );
+ logger.info( "simulateResp ret=" + ret );
return ret;
}
private String simulateDelResp( Feed f ){