Search in sources :

Example 11 with ConstantServiceUrlProvider

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

the class HomeModuleTest method setup.

@Before
public void setup() {
    this.module = Mockito.spy(HomeModule.create(HomeFormat.JSON_HOME));
    boot = new CrnkBoot();
    boot.addModule(module);
    boot.addModule(new TestModule());
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
    boot.boot();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) TestModule(io.crnk.test.mock.TestModule) Before(org.junit.Before)

Example 12 with ConstantServiceUrlProvider

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

the class CdiRunner method run.

public void run(GeneratorTrigger context) throws IOException {
    Weld weld = new Weld();
    try {
        weld.setClassLoader(context.getClassLoader());
        weld.initialize();
        CrnkBoot boot = new CrnkBoot();
        boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://<generator>"));
        boot.boot();
        ModuleRegistry moduleRegistry = boot.getModuleRegistry();
        Optional<MetaModule> optionalModule = moduleRegistry.getModule(MetaModule.class);
        if (!optionalModule.isPresent()) {
            throw new IllegalStateException("add MetaModule to CDI setup, got: " + moduleRegistry.getModules() + " with " + boot.getServiceDiscovery());
        }
        MetaModule metaModule = optionalModule.get();
        MetaLookup lookup = metaModule.getLookup();
        context.generate(lookup);
    } finally {
        weld.shutdown();
    }
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) MetaLookup(io.crnk.meta.MetaLookup) ModuleRegistry(io.crnk.core.module.ModuleRegistry) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) MetaModule(io.crnk.meta.MetaModule) Weld(org.jboss.weld.environment.se.Weld)

Example 13 with ConstantServiceUrlProvider

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

the class ImplicitOwnerBasedRelationshipRepositoryTest 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 = new ImplicitOwnerBasedRelationshipRepository(RelationIdTestResource.class, Schedule.class);
    relRepository.setResourceRegistry(resourceRegistry);
    taskProjectRepository = new ImplicitOwnerBasedRelationshipRepository(Task.class, Project.class);
    taskProjectRepository.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) TaskRepository(io.crnk.core.mock.repository.TaskRepository) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) ScheduleRepositoryImpl(io.crnk.core.mock.repository.ScheduleRepositoryImpl) Project(io.crnk.core.mock.models.Project) CrnkBoot(io.crnk.core.boot.CrnkBoot) ImplicitOwnerBasedRelationshipRepository(io.crnk.core.repository.implicit.ImplicitOwnerBasedRelationshipRepository) 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 14 with ConstantServiceUrlProvider

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

the class DefaultQueryParamsSerializerTest method setup.

@Before
public void setup() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://127.0.0.1"));
    boot.boot();
    resourceRegistry = boot.getResourceRegistry();
    urlBuilder = new JsonApiUrlBuilder(resourceRegistry);
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder) Before(org.junit.Before)

Example 15 with ConstantServiceUrlProvider

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

the class DefaultQueryParamsSerializerTest method testPort.

@Test
public void testPort() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("https://127.0.0.1:1234"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.boot();
    resourceRegistry = boot.getResourceRegistry();
    urlBuilder = new JsonApiUrlBuilder(boot.getResourceRegistry());
    check("https://127.0.0.1:1234/tasks", null, new QueryParams());
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder) Test(org.junit.Test)

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