Search in sources :

Example 21 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class DocumentSerializerTest method setup.

@Before
public void setup() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
    boot.boot();
    objectMapper = boot.getObjectMapper();
    objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    reader = objectMapper.reader().forType(Document.class);
    writer = objectMapper.writer();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) Before(org.junit.Before)

Example 22 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class RelationshipRepositoryBehaviorTest method setup.

@Before
public void setup() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.boot();
    resourceRegistry = boot.getResourceRegistry();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) Before(org.junit.Before)

Example 23 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class CrnkConfigV3Test method checkProperties.

@Test
public void checkProperties() {
    ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
    Mockito.when(applicationContext.getEnvironment()).thenReturn(Mockito.mock(Environment.class));
    CrnkSpringBootProperties properties = new CrnkSpringBootProperties();
    properties.setDomainName("testDomain");
    properties.setDefaultPageLimit(12L);
    properties.setMaxPageLimit(20L);
    properties.setPathPrefix("prefix");
    properties.setAllowUnknownAttributes(true);
    properties.setReturn404OnNull(true);
    properties.setResourcePackage("ch.something");
    ObjectMapper objectMapper = new ObjectMapper();
    CrnkConfigV3 config = new CrnkConfigV3(properties, objectMapper);
    config.setApplicationContext(applicationContext);
    SpringServiceDiscovery serviceDiscovery = Mockito.mock(SpringServiceDiscovery.class);
    CrnkBoot boot = config.crnkBoot(serviceDiscovery);
    PropertiesProvider propertiesProvider = boot.getPropertiesProvider();
    Assert.assertEquals("testDomain", propertiesProvider.getProperty(CrnkProperties.RESOURCE_DEFAULT_DOMAIN));
    Assert.assertEquals("ch.something", propertiesProvider.getProperty(CrnkProperties.RESOURCE_SEARCH_PACKAGE));
    Assert.assertEquals("prefix", propertiesProvider.getProperty(CrnkProperties.WEB_PATH_PREFIX));
    Assert.assertEquals("true", propertiesProvider.getProperty(CrnkProperties.ALLOW_UNKNOWN_ATTRIBUTES));
    Assert.assertEquals("true", propertiesProvider.getProperty(CrnkProperties.RETURN_404_ON_NULL));
    DefaultQuerySpecDeserializer deserializer = (DefaultQuerySpecDeserializer) boot.getQuerySpecDeserializer();
    Assert.assertTrue(deserializer.getAllowUnknownAttributes());
    ConstantServiceUrlProvider constantServiceUrlProvider = (ConstantServiceUrlProvider) boot.getServiceUrlProvider();
    Assert.assertEquals("testDomainprefix", constantServiceUrlProvider.getUrl());
    Assert.assertSame(objectMapper, boot.getObjectMapper());
    Assert.assertNotNull(boot.getModuleRegistry().getSecurityProvider());
}
Also used : PropertiesProvider(io.crnk.core.engine.properties.PropertiesProvider) ApplicationContext(org.springframework.context.ApplicationContext) CrnkBoot(io.crnk.core.boot.CrnkBoot) DefaultQuerySpecDeserializer(io.crnk.core.queryspec.DefaultQuerySpecDeserializer) Environment(org.springframework.core.env.Environment) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) CrnkSpringBootProperties(io.crnk.spring.boot.CrnkSpringBootProperties) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CrnkConfigV3(io.crnk.spring.boot.v3.CrnkConfigV3) SpringServiceDiscovery(io.crnk.spring.internal.SpringServiceDiscovery) Test(org.junit.Test)

Example 24 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class OwnerFowardingRelationshipRepositoryTest method setup.

@Before
public void setup() {
    MockRepositoryUtil.clear();
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
    boot.boot();
    resourceRegistry = boot.getResourceRegistry();
    RegistryEntry entry = resourceRegistry.getEntry(RelationIdTestResource.class);
    relRepository = (ForwardingRelationshipRepository) entry.getRelationshipRepository("testSerializeEager", null).getRelationshipRepository();
    RelationshipMatcher taskProjectMatcher = new RelationshipMatcher().rule().source(Task.class).target(Project.class).add();
    taskProjectRepository = new ForwardingRelationshipRepository(Task.class, taskProjectMatcher, ForwardingDirection.OWNER, ForwardingDirection.OWNER);
    taskProjectRepository.setResourceRegistry(resourceRegistry);
    projectTaskRepository = new ForwardingRelationshipRepository(Project.class, taskProjectMatcher, ForwardingDirection.OWNER, ForwardingDirection.OWNER);
    projectTaskRepository.setResourceRegistry(resourceRegistry);
    testRepository = (RelationIdTestRepository) entry.getResourceRepository().getResourceRepository();
    testRepository.setResourceRegistry(resourceRegistry);
    resource = new RelationIdTestResource();
    resource.setId(2L);
    resource.setName("relationId");
    testRepository.create(resource);
    scheduleRepository = new ScheduleRepositoryImpl();
    schedule3 = new Schedule();
    schedule3.setId(3L);
    schedule3.setName("schedule");
    scheduleRepository.create(schedule3);
    for (int i = 0; i < 10; i++) {
        schedule = new Schedule();
        schedule.setId(4L + i);
        schedule.setName("schedule");
        scheduleRepository.create(schedule);
        projectRepository = new ProjectRepository();
        project = new Project();
        project.setId(42L + i);
        project.setName("project");
        projectRepository.save(project);
        taskRepository = new TaskRepository();
        task = new Task();
        task.setId(13L + i);
        task.setName("task");
        taskRepository.save(task);
    }
}
Also used : Task(io.crnk.core.mock.models.Task) ProjectRepository(io.crnk.core.mock.repository.ProjectRepository) ForwardingRelationshipRepository(io.crnk.core.repository.foward.ForwardingRelationshipRepository) TaskRepository(io.crnk.core.mock.repository.TaskRepository) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) RelationshipMatcher(io.crnk.core.repository.RelationshipMatcher) ScheduleRepositoryImpl(io.crnk.core.mock.repository.ScheduleRepositoryImpl) Project(io.crnk.core.mock.models.Project) CrnkBoot(io.crnk.core.boot.CrnkBoot) Schedule(io.crnk.core.mock.models.Schedule) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) RelationIdTestResource(io.crnk.core.mock.models.RelationIdTestResource) Before(org.junit.Before)

Example 25 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class RegistryEntryFacadeTest method setup.

@Before
public void setup() {
    MockRepositoryUtil.clear();
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
    boot.boot();
    user1 = new User();
    user1.setName("test1");
    user1.setId(13L);
    repository.save(user1);
    user2 = new User();
    user2.setName("test2");
    user2.setId(14L);
    repository.save(user2);
    entry = boot.getResourceRegistry().getEntry(User.class);
    facade = entry.getResourceRepositoryFacade();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) User(io.crnk.core.mock.models.User) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) Before(org.junit.Before)

Aggregations

ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)40 CrnkBoot (io.crnk.core.boot.CrnkBoot)34 Before (org.junit.Before)27 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)24 Test (org.junit.Test)8 JsonApiUrlBuilder (io.crnk.core.engine.internal.utils.JsonApiUrlBuilder)6 TestModule (io.crnk.test.mock.TestModule)6 Task (io.crnk.core.mock.models.Task)5 ResourceMetaProvider (io.crnk.meta.provider.resource.ResourceMetaProvider)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 ResourceRegistryImpl (io.crnk.core.engine.internal.registry.ResourceRegistryImpl)4 DefaultResourceRegistryPart (io.crnk.core.engine.registry.DefaultResourceRegistryPart)4 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)4 SimpleModule (io.crnk.core.module.SimpleModule)4 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)3 RelationIdTestResource (io.crnk.core.mock.models.RelationIdTestResource)3 ModuleRegistry (io.crnk.core.module.ModuleRegistry)3 CoreModule (io.crnk.core.engine.internal.CoreModule)2 PathBuilder (io.crnk.core.engine.internal.dispatcher.path.PathBuilder)2 DefaultInformationBuilder (io.crnk.core.engine.internal.information.DefaultInformationBuilder)2