summaryrefslogtreecommitdiffstats
path: root/aai-resources/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'aai-resources/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java')
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/aai-resources/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java b/aai-resources/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java
new file mode 100644
index 0000000..dc6879d
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java
@@ -0,0 +1,53 @@
+package org.openecomp.aai.interceptors;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.logging.LoggingContext;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class PostAaiAjscInterceptorTest {
+
+ private PostAaiAjscInterceptor postAaiAjscInterceptor;
+
+ @Before
+ public void setup(){
+ postAaiAjscInterceptor = new PostAaiAjscInterceptor();
+ }
+
+ @Test
+ public void getInstance() throws Exception {
+ PostAaiAjscInterceptor interceptor = PostAaiAjscInterceptor.getInstance();
+ assertNotNull(interceptor);
+ }
+
+ @Test
+ public void testAllowOrRejectIfSuccess() throws Exception {
+
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+
+ LoggingContext.put(LoggingContext.LoggingField.RESPONSE_CODE.toString(), "SUCCESS");
+ Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj"));
+
+ boolean success = postAaiAjscInterceptor.allowOrReject(request, null, null);
+
+ assertTrue("Expecting the post interceptor to return success regardless", success);
+ }
+
+ @Test
+ public void testAllowOrRejectIfFailure() throws Exception {
+
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+
+ LoggingContext.put(LoggingContext.LoggingField.RESPONSE_CODE.toString(), "ERR.");
+ Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj"));
+
+ boolean success = postAaiAjscInterceptor.allowOrReject(request, null, null);
+
+ assertTrue("Expecting the post interceptor to return success regardless", success);
+ }
+} \ No newline at end of file