Search in sources :

Example 1 with SampleJsonServiceLocator

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

the class CrnkFeatureTest method testQuerySpecConstructor.

@Test
public void testQuerySpecConstructor() {
    ObjectMapper objectMapper = new ObjectMapper();
    QuerySpecDeserializer querySpecDeserializer = new DefaultQuerySpecDeserializer();
    SampleJsonServiceLocator serviceLocator = new SampleJsonServiceLocator();
    CrnkFeature feature = new CrnkFeature(objectMapper, querySpecDeserializer, serviceLocator);
    Assert.assertSame(objectMapper, feature.getObjectMapper());
    Assert.assertSame(querySpecDeserializer, feature.getBoot().getQuerySpecDeserializer());
}
Also used : QuerySpecDeserializer(io.crnk.core.queryspec.QuerySpecDeserializer) DefaultQuerySpecDeserializer(io.crnk.core.queryspec.DefaultQuerySpecDeserializer) DefaultQuerySpecDeserializer(io.crnk.core.queryspec.DefaultQuerySpecDeserializer) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with SampleJsonServiceLocator

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

the class JpaExceptionMapperTests method setup.

@Before
public void setup() {
    boot = new CrnkBoot();
    boot.addModule(JpaModule.newClientModule());
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.jpa.mock.model", new SampleJsonServiceLocator()));
    boot.boot();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) Before(org.junit.Before)

Example 3 with SampleJsonServiceLocator

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

the class AnnotatedRelationshipEntryBuilderTest method onInstanceOfAnnotatedRelationshipRepositoryShouldReturnTargetClass.

@Test
public void onInstanceOfAnnotatedRelationshipRepositoryShouldReturnTargetClass() {
    // GIVEN
    final AnnotatedRelationshipEntryBuilder builder = new AnnotatedRelationshipEntryBuilder(moduleRegistry, new RepositoryInstanceBuilder(new SampleJsonServiceLocator(), SimpleRelationshipRepository.class));
    // WHEN
    final String targetResourceType = builder.getTargetResourceType();
    // THEN
    assertThat(targetResourceType).isEqualTo("projects");
}
Also used : SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) AnnotatedRelationshipEntryBuilder(io.crnk.legacy.registry.AnnotatedRelationshipEntryBuilder) RepositoryInstanceBuilder(io.crnk.legacy.registry.RepositoryInstanceBuilder) Test(org.junit.Test)

Example 4 with SampleJsonServiceLocator

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

the class FallbackServiceDiscoveryFactoryTest method returnDefaultDiscoveryIfAvailable.

@Test
public void returnDefaultDiscoveryIfAvailable() {
    PropertiesProvider propertiesProvider = new NullPropertiesProvider();
    DefaultServiceDiscoveryFactory defaultFactory = new DefaultServiceDiscoveryFactory();
    FallbackServiceDiscoveryFactory fallbackFactory = new FallbackServiceDiscoveryFactory(defaultFactory, new SampleJsonServiceLocator(), propertiesProvider);
    Assert.assertTrue(fallbackFactory.getInstance() instanceof TestServiceDiscovery);
}
Also used : PropertiesProvider(io.crnk.core.engine.properties.PropertiesProvider) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) Test(org.junit.Test)

Example 5 with SampleJsonServiceLocator

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

the class FallbackServiceDiscoveryFactoryTest method fallbackToEmptyDiscoveryIfNoPackageAndDefaultAvailable.

@Test
public void fallbackToEmptyDiscoveryIfNoPackageAndDefaultAvailable() {
    PropertiesProvider propertiesProvider = Mockito.mock(PropertiesProvider.class);
    ServiceDiscoveryFactory defaultFactory = new ServiceDiscoveryFactory() {

        @Override
        public ServiceDiscovery getInstance() {
            return null;
        }
    };
    FallbackServiceDiscoveryFactory fallbackFactory = new FallbackServiceDiscoveryFactory(defaultFactory, new SampleJsonServiceLocator(), propertiesProvider);
    Assert.assertTrue(fallbackFactory.getInstance() instanceof EmptyServiceDiscovery);
}
Also used : PropertiesProvider(io.crnk.core.engine.properties.PropertiesProvider) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) Test(org.junit.Test)

Aggregations

SampleJsonServiceLocator (io.crnk.legacy.locator.SampleJsonServiceLocator)11 Test (org.junit.Test)7 CrnkBoot (io.crnk.core.boot.CrnkBoot)4 NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)4 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)3 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)3 RepositoryInstanceBuilder (io.crnk.legacy.registry.RepositoryInstanceBuilder)3 Before (org.junit.Before)3 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)2 Span (brave.Span)1 Tracer (brave.Tracer)1 Tracing (brave.Tracing)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 RepositoryRequestSpec (io.crnk.core.engine.dispatcher.RepositoryRequestSpec)1 RepositoryFilterContext (io.crnk.core.engine.filter.RepositoryFilterContext)1 RepositoryRequestFilterChain (io.crnk.core.engine.filter.RepositoryRequestFilterChain)1 ResourceRepositoryInformation (io.crnk.core.engine.information.repository.ResourceRepositoryInformation)1 ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)1