@Test public void checkEndpointAuthorizationFilterRegistrationForSecuredMethod() throws Exception { JsonNode fromString = JsonHandler.getFromString("{\n" + " \"$roots\": [],\n" + " \"$query\": [\n" + " {\n" + " \"exists\": {\n" + " \"Title\": \"assemblée\"\n" + " },\n" + " \"$depth\": 20\n" + " },\n" + " {\n" + " \"exists\": {\n" + " },\n" + " \"$depth\": 20\n" + " }\n" + " ],\n" + " \"$filter\": {\n" + " \"$orderby\": {\n" + " \"TransactedDate\": 1\n" + " }\n" + " }\n" + "}"); ResourceInfo resourceInfo = mock(ResourceInfo.class); List<JsonNode> methodeArgsQueryDsl = new ArrayList<>(); methodeArgsQueryDsl.add(fromString); when(resourceInfo.getResourceMethod()) .thenReturn(DslDynamicFeatureTest.class.getMethod("myDslQueryMethod", JsonNode.class)); when(resourceInfo.getResourceClass()).thenReturn((Class) DslDynamicFeatureTest.class); FeatureContext context = mock(FeatureContext.class); DslDynamicFeature instance = new DslDynamicFeature(); instance.configure(resourceInfo, context); ArgumentCaptor<DslScannerFilter> dslScannerFilterArgumentCaptor = ArgumentCaptor.forClass(DslScannerFilter.class); verify(context, only()) .register(dslScannerFilterArgumentCaptor.capture()); }
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { Class<?> parametersClass[] = resourceInfo.getResourceMethod().getParameterTypes(); for (int i = 0; i < parametersClass.length; i++) { Class<?> parameterClass = parametersClass[i]; if (parameterClass.isAssignableFrom(JsonNode.class)) { Parameter[] parameters = resourceInfo.getResourceMethod().getParameters(); final Parameter parameter = parameters[i]; if (parameter != null) { final Dsl dslAnnotation = parameter.getAnnotation(Dsl.class); try { if (dslAnnotation != null) { context.register(new DslScannerFilter(dslAnnotation.value())); } } catch (IOException e) { LOGGER.error(e); throw new IllegalStateException("Can not initialize DslScannerFilter"); } } } } }
DslDynamicFeature implements DynamicFeature { @Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { Class<?> parametersClass[] = resourceInfo.getResourceMethod().getParameterTypes(); for (int i = 0; i < parametersClass.length; i++) { Class<?> parameterClass = parametersClass[i]; if (parameterClass.isAssignableFrom(JsonNode.class)) { Parameter[] parameters = resourceInfo.getResourceMethod().getParameters(); final Parameter parameter = parameters[i]; if (parameter != null) { final Dsl dslAnnotation = parameter.getAnnotation(Dsl.class); try { if (dslAnnotation != null) { context.register(new DslScannerFilter(dslAnnotation.value())); } } catch (IOException e) { LOGGER.error(e); throw new IllegalStateException("Can not initialize DslScannerFilter"); } } } } } }
DslDynamicFeature implements DynamicFeature { @Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { Class<?> parametersClass[] = resourceInfo.getResourceMethod().getParameterTypes(); for (int i = 0; i < parametersClass.length; i++) { Class<?> parameterClass = parametersClass[i]; if (parameterClass.isAssignableFrom(JsonNode.class)) { Parameter[] parameters = resourceInfo.getResourceMethod().getParameters(); final Parameter parameter = parameters[i]; if (parameter != null) { final Dsl dslAnnotation = parameter.getAnnotation(Dsl.class); try { if (dslAnnotation != null) { context.register(new DslScannerFilter(dslAnnotation.value())); } } catch (IOException e) { LOGGER.error(e); throw new IllegalStateException("Can not initialize DslScannerFilter"); } } } } }  }
DslDynamicFeature implements DynamicFeature { @Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { Class<?> parametersClass[] = resourceInfo.getResourceMethod().getParameterTypes(); for (int i = 0; i < parametersClass.length; i++) { Class<?> parameterClass = parametersClass[i]; if (parameterClass.isAssignableFrom(JsonNode.class)) { Parameter[] parameters = resourceInfo.getResourceMethod().getParameters(); final Parameter parameter = parameters[i]; if (parameter != null) { final Dsl dslAnnotation = parameter.getAnnotation(Dsl.class); try { if (dslAnnotation != null) { context.register(new DslScannerFilter(dslAnnotation.value())); } } catch (IOException e) { LOGGER.error(e); throw new IllegalStateException("Can not initialize DslScannerFilter"); } } } } }  @Override void configure(ResourceInfo resourceInfo, FeatureContext context); }
DslDynamicFeature implements DynamicFeature { @Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { Class<?> parametersClass[] = resourceInfo.getResourceMethod().getParameterTypes(); for (int i = 0; i < parametersClass.length; i++) { Class<?> parameterClass = parametersClass[i]; if (parameterClass.isAssignableFrom(JsonNode.class)) { Parameter[] parameters = resourceInfo.getResourceMethod().getParameters(); final Parameter parameter = parameters[i]; if (parameter != null) { final Dsl dslAnnotation = parameter.getAnnotation(Dsl.class); try { if (dslAnnotation != null) { context.register(new DslScannerFilter(dslAnnotation.value())); } } catch (IOException e) { LOGGER.error(e); throw new IllegalStateException("Can not initialize DslScannerFilter"); } } } } }  @Override void configure(ResourceInfo resourceInfo, FeatureContext context);  }