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));
}
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);
}
Aggregations