summaryrefslogtreecommitdiffstats
path: root/cadi/oauth-enduser/src/test/java/org
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-07-05 15:00:18 -0500
committerInstrumental <jonathan.gathman@att.com>2018-07-05 15:00:23 -0500
commitd37b5467a3b8b375b603579d2888a4443a8b06a7 (patch)
tree54baad3b69be2386bf43e88acac86a15f686a68d /cadi/oauth-enduser/src/test/java/org
parentd41c5dc8c946fef66b64e8f95392b07403a93638 (diff)
Refine Agent for cadi utils
Issue-ID: AAF-361 Change-Id: Id07b60181b906e65aefb24cbe0d192e362c2c3f4 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/oauth-enduser/src/test/java/org')
-rw-r--r--cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/SimpleRestClientExample.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/SimpleRestClientExample.java b/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/SimpleRestClientExample.java
index 7340618f..7d251bad 100644
--- a/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/SimpleRestClientExample.java
+++ b/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/SimpleRestClientExample.java
@@ -27,6 +27,7 @@ import java.security.Principal;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.enduser.ClientFactory;
+import org.onap.aaf.cadi.enduser.RESTException;
import org.onap.aaf.cadi.enduser.SimpleRESTClient;
import org.onap.aaf.misc.env.APIException;
@@ -53,6 +54,11 @@ public class SimpleRestClientExample {
String rv = restClient.get("resthello");
System.out.println(rv);
+ // Same call with "read" style
+ rv = restClient.read("resthello");
+ System.out.println(rv);
+
+
// Call with Queries
rv = restClient.get("resthello?perm=org.osaaf.people|*|read");
System.out.println(rv);
@@ -61,10 +67,22 @@ public class SimpleRestClientExample {
// Pretend Transaction
HRequest req = new HRequest("demo@people.osaaf.org"); // Pretend Trans has Jonathan as Identity
- rv = restClient.as(req.userPrincipal()).get("resthello?perm=org.osaaf.people|*|read");
+ // Call with RESTException, which allows obtaining HTTPCode and any Error message sent
+ rv = restClient.endUser(req.userPrincipal()).get("resthello?perm=org.osaaf.people|*|read");
System.out.println(rv);
+
+ try {
+ restClient.get("notAnAPI");
+ } catch(RESTException e) {
+ System.out.println(e.getCode());
+ System.out.println(e.getMsg());
+ System.out.println(e.getMessage());
+ System.out.println(e.getLocalizedMessage());
+ System.out.println(e);
+ }
+
}
- } catch (CadiException | APIException e) {
+ } catch (CadiException | APIException | RESTException e) {
e.printStackTrace();
}
}