summaryrefslogtreecommitdiffstats
path: root/cadi/client/src/main/java/org
diff options
context:
space:
mode:
authorIanHowell <ian.howell@att.com>2018-04-23 13:39:31 -0500
committerIanHowell <ian.howell@att.com>2018-04-23 13:40:17 -0500
commit8bea94c36a838bdabd532cfd25e1275a66407827 (patch)
treeea94f38e1c027a10993b7defbc8ddf915f016333 /cadi/client/src/main/java/org
parent6a93111c678a3970ab2f1667511d59d5fba458f6 (diff)
Improve coverage of Cadi/client
Issue-ID: AAF-224 Change-Id: I26f487429bd46ab176ab6af76942baa068933943 Signed-off-by: IanHowell <ian.howell@att.com>
Diffstat (limited to 'cadi/client/src/main/java/org')
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java326
1 files changed, 39 insertions, 287 deletions
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java
index 5ebc017e..c93d233a 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java
@@ -133,18 +133,7 @@ public abstract class Rcli<CT> {
public<T> Future<T> create(String pathinfo, String contentType, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -164,18 +153,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> create(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -195,18 +173,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> create(String pathinfo, Class<?> cls, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -226,19 +193,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> create(String pathinfo, Class<T> cls) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -253,19 +208,7 @@ public abstract class Rcli<CT> {
}
public Future<Void> create(String pathinfo, String contentType) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -294,18 +237,7 @@ public abstract class Rcli<CT> {
* @throws CadiException
*/
public <T> Future<T> postForm(String pathinfo, final RosettaDF<T> df, final String ... formParam) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -364,18 +296,7 @@ public abstract class Rcli<CT> {
* @throws CadiException
*/
public<T> Future<String> readPost(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -406,18 +327,7 @@ public abstract class Rcli<CT> {
* @throws CadiException
*/
public<T,R> Future<R> readPost(String pathinfo, final RosettaDF<T> df, final T t, final RosettaDF<R> resp) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -437,18 +347,7 @@ public abstract class Rcli<CT> {
}
public Future<String> readPost(String pathinfo, String contentType, String ... headers) throws CadiException, APIException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
@@ -466,18 +365,7 @@ public abstract class Rcli<CT> {
}
public Future<String> read(String pathinfo, String accept, String ... headers) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(GET);
@@ -498,19 +386,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> read(String pathinfo, String accept, RosettaDF<T> df, String ... headers) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(GET);
@@ -529,19 +405,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> read(String pathinfo, RosettaDF<T> df,String ... headers) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(GET);
@@ -560,18 +424,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> read(String pathinfo, Class<?> cls, RosettaDF<T> df) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(GET);
@@ -587,19 +440,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> update(String pathinfo, String contentType, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(PUT);
@@ -619,19 +460,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<String> updateRespondString(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(PUT);
@@ -652,18 +481,7 @@ public abstract class Rcli<CT> {
public<T> Future<T> update(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(PUT);
@@ -683,19 +501,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> update(String pathinfo, Class<?> cls, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(PUT);
@@ -724,19 +530,7 @@ public abstract class Rcli<CT> {
* @throws CadiException
*/
public<T> Future<Void> update(String pathinfo) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(PUT);
@@ -755,19 +549,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> delete(String pathinfo, String contentType, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
@@ -787,19 +569,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> delete(String pathinfo, Class<?> cls, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
@@ -819,18 +589,7 @@ public abstract class Rcli<CT> {
}
public<T> Future<T> delete(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
@@ -852,19 +611,7 @@ public abstract class Rcli<CT> {
public<T> Future<T> delete(String pathinfo, Class<T> cls) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
-
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
@@ -879,18 +626,7 @@ public abstract class Rcli<CT> {
}
public Future<Void> delete(String pathinfo, String contentType) throws APIException, CadiException {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
- } else {
- qp=queryParams;
- }
- }
+ final String qp = setupParams(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
@@ -944,6 +680,22 @@ public abstract class Rcli<CT> {
return client.future(resp, expected);
}
+ private String setupParams(String pathinfo) {
+ final String qp;
+ if(pathinfo==null) {
+ qp=queryParams;
+ } else {
+ final int idx = pathinfo.indexOf('?');
+ if(idx>=0) {
+ qp=pathinfo.substring(idx+1);
+ pathinfo=pathinfo.substring(0,idx);
+ } else {
+ qp=queryParams;
+ }
+ }
+ return qp;
+ }
+
public String toString() {
return uri.toString();
}