use of io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider in project crnk-framework by crnk-project.
the class MetaModule method registerInformationBuilder.
protected DefaultResourceInformationProvider registerInformationBuilder(PropertiesProvider propertiesProvider) {
InformationBuilder informationBuilder = new DefaultInformationBuilder(context.getTypeParser());
DefaultResourceInformationProvider informationProvider = new DefaultResourceInformationProvider(propertiesProvider, new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
informationProvider.init(new DefaultResourceInformationProviderContext(informationProvider, informationBuilder, context.getTypeParser(), null) {
@Override
public ObjectMapper getObjectMapper() {
return context.getObjectMapper();
}
});
return informationProvider;
}
use of io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider in project crnk-framework by crnk-project.
the class JacksonModule method setupModule.
@Override
public void setupModule(ModuleContext context) {
objectMapper.registerModule(createJacksonModule(serializeLinksAsObjects));
DefaultResourceFieldInformationProvider defaultFieldProvider = new DefaultResourceFieldInformationProvider();
ResourceFieldInformationProvider jacksonFieldProvider = new JacksonResourceFieldInformationProvider();
// TODO move somewhere else and make use of a SerializerExtension
context.addResourceInformationBuilder(new DefaultResourceInformationProvider(context.getPropertiesProvider(), pagingBehaviors, defaultFieldProvider, jacksonFieldProvider));
}
use of io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method getResourceInformationProviderWithProperty.
private ResourceInformationProvider getResourceInformationProviderWithProperty(String key, String value) {
PropertiesProvider propertiesProvider = Mockito.mock(PropertiesProvider.class);
Mockito.when(propertiesProvider.getProperty(Mockito.eq(key))).thenReturn(value);
ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(propertiesProvider, new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
resourceInformationProvider.init(context);
return resourceInformationProvider;
}
use of io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider in project crnk-framework by crnk-project.
the class AbstractQueryParamsTest method setup.
@Before
public void setup() {
JsonServiceLocator jsonServiceLocator = new SampleJsonServiceLocator();
ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(new NullPropertiesProvider(), (PagingBehavior) null, new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
SimpleModule testModule = new SimpleModule("test");
CrnkBoot boot = new CrnkBoot();
boot.addModule(testModule);
boot.boot();
moduleRegistry = boot.getModuleRegistry();
resourceRegistry = boot.getResourceRegistry();
converter = new DefaultQueryParamsConverter(resourceRegistry);
paramsToSpecConverter = new DefaultQuerySpecConverter(moduleRegistry);
}
use of io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider in project crnk-framework by crnk-project.
the class QueryParamsAdapterTest method test.
@Test
public void test() {
ModuleRegistry moduleRegistry = new ModuleRegistry();
moduleRegistry.getHttpRequestContextProvider().setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
ResourceRegistry resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
QueryParams params = new QueryParams();
DefaultResourceInformationProvider builder = new DefaultResourceInformationProvider(new NullPropertiesProvider(), new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
builder.init(new DefaultResourceInformationProviderContext(builder, new DefaultInformationBuilder(moduleRegistry.getTypeParser()), moduleRegistry.getTypeParser(), new ObjectMapper()));
ResourceInformation info = builder.build(Task.class);
QueryParamsAdapter adapter = new QueryParamsAdapter(info, params, moduleRegistry);
Assert.assertEquals(Task.class, adapter.getResourceInformation().getResourceClass());
Assert.assertEquals(resourceRegistry, adapter.getResourceRegistry());
}
Aggregations