use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class ApprovalTestApplication method createApprovalModule.
// tag::approvalModule[]
public static SimpleModule createApprovalModule(ApprovalManager approvalManager) {
FilterSpec approvalFilter = new FilterSpec(Arrays.asList("definitionKey"), FilterOperator.EQ, "scheduleChange");
List<FilterSpec> approvalFilters = Arrays.asList(approvalFilter);
SimpleModule module = new SimpleModule("approval");
module.addRepositoryDecoratorFactory(ApprovalRepositoryDecorator.createFactory(approvalManager));
module.addRepository(new ApprovalRelationshipRepository(Schedule.class, ScheduleApprovalProcessInstance.class, "approval", "approval/schedule", approvalFilters));
return module;
}
use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class HomeResourceFilteringTest method setup.
@Before
public void setup() {
filter = Mockito.mock(ResourceFilter.class);
SimpleModule filterModule = new SimpleModule("filter");
filterModule.addResourceFilter(filter);
this.module = Mockito.spy(HomeModule.create());
boot = new CrnkBoot();
boot.addModule(module);
boot.addModule(new TestModule());
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.addModule(filterModule);
boot.boot();
}
use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class ResourceFilterTest method prepare.
@Before
public void prepare() {
boot = new CrnkBoot();
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
SimpleModule filterModule = new SimpleModule("filter");
filterModule.addResourceFilter(filter);
boot.addModule(filterModule);
boot.boot();
resourceRegistry = boot.getResourceRegistry();
}
use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class CrnkBootTest method setInvalidRepository.
@Test
public void setInvalidRepository() {
SimpleModule module = new SimpleModule("test");
module.addRepository("not a repository");
CrnkBoot boot = new CrnkBoot();
boot.boot();
}
use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class CrnkBootTest method boot.
@Test
public void boot() {
CrnkBoot boot = new CrnkBoot();
boot.setDefaultServiceUrlProvider(new ServiceUrlProvider() {
@Override
public String getUrl() {
return "http://127.0.0.1";
}
});
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.addModule(new SimpleModule("test"));
boot.boot();
RequestDispatcher requestDispatcher = boot.getRequestDispatcher();
ResourceRegistry resourceRegistry = boot.getResourceRegistry();
RegistryEntry taskEntry = resourceRegistry.getEntry(Task.class);
Assert.assertNotEquals(0, taskEntry.getRelationshipEntries().size());
ResourceRepositoryAdapter<?, ?> repositoryAdapter = taskEntry.getResourceRepository(null);
Assert.assertNotNull(repositoryAdapter.getResourceRepository());
JsonApiResponse response = repositoryAdapter.findAll(new QueryParamsAdapter(taskEntry.getResourceInformation(), new QueryParams(), boot.getModuleRegistry()));
Assert.assertNotNull(response);
Assert.assertNotNull(requestDispatcher);
ServiceDiscovery serviceDiscovery = boot.getServiceDiscovery();
Assert.assertNotNull(serviceDiscovery);
Assert.assertNotNull(boot.getModuleRegistry());
Assert.assertNotNull(boot.getExceptionMapperRegistry());
List<Module> modules = boot.getModuleRegistry().getModules();
Assert.assertEquals(4, modules.size());
boot.setDefaultPageLimit(20L);
boot.setMaxPageLimit(100L);
Assert.assertEquals(1, boot.getPagingBehaviors().size());
Assert.assertTrue(boot.getPagingBehaviors().get(0) instanceof OffsetLimitPagingBehavior);
}
Aggregations