private void prepareAppEvent(final String resourceMethodName) throws NoSuchMethodException { final Resource.Builder builder = Resource.builder(); final MockResource mockResource = new MockResource(); final Method handlingMethod = mockResource.getClass().getMethod(resourceMethodName); Method definitionMethod = handlingMethod; final Class<?> interfaceClass = mockResource.getClass().getInterfaces()[0]; if (this.methodDefinedOnInterface(resourceMethodName, interfaceClass.getMethods())) { definitionMethod = interfaceClass.getMethod(resourceMethodName); } final ResourceMethod resourceMethod = builder.addMethod() .handlingMethod(handlingMethod) .handledBy(mockResource, definitionMethod).build(); final Resource resource = builder.build(); final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build(); when(this.appEvent.getResourceModel()).thenReturn(model); when(this.uriInfo.getMatchedResourceMethod()).thenReturn(resourceMethod); }
private void prepareAppEvent(String resourceMethodName) throws NoSuchMethodException { final Resource.Builder builder = Resource.builder(); final MockResource mockResource = new MockResource(); final Method handlingMethod = mockResource.getClass().getMethod(resourceMethodName); Method definitionMethod = handlingMethod; Class<?> interfaceClass = mockResource.getClass().getInterfaces()[0]; if (methodDefinedOnInterface(resourceMethodName, interfaceClass.getMethods())) { definitionMethod = interfaceClass.getMethod(resourceMethodName); } final ResourceMethod resourceMethod = builder.addMethod() .handlingMethod(handlingMethod) .handledBy(mockResource, definitionMethod).build(); final Resource resource = builder.build(); final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build(); when(appEvent.getResourceModel()).thenReturn(model); when(uriInfo.getMatchedResourceMethod()).thenReturn(resourceMethod); }
private void prepareAppEvent(String resourceMethodName) throws NoSuchMethodException { final Resource.Builder builder = Resource.builder(); final MockResource mockResource = new MockResource(); final Method handlingMethod = mockResource.getClass().getMethod(resourceMethodName); Method definitionMethod = handlingMethod; Class<?> interfaceClass = mockResource.getClass().getInterfaces()[0]; if (methodDefinedOnInterface(resourceMethodName, interfaceClass.getMethods())) { definitionMethod = interfaceClass.getMethod(resourceMethodName); } final ResourceMethod resourceMethod = builder.addMethod().handlingMethod(handlingMethod) .handledBy(mockResource, definitionMethod).build(); final Resource resource = builder.build(); final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build(); when(appEvent.getResourceModel()).thenReturn(model); when(uriInfo.getMatchedResourceMethod()).thenReturn(resourceMethod); }
@Override public void onEvent(ApplicationEvent event) { if (event.getType() == ApplicationEvent.Type.INITIALIZATION_APP_FINISHED) { final ResourceModel resourceModel = event.getResourceModel(); final ResourceLogDetails logDetails = new ResourceLogDetails(); resourceModel.getResources().stream().forEach((resource) -> { logDetails.addEndpointLogLines(getLinesFromResource(resource)); }); logDetails.log(); } }
@Override public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) { ResourceModel.Builder rmb = new ResourceModel.Builder(false); resourceModel.getResources().forEach(r -> { rmb.addResource(processResource(r)); }); return rmb.build(); }
@Test public void processResourceModel() { ResourceModel.Builder rmb = new ResourceModel.Builder(false); Resource resource = Resource.builder(SomeController.class).build(); rmb.addResource(resource); ResourceModel processedModel = new OzarkModelProcessor().processResourceModel(rmb.build(), null); Resource processedResource = processedModel.getResources().get(0); processedResource.getResourceMethods().forEach(m -> assertTrue(m.getProducedTypes().contains(MediaType.TEXT_HTML_TYPE))); }
private void prepareAppEvent(String resourceMethodName) throws NoSuchMethodException { final Resource.Builder builder = Resource.builder(); final Method method = mockResource.getClass().getMethod(resourceMethodName); final ResourceMethod resourceMethod = builder.addMethod().handlingMethod(method).handledBy(mockResource, method).build(); final Resource resource = builder.build(); final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build(); when(appEvent.getResourceModel()).thenReturn(model); when(uriInfo.getMatchedResourceMethod()).thenReturn(resourceMethod); }
@Override public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) { if (LOGGER.isDebugEnabled()) { resourceModel.getRootResources().forEach(r -> { debugResource(r); }); } return resourceModel; }
@Override public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) { final ResourceModel.Builder builder = new ResourceModel.Builder(resourceModel, false); for (Resource resource : resources) { builder.addResource(resource); } return builder.build(); }
@Override public ResourceModel processSubResource(ResourceModel subResourceModel, Configuration configuration) { return subResourceModel; }
/** * {@inheritDoc} */ @Override public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) { return ModelProcessorUtil.enhanceResourceModel(resourceModel, false, methodList, true).build(); }
/** * {@inheritDoc} */ @Override public ResourceModel processSubResource(ResourceModel subResourceModel, Configuration configuration) { return ModelProcessorUtil.enhanceResourceModel(subResourceModel, true, methodList, true).build(); }
/** * <p>getResourceModel.</p> * * @return a {@link org.glassfish.jersey.server.model.ResourceModel} object. */ public ResourceModel getResourceModel() { return event.getResourceModel(); }