use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class FilterTest 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));
// GIVEN
filter = mock(TestFilter.class);
SimpleModule filterModule = new SimpleModule("filter");
filterModule.addFilter(filter);
boot.addModule(filterModule);
boot.boot();
resourceRegistry = boot.getResourceRegistry();
moduleRegistry = boot.getModuleRegistry();
pathBuilder = new PathBuilder(resourceRegistry);
ControllerRegistry controllerRegistry = new ControllerRegistry(null);
collectionGet = mock(CollectionGet.class);
controllerRegistry.addController(collectionGet);
QuerySpecAdapterBuilder queryAdapterBuilder = new QuerySpecAdapterBuilder(new DefaultQuerySpecDeserializer(), moduleRegistry);
dispatcher = new HttpRequestProcessorImpl(moduleRegistry, controllerRegistry, null, queryAdapterBuilder);
}
use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class RepositoryFilterTest 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.addRepositoryFilter(filter);
boot.addModule(filterModule);
boot.boot();
resourceRegistry = boot.getResourceRegistry();
querySpec = new QuerySpec(User.class);
querySpec.setPagingSpec(new OffsetLimitPagingSpec());
queryAdapter = new QuerySpecAdapter(querySpec, resourceRegistry);
scheduleInfo = resourceRegistry.getEntry(Schedule.class).getResourceInformation();
RegistryEntry userEntry = resourceRegistry.getEntry(User.class);
resourceAdapter = userEntry.getResourceRepository(null);
projectRelationAdapter = userEntry.getRelationshipRepository("assignedProjects", null);
taskRelationAdapter = userEntry.getRelationshipRepository("assignedTasks", null);
userInfo = userEntry.getResourceInformation();
UserRepository resourceRepository = (UserRepository) resourceAdapter.getResourceRepository();
user1 = new User();
user1.setId(1L);
resourceRepository.save(user1);
user2 = new User();
user2.setId(2L);
resourceRepository.save(user2);
UserToProjectRepository userProjectRepository = (UserToProjectRepository) ((AnnotatedRelationshipRepositoryAdapter<?, ?, ?, ?>) projectRelationAdapter.getRelationshipRepository()).getImplementationObject();
userProjectRepository.setRelation(user1, 11L, "assignedProjects");
UserToTaskRepository userTaskRepository = new UserToTaskRepository();
userTaskRepository.addRelations(user1, Arrays.asList(21L), "assignedTasks");
userTaskRepository.addRelations(user2, Arrays.asList(22L), "assignedTasks");
assignedTasksField = resourceRegistry.getEntry(User.class).getResourceInformation().findRelationshipFieldByName("assignedTasks");
assignedProjectsField = resourceRegistry.getEntry(User.class).getResourceInformation().findRelationshipFieldByName("assignedProjects");
}
use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class DropwizardService method run.
@Override
public void run(DropwizardConfiguration dropwizardConfiguration, Environment environment) throws Exception {
// here we make use of a module as example instead of using service discovery (CDI, Spring, etc.)
// tag::docs[]
SimpleModule module = new SimpleModule("example");
module.addRepository(new ProjectRepository());
CrnkFeature crnkFeature = new CrnkFeature();
crnkFeature.addModule(module);
environment.jersey().register(crnkFeature);
// end::docs[]
}
use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class JsonApiActionResponseTest method setupFeature.
@Override
protected void setupFeature(CrnkTestFeature feature) {
filter = Mockito.spy(new DocumentFilter() {
@Override
public Response filter(DocumentFilterContext filterRequestContext, DocumentFilterChain chain) {
return chain.doFilter(filterRequestContext);
}
});
SimpleModule testModule = new SimpleModule("testFilter");
testModule.addFilter(filter);
feature.addModule(testModule);
}
use of io.crnk.core.module.SimpleModule in project crnk-framework by crnk-project.
the class AbstractQueryParamsTest method setup.
@Before
public void setup() {
JsonServiceLocator jsonServiceLocator = new SampleJsonServiceLocator();
ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(new NullPropertiesProvider(), (PagingBehavior) null, new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
SimpleModule testModule = new SimpleModule("test");
CrnkBoot boot = new CrnkBoot();
boot.addModule(testModule);
boot.boot();
moduleRegistry = boot.getModuleRegistry();
resourceRegistry = boot.getResourceRegistry();
converter = new DefaultQueryParamsConverter(resourceRegistry);
paramsToSpecConverter = new DefaultQuerySpecConverter(moduleRegistry);
}
Aggregations