Search in sources :

Example 6 with Module

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());
}
Also used : CrnkClient(io.crnk.client.CrnkClient) JacksonModule(io.crnk.core.engine.internal.jackson.JacksonModule) Module(io.crnk.core.module.Module) Test(org.junit.Test)

Example 7 with Module

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);
}
Also used : ClientModuleFactory(io.crnk.client.module.ClientModuleFactory) Module(io.crnk.core.module.Module) Test(org.junit.Test)

Example 8 with Module

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());
}
Also used : CrnkClient(io.crnk.client.CrnkClient) JacksonModule(io.crnk.core.engine.internal.jackson.JacksonModule) Module(io.crnk.core.module.Module) Test(org.junit.Test)

Example 9 with Module

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);
    }
}
Also used : JacksonModule(io.crnk.core.engine.internal.jackson.JacksonModule) CoreModule(io.crnk.core.engine.internal.CoreModule) SimpleModule(io.crnk.core.module.SimpleModule) Module(io.crnk.core.module.Module) JacksonModule(io.crnk.core.engine.internal.jackson.JacksonModule)

Example 10 with 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());
        }
    }
}
Also used : Module(io.crnk.core.module.Module) JacksonModule(io.crnk.core.engine.internal.jackson.JacksonModule) ClientModule(io.crnk.client.module.ClientModule) HttpAdapterAware(io.crnk.client.module.HttpAdapterAware)

Aggregations

Module (io.crnk.core.module.Module)12 Test (org.junit.Test)8 ClientModuleFactory (io.crnk.client.module.ClientModuleFactory)5 JacksonModule (io.crnk.core.engine.internal.jackson.JacksonModule)5 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)3 SimpleModule (io.crnk.core.module.SimpleModule)3 CrnkClient (io.crnk.client.CrnkClient)2 ClientModule (io.crnk.client.module.ClientModule)2 ServiceUrlProvider (io.crnk.core.engine.url.ServiceUrlProvider)2 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)2 MetaModule (io.crnk.meta.MetaModule)2 HashSet (java.util.HashSet)2 HttpAdapterAware (io.crnk.client.module.HttpAdapterAware)1 CrnkBoot (io.crnk.core.boot.CrnkBoot)1 RequestDispatcher (io.crnk.core.engine.dispatcher.RequestDispatcher)1 JsonApiExceptionMapper (io.crnk.core.engine.error.JsonApiExceptionMapper)1 DocumentFilter (io.crnk.core.engine.filter.DocumentFilter)1 CoreModule (io.crnk.core.engine.internal.CoreModule)1 HttpRequestContextBaseAdapter (io.crnk.core.engine.internal.http.HttpRequestContextBaseAdapter)1 JsonApiRequestProcessor (io.crnk.core.engine.internal.http.JsonApiRequestProcessor)1