Search in sources :

Example 1 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery in project crnk-framework by crnk-project.

the class HttpRequestProcessorImplTest method prepare.

@Before
public void prepare() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.addModule(new ActionTestModule());
    boot.boot();
    resourceRegistry = boot.getResourceRegistry();
    moduleRegistry = boot.getModuleRegistry();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) Before(org.junit.Before)

Example 2 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery in project crnk-framework by crnk-project.

the class JsonApiRequestProcessorTest method setup.

@Before
public void setup() {
    TaskRepository.clear();
    boot = new CrnkBoot();
    boot.addModule(new Module() {

        @Override
        public String getModuleName() {
            return "test";
        }

        @Override
        public void setupModule(ModuleContext context) {
            moduleContext = context;
        }
    });
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost:8080"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.boot();
    Task task = new Task();
    task.setId(1L);
    task.setName("SomeTask");
    task.setLinksInformation(new TaskLinks());
    TaskRepository tasks = new TaskRepository();
    tasks.save(task);
    processor = new JsonApiRequestProcessor(moduleContext);
    requestContextBase = Mockito.mock(HttpRequestContextBase.class);
    requestContext = new HttpRequestContextBaseAdapter(requestContextBase);
    HttpRequestContextProvider requestContextProvider = boot.getModuleRegistry().getHttpRequestContextProvider();
    requestContextProvider.onRequestStarted(requestContext);
}
Also used : HttpRequestContextBaseAdapter(io.crnk.core.engine.internal.http.HttpRequestContextBaseAdapter) Task(io.crnk.core.mock.models.Task) TaskRepository(io.crnk.core.mock.repository.TaskRepository) JsonApiRequestProcessor(io.crnk.core.engine.internal.http.JsonApiRequestProcessor) CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) Module(io.crnk.core.module.Module) TaskLinks(io.crnk.core.mock.models.TaskLinks) Before(org.junit.Before)

Example 3 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery 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 4 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery 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 5 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery in project crnk-framework by crnk-project.

the class CrnkBootTest method setServiceLocator.

@Test
public void setServiceLocator() {
    JsonServiceLocator locator = mock(JsonServiceLocator.class);
    PropertiesProvider propertiesProvider = mock(PropertiesProvider.class);
    Mockito.when(propertiesProvider.getProperty(eq(CrnkProperties.RESOURCE_SEARCH_PACKAGE))).thenReturn("a.b.c");
    CrnkBoot boot = new CrnkBoot();
    boot.setPropertiesProvider(propertiesProvider);
    boot.setServiceLocator(locator);
    boot.setServiceDiscoveryFactory(mock(ServiceDiscoveryFactory.class));
    boot.boot();
    ReflectionsServiceDiscovery serviceDiscovery = (ReflectionsServiceDiscovery) boot.getServiceDiscovery();
    Assert.assertSame(locator, serviceDiscovery.getLocator());
}
Also used : PropertiesProvider(io.crnk.core.engine.properties.PropertiesProvider) ServiceDiscoveryFactory(io.crnk.core.module.discovery.ServiceDiscoveryFactory) JsonServiceLocator(io.crnk.legacy.locator.JsonServiceLocator) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) Test(org.junit.Test)

Aggregations

ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)30 CrnkBoot (io.crnk.core.boot.CrnkBoot)28 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)25 Before (org.junit.Before)22 Test (org.junit.Test)7 JsonApiUrlBuilder (io.crnk.core.engine.internal.utils.JsonApiUrlBuilder)6 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)5 Task (io.crnk.core.mock.models.Task)5 SimpleModule (io.crnk.core.module.SimpleModule)4 RelationIdTestResource (io.crnk.core.mock.models.RelationIdTestResource)3 PathBuilder (io.crnk.core.engine.internal.dispatcher.path.PathBuilder)2 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)2 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)2 Project (io.crnk.core.mock.models.Project)2 Schedule (io.crnk.core.mock.models.Schedule)2 User (io.crnk.core.mock.models.User)2 ProjectRepository (io.crnk.core.mock.repository.ProjectRepository)2 ScheduleRepositoryImpl (io.crnk.core.mock.repository.ScheduleRepositoryImpl)2 TaskRepository (io.crnk.core.mock.repository.TaskRepository)2 Module (io.crnk.core.module.Module)2