@Test public void testGetAlwaysPass() throws Exception { ContainerRequestContext requestContext = mock(ContainerRequestContext.class); when(resourceInfo.getResourceMethod()).thenReturn(TestSimpleOperations.class.getMethod("test1")); when(resourceInfo.getResourceClass()).thenReturn((Class) TestSimpleOperations.class); when(requestContext.getMethod()).thenReturn("GET"); filter.filter(requestContext); verify(requestContext, times(0)).abortWith(anyObject()); }
@Override public void filter(ContainerRequestContext requestContext) { KieServerEndpoint endpoint = null; if (resourceInfo.getResourceMethod().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceMethod().getAnnotation(KieServerEndpoint.class); } else if(resourceInfo.getResourceClass().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceClass().getAnnotation(KieServerEndpoint.class); } if ("GET".equals(requestContext.getMethod())) { return; } if (endpoint == null) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); return; } List<EndpointType> current = new ArrayList<>(asList(endpoint.categories())); current.retainAll(valid); if(current.isEmpty()) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); } }
KieServerEndpointRequestFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { KieServerEndpoint endpoint = null; if (resourceInfo.getResourceMethod().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceMethod().getAnnotation(KieServerEndpoint.class); } else if(resourceInfo.getResourceClass().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceClass().getAnnotation(KieServerEndpoint.class); } if ("GET".equals(requestContext.getMethod())) { return; } if (endpoint == null) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); return; } List<EndpointType> current = new ArrayList<>(asList(endpoint.categories())); current.retainAll(valid); if(current.isEmpty()) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); } } }
KieServerEndpointRequestFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { KieServerEndpoint endpoint = null; if (resourceInfo.getResourceMethod().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceMethod().getAnnotation(KieServerEndpoint.class); } else if(resourceInfo.getResourceClass().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceClass().getAnnotation(KieServerEndpoint.class); } if ("GET".equals(requestContext.getMethod())) { return; } if (endpoint == null) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); return; } List<EndpointType> current = new ArrayList<>(asList(endpoint.categories())); current.retainAll(valid); if(current.isEmpty()) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); } }  }
KieServerEndpointRequestFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { KieServerEndpoint endpoint = null; if (resourceInfo.getResourceMethod().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceMethod().getAnnotation(KieServerEndpoint.class); } else if(resourceInfo.getResourceClass().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceClass().getAnnotation(KieServerEndpoint.class); } if ("GET".equals(requestContext.getMethod())) { return; } if (endpoint == null) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); return; } List<EndpointType> current = new ArrayList<>(asList(endpoint.categories())); current.retainAll(valid); if(current.isEmpty()) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); } }  @Override void filter(ContainerRequestContext requestContext); }
KieServerEndpointRequestFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { KieServerEndpoint endpoint = null; if (resourceInfo.getResourceMethod().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceMethod().getAnnotation(KieServerEndpoint.class); } else if(resourceInfo.getResourceClass().isAnnotationPresent(KieServerEndpoint.class)) { endpoint = resourceInfo.getResourceClass().getAnnotation(KieServerEndpoint.class); } if ("GET".equals(requestContext.getMethod())) { return; } if (endpoint == null) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); return; } List<EndpointType> current = new ArrayList<>(asList(endpoint.categories())); current.retainAll(valid); if(current.isEmpty()) { requestContext.abortWith(Response.status(SERVICE_UNAVAILABLE).entity("Endpoint disabled").build()); } }  @Override void filter(ContainerRequestContext requestContext);  }