Search in sources :

Example 1 with JsonServiceLocator

use of io.crnk.legacy.locator.JsonServiceLocator 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)

Example 2 with JsonServiceLocator

use of io.crnk.legacy.locator.JsonServiceLocator 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);
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JsonServiceLocator(io.crnk.legacy.locator.JsonServiceLocator) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) ResourceInformationProvider(io.crnk.core.engine.information.resource.ResourceInformationProvider) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JacksonResourceFieldInformationProvider(io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider) DefaultQuerySpecConverter(io.crnk.legacy.internal.DefaultQuerySpecConverter) SimpleModule(io.crnk.core.module.SimpleModule) DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider) Before(org.junit.Before)

Example 3 with JsonServiceLocator

use of io.crnk.legacy.locator.JsonServiceLocator in project crnk-framework by crnk-project.

the class AnnotatedRelationshipEntryBuilderTest method onInstanceOfAnonymousDescendantOfAnnotatedRelationshipRepositoryShouldReturnTargetClass.

@Test
public void onInstanceOfAnonymousDescendantOfAnnotatedRelationshipRepositoryShouldReturnTargetClass() {
    // GIVEN
    final AnnotatedRelationshipEntryBuilder builder = new AnnotatedRelationshipEntryBuilder(moduleRegistry, new RepositoryInstanceBuilder(new JsonServiceLocator() {

        @Override
        public <T> T getInstance(Class<T> clazz) {
            return (T) new SimpleRelationshipRepository() {
            };
        }
    }, SimpleRelationshipRepository.class));
    // WHEN
    final String targetResourceType = builder.getTargetResourceType();
    // THEN
    assertThat(targetResourceType).isEqualTo("projects");
}
Also used : AnnotatedRelationshipEntryBuilder(io.crnk.legacy.registry.AnnotatedRelationshipEntryBuilder) JsonServiceLocator(io.crnk.legacy.locator.JsonServiceLocator) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) RepositoryInstanceBuilder(io.crnk.legacy.registry.RepositoryInstanceBuilder) Test(org.junit.Test)

Example 4 with JsonServiceLocator

use of io.crnk.legacy.locator.JsonServiceLocator in project crnk-framework by crnk-project.

the class RepositoryInstanceBuilderTest method onNullInstanceShouldThrowException.

@Test(expected = RepositoryInstanceNotFoundException.class)
public void onNullInstanceShouldThrowException() throws Exception {
    // GIVEN
    RepositoryInstanceBuilder<TaskRepository> sut = new RepositoryInstanceBuilder<>(new JsonServiceLocator() {

        @Override
        public <T> T getInstance(Class<T> clazz) {
            return null;
        }
    }, TaskRepository.class);
    // WHEN
    sut.buildRepository();
}
Also used : TaskRepository(io.crnk.core.mock.repository.TaskRepository) JsonServiceLocator(io.crnk.legacy.locator.JsonServiceLocator) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) RepositoryInstanceBuilder(io.crnk.legacy.registry.RepositoryInstanceBuilder) Test(org.junit.Test)

Aggregations

JsonServiceLocator (io.crnk.legacy.locator.JsonServiceLocator)4 SampleJsonServiceLocator (io.crnk.legacy.locator.SampleJsonServiceLocator)3 Test (org.junit.Test)3 RepositoryInstanceBuilder (io.crnk.legacy.registry.RepositoryInstanceBuilder)2 CrnkBoot (io.crnk.core.boot.CrnkBoot)1 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)1 DefaultResourceFieldInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider)1 DefaultResourceInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider)1 JacksonResourceFieldInformationProvider (io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider)1 NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)1 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)1 TaskRepository (io.crnk.core.mock.repository.TaskRepository)1 SimpleModule (io.crnk.core.module.SimpleModule)1 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)1 ServiceDiscoveryFactory (io.crnk.core.module.discovery.ServiceDiscoveryFactory)1 DefaultQuerySpecConverter (io.crnk.legacy.internal.DefaultQuerySpecConverter)1 AnnotatedRelationshipEntryBuilder (io.crnk.legacy.registry.AnnotatedRelationshipEntryBuilder)1 Before (org.junit.Before)1