use of io.crnk.core.module.Module in project crnk-framework by crnk-project.
the class ClientModuleFactoryTest method shouldDiscoverObjectLinkModules.
@Test
public void shouldDiscoverObjectLinkModules() {
CrnkClient client = new CrnkClient("http://something", CrnkClient.ClientType.OBJECT_LINKS);
client.findModules();
List<Module> modules = client.getModuleRegistry().getModules();
Assert.assertEquals(3, modules.size());
Assert.assertEquals(ClientModule.class, modules.get(0).getClass());
Assert.assertEquals(JacksonModule.class, modules.get(1).getClass());
Assert.assertEquals(ClientTestModule.class, modules.get(2).getClass());
}
use of io.crnk.core.module.Module in project crnk-framework by crnk-project.
the class SecurityClientModuleFactoryTest method test.
@Test
public void test() {
ServiceLoader<ClientModuleFactory> loader = ServiceLoader.load(ClientModuleFactory.class);
Iterator<ClientModuleFactory> iterator = loader.iterator();
Assert.assertTrue(iterator.hasNext());
ClientModuleFactory moduleFactory = iterator.next();
Assert.assertFalse(iterator.hasNext());
Module module = moduleFactory.create();
Assert.assertTrue(module instanceof SecurityModule);
}
use of io.crnk.core.module.Module in project crnk-framework by crnk-project.
the class ClientModuleFactoryTest method shouldDiscoverModules.
@Test
public void shouldDiscoverModules() {
CrnkClient client = new CrnkClient("http://something");
client.findModules();
List<Module> modules = client.getModuleRegistry().getModules();
Assert.assertEquals(3, modules.size());
Assert.assertEquals(ClientModule.class, modules.get(0).getClass());
Assert.assertEquals(JacksonModule.class, modules.get(1).getClass());
Assert.assertEquals(ClientTestModule.class, modules.get(2).getClass());
}
use of io.crnk.core.module.Module in project crnk-framework by crnk-project.
the class CrnkBoot method addModules.
private void addModules() {
for (Module module : registeredModules) {
moduleRegistry.addModule(module);
}
boolean serializeLinksAsObjects = Boolean.parseBoolean(propertiesProvider.getProperty(CrnkProperties.SERIALIZE_LINKS_AS_OBJECTS));
moduleRegistry.addModule(new JacksonModule(objectMapper, serializeLinksAsObjects, moduleRegistry.getPagingBehaviors()));
List<Module> discoveredModules = getInstancesByType(Module.class);
for (Module module : discoveredModules) {
moduleRegistry.addModule(module);
}
}
use of io.crnk.core.module.Module in project crnk-framework by crnk-project.
the class CrnkClient method setHttpAdapter.
public void setHttpAdapter(HttpAdapter httpAdapter) {
this.httpAdapter = httpAdapter;
List<Module> modules = moduleRegistry.getModules();
for (Module module : modules) {
if (module instanceof HttpAdapterAware) {
((HttpAdapterAware) module).setHttpAdapter(getHttpAdapter());
}
}
}
Aggregations