Search in sources :

Example 11 with Module

use of io.crnk.core.module.Module in project crnk-framework by crnk-project.

the class CrnkBootTest method testServiceDiscovery.

@Test
public void testServiceDiscovery() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscoveryFactory(serviceDiscoveryFactory);
    boot.setServiceUrlProvider(mock(ServiceUrlProvider.class));
    Module module = mock(Module.class);
    DocumentFilter filter = mock(DocumentFilter.class);
    JsonApiExceptionMapper exceptionMapper = new TestExceptionMapper();
    Mockito.when(serviceDiscovery.getInstancesByType(eq(DocumentFilter.class))).thenReturn(Arrays.asList(filter));
    Mockito.when(serviceDiscovery.getInstancesByType(eq(Module.class))).thenReturn(Arrays.asList(module));
    Mockito.when(serviceDiscovery.getInstancesByType(eq(JsonApiExceptionMapper.class))).thenReturn(Arrays.asList(exceptionMapper));
    boot.boot();
    ModuleRegistry moduleRegistry = boot.getModuleRegistry();
    Assert.assertTrue(moduleRegistry.getModules().contains(module));
    Assert.assertTrue(moduleRegistry.getFilters().contains(filter));
    Assert.assertTrue(moduleRegistry.getExceptionMapperLookup().getExceptionMappers().contains(exceptionMapper));
}
Also used : ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ServiceUrlProvider(io.crnk.core.engine.url.ServiceUrlProvider) ModuleRegistry(io.crnk.core.module.ModuleRegistry) DocumentFilter(io.crnk.core.engine.filter.DocumentFilter) SimpleModule(io.crnk.core.module.SimpleModule) Module(io.crnk.core.module.Module) JsonApiExceptionMapper(io.crnk.core.engine.error.JsonApiExceptionMapper) Test(org.junit.Test)

Example 12 with Module

use of io.crnk.core.module.Module in project crnk-framework by crnk-project.

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

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