use of org.glassfish.jersey.server.model.ResourceModel in project graylog2-server by Graylog2.
the class PrefixAddingModelProcessorTest method processSubResourceDoesNothing.
@Test
public void processSubResourceDoesNothing() throws Exception {
final Map<String, String> packagePrefixes = ImmutableMap.of(PACKAGE_NAME, "/test/prefix");
when(configuration.isCloud()).thenReturn(false);
final PrefixAddingModelProcessor modelProcessor = new PrefixAddingModelProcessor(packagePrefixes, configuration);
final ResourceModel originalResourceModel = new ResourceModel.Builder(false).addResource(Resource.from(TestResource.class)).build();
final ResourceModel resourceModel = modelProcessor.processSubResource(originalResourceModel, new ResourceConfig());
assertThat(originalResourceModel).isSameAs(resourceModel);
}
use of org.glassfish.jersey.server.model.ResourceModel in project jersey by jersey.
the class MonitoringStatisticsTest method getProgStats.
private MonitoringStatisticsImpl.Builder getProgStats() {
final Resource.Builder testBuilder = Resource.builder(TestResource.class);
testBuilder.addChildResource("/prog-child").addMethod("GET").handledBy(MyInflector.class);
final List<Resource> resources = new ArrayList<>();
resources.add(testBuilder.build());
resources.add(Resource.from(HelloResource.class));
final Resource.Builder prog = Resource.builder("prog");
prog.addMethod("GET").handledBy(MyInflector.class);
resources.add(prog.build());
ResourceModel model = new ResourceModel.Builder(resources, false).build();
return new MonitoringStatisticsImpl.Builder(model);
}
use of org.glassfish.jersey.server.model.ResourceModel in project jersey by jersey.
the class MonitoringStatisticsTest method getSimpleStats.
private MonitoringStatisticsImpl getSimpleStats() {
final List<Resource> resources = Arrays.asList(Resource.from(TestResource.class), Resource.from(HelloResource.class));
ResourceModel model = new ResourceModel.Builder(resources, false).build();
MonitoringStatisticsImpl.Builder monBuilder = new MonitoringStatisticsImpl.Builder(model);
return monBuilder.build();
}
use of org.glassfish.jersey.server.model.ResourceModel in project jersey by jersey.
the class TemplateModelProcessor method processTemplateAnnotatedInvocables.
/**
* Process all {@link Invocable invocables} and defines
* {@link org.glassfish.jersey.server.model.Invocable#getRoutingResponseType() routing response types}
* as {@link Viewable} for all methods annotated with {@link Template}.
*
* @param resourceModel resource model to process.
* @param subResourceModel determines whether the resource model represents sub-resource.
* @return Modified resource model.
*/
private ResourceModel.Builder processTemplateAnnotatedInvocables(ResourceModel resourceModel, final boolean subResourceModel) {
ResourceModel.Builder modelBuilder = new ResourceModel.Builder(subResourceModel);
for (Resource resource : resourceModel.getResources()) {
Resource newResource = processResource(resource);
modelBuilder.addResource(newResource);
}
return modelBuilder;
}
use of org.glassfish.jersey.server.model.ResourceModel in project graylog2-server by Graylog2.
the class PrefixAddingModelProcessorTest method processResourceModelAddsPrefixToResourceClassInCorrectPackage.
@Test
public void processResourceModelAddsPrefixToResourceClassInCorrectPackage() throws Exception {
final ImmutableMap<String, String> packagePrefixes = ImmutableMap.of(PACKAGE_NAME, "/test/prefix");
when(configuration.isCloud()).thenReturn(false);
final PrefixAddingModelProcessor modelProcessor = new PrefixAddingModelProcessor(packagePrefixes, configuration);
final ResourceModel originalResourceModel = new ResourceModel.Builder(false).addResource(Resource.from(TestResource.class)).addResource(Resource.from(HiddenTestResource.class)).build();
final ResourceModel resourceModel = modelProcessor.processResourceModel(originalResourceModel, new ResourceConfig());
assertThat(resourceModel.getResources()).hasSize(2);
final Resource resource = resourceModel.getResources().get(0);
assertThat(resource.getPath()).isEqualTo("/test/prefix/foobar/{test}");
final Resource resource2 = resourceModel.getResources().get(1);
assertThat(resource2.getPath()).isEqualTo("/test/prefix/hide-cloud/{test}");
}
Aggregations