use of io.crnk.core.engine.internal.exception.ExceptionMapperLookup in project crnk-framework by crnk-project.
the class ModuleRegistryTest method testExceptionMappers.
@Test
public void testExceptionMappers() {
ExceptionMapperLookup exceptionMapperLookup = moduleRegistry.getExceptionMapperLookup();
Set<JsonApiExceptionMapper> exceptionMappers = exceptionMapperLookup.getExceptionMappers();
Set<Class<?>> classes = new HashSet<>();
for (JsonApiExceptionMapper exceptionMapper : exceptionMappers) {
classes.add(exceptionMapper.getClass());
}
Assert.assertTrue(classes.contains(IllegalStateExceptionMapper.class));
Assert.assertTrue(classes.contains(SomeIllegalStateExceptionMapper.class));
}
use of io.crnk.core.engine.internal.exception.ExceptionMapperLookup in project crnk-framework by crnk-project.
the class SimpleModule method addExceptionMapper.
public void addExceptionMapper(@SuppressWarnings("rawtypes") JsonApiExceptionMapper exceptionMapper) {
checkInitialized();
ExceptionMapperLookup exceptionMapperLookup = new CollectionExceptionMapperLookup(exceptionMapper);
exceptionMapperLookups.add(exceptionMapperLookup);
}
use of io.crnk.core.engine.internal.exception.ExceptionMapperLookup in project crnk-framework by crnk-project.
the class ModuleRegistry method init.
/**
* Initializes the {@link ModuleRegistry} and applies all pending changes.
* After the initialization completed, it is not possible to add any further
* modules.
*
* @param objectMapper object mapper
*/
public void init(ObjectMapper objectMapper) {
PreconditionUtil.assertEquals("already initialized", InitializedState.NOT_INITIALIZED, initializedState);
this.initializedState = InitializedState.INITIALIZING;
this.objectMapper = objectMapper;
this.objectMapper.registerModules(getJacksonModules());
initializeModules();
applyRepositoryRegistrations();
ExceptionMapperLookup exceptionMapperLookup = getExceptionMapperLookup();
ExceptionMapperRegistryBuilder mapperRegistryBuilder = new ExceptionMapperRegistryBuilder();
exceptionMapperRegistry = mapperRegistryBuilder.build(exceptionMapperLookup);
filterBehaviorProvider = new ResourceFilterDirectoryImpl(aggregatedModule.getResourceFilters(), httpRequestContextProvider, resourceRegistry);
this.initializedState = InitializedState.INITIALIZED;
}
use of io.crnk.core.engine.internal.exception.ExceptionMapperLookup in project crnk-framework by crnk-project.
the class CrnkClient method initExceptionMapperRegistry.
private void initExceptionMapperRegistry() {
ExceptionMapperLookup exceptionMapperLookup = moduleRegistry.getExceptionMapperLookup();
exceptionMapperRegistry = new ExceptionMapperRegistryBuilder().build(exceptionMapperLookup);
}
Aggregations