Search in sources :

Example 11 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot 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();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) SimpleModule(io.crnk.core.module.SimpleModule) Before(org.junit.Before)

Example 12 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.

the class BaseControllerTest method prepare.

@Before
public void prepare() {
    modificationFilter = Mockito.spy(new ResourceModificationFilterBase());
    modificationFilters = Arrays.asList(modificationFilter);
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.boot();
    objectMapper = boot.getObjectMapper();
    resourceRegistry = boot.getResourceRegistry();
    moduleRegistry = boot.getModuleRegistry();
    pathBuilder = new PathBuilder(resourceRegistry);
    typeParser = moduleRegistry.getTypeParser();
    documentMapper = boot.getDocumentMapper();
    MockRepositoryUtil.clear();
    emptyTaskQuery = new QuerySpecAdapter(new QuerySpec(Task.class), resourceRegistry);
    emptyProjectQuery = new QuerySpecAdapter(new QuerySpec(Project.class), resourceRegistry);
    emptyUserQuery = new QuerySpecAdapter(new QuerySpec(User.class), resourceRegistry);
    emptyComplexPojoQuery = new QuerySpecAdapter(new QuerySpec(ComplexPojo.class), resourceRegistry);
    emptyMemorandumQuery = new QuerySpecAdapter(new QuerySpec(Memorandum.class), resourceRegistry);
}
Also used : PathBuilder(io.crnk.core.engine.internal.dispatcher.path.PathBuilder) CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ResourceModificationFilterBase(io.crnk.core.engine.filter.ResourceModificationFilterBase) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) QuerySpec(io.crnk.core.queryspec.QuerySpec) Before(org.junit.Before)

Example 13 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot 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);
}
Also used : ControllerRegistry(io.crnk.core.engine.internal.dispatcher.ControllerRegistry) PathBuilder(io.crnk.core.engine.internal.dispatcher.path.PathBuilder) CrnkBoot(io.crnk.core.boot.CrnkBoot) CollectionGet(io.crnk.core.engine.internal.dispatcher.controller.CollectionGet) QuerySpecAdapterBuilder(io.crnk.core.queryspec.internal.QuerySpecAdapterBuilder) DefaultQuerySpecDeserializer(io.crnk.core.queryspec.DefaultQuerySpecDeserializer) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) SimpleModule(io.crnk.core.module.SimpleModule) HttpRequestProcessorImpl(io.crnk.core.engine.internal.http.HttpRequestProcessorImpl) Before(org.junit.Before)

Example 14 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot 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");
}
Also used : UserToProjectRepository(io.crnk.core.mock.repository.UserToProjectRepository) CrnkBoot(io.crnk.core.boot.CrnkBoot) User(io.crnk.core.mock.models.User) UserRepository(io.crnk.core.mock.repository.UserRepository) OffsetLimitPagingSpec(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingSpec) UserToTaskRepository(io.crnk.core.mock.repository.UserToTaskRepository) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) QuerySpec(io.crnk.core.queryspec.QuerySpec) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) SimpleModule(io.crnk.core.module.SimpleModule) Before(org.junit.Before)

Example 15 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.

the class MetaModuleTest method setupBoot.

private void setupBoot() {
    boot = new CrnkBoot();
    boot.addModule(new JaxrsModule(null));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
    boot.addModule(metaModule);
    boot.boot();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) JaxrsModule(io.crnk.rs.internal.JaxrsModule) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider)

Aggregations

CrnkBoot (io.crnk.core.boot.CrnkBoot)54 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)34 Before (org.junit.Before)34 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)28 Test (org.junit.Test)11 TestModule (io.crnk.test.mock.TestModule)9 SimpleModule (io.crnk.core.module.SimpleModule)7 JsonApiUrlBuilder (io.crnk.core.engine.internal.utils.JsonApiUrlBuilder)6 ResourceMetaProvider (io.crnk.meta.provider.resource.ResourceMetaProvider)6 MetaModule (io.crnk.meta.MetaModule)5 NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)4 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)4 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)4 Task (io.crnk.core.mock.models.Task)4 TaskRepository (io.crnk.core.mock.repository.TaskRepository)4 QuerySpec (io.crnk.core.queryspec.QuerySpec)4 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)4 JaxrsModule (io.crnk.rs.internal.JaxrsModule)4 JsonApiExceptionMapper (io.crnk.core.engine.error.JsonApiExceptionMapper)3 HttpRequestContextProvider (io.crnk.core.engine.http.HttpRequestContextProvider)3