Search in sources :

Example 36 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.

the class HttpRequestContextAwareTest method check.

@Test
public void check() throws IOException {
    HttTestModule testModule = Mockito.mock(HttTestModule.class);
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost:8080"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.addModule(testModule);
    boot.boot();
    Mockito.verify(testModule, Mockito.times(1)).setHttpRequestContextProvider(Mockito.any(HttpRequestContextProvider.class));
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) Test(org.junit.Test)

Example 37 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.

the class ResourceFieldContributorTest method setup.

@Before
public void setup() {
    MockRepositoryUtil.clear();
    contributedRepository = Mockito.spy(new ContributorRelationshipRepository());
    SimpleModule testModule = new SimpleModule("test");
    testModule.addRepository(new TaskRepository());
    testModule.addRepository(new ProjectRepository());
    testModule.addRepository(new ProjectToTaskRepository());
    testModule.addRepository(contributedRepository);
    boot = new CrnkBoot();
    boot.setServiceDiscovery(new TestServiceDiscovery());
    boot.addModule(testModule);
    boot.boot();
}
Also used : ProjectRepository(io.crnk.core.mock.repository.ProjectRepository) CrnkBoot(io.crnk.core.boot.CrnkBoot) ProjectToTaskRepository(io.crnk.core.mock.repository.ProjectToTaskRepository) TestServiceDiscovery(io.crnk.core.module.discovery.TestServiceDiscovery) ProjectToTaskRepository(io.crnk.core.mock.repository.ProjectToTaskRepository) TaskRepository(io.crnk.core.mock.repository.TaskRepository) SimpleModule(io.crnk.core.module.SimpleModule) Before(org.junit.Before)

Example 38 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.

the class PathBuilderTest method prepare.

@Before
public void prepare() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
    boot.boot();
    pathBuilder = new PathBuilder(boot.getResourceRegistry());
    RegistryEntry entry = boot.getResourceRegistry().findEntry(Task.class);
    ResourceRepositoryInformation repositoryInformation = entry.getRepositoryInformation();
    repositoryInformation.getActions().put("someRepositoryAction", Mockito.mock(RepositoryAction.class));
    repositoryInformation.getActions().put("someResourceAction", Mockito.mock(RepositoryAction.class));
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ResourceRepositoryInformation(io.crnk.core.engine.information.repository.ResourceRepositoryInformation) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) RepositoryAction(io.crnk.core.engine.information.repository.RepositoryAction) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) Before(org.junit.Before)

Example 39 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.

the class ControllerRegistryTest method prepare.

@Before
public void prepare() {
    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();
}
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 40 with CrnkBoot

use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.

the class ConstraintViolationImplTest method setup.

@Before
public void setup() {
    boot = new CrnkBoot();
    boot.addModule(ValidationModule.create());
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.validation.mock.repository"));
    boot.boot();
    errorData = Mockito.spy(new ErrorDataBuilder().setDetail("testMessage").addMetaField(ConstraintViolationExceptionMapper.META_RESOURCE_TYPE, "tasks").setSourcePointer("name").build());
    ResourceRegistry resourceRegistry = boot.getResourceRegistry();
    violation = ConstraintViolationImpl.fromError(resourceRegistry, errorData);
}
Also used : ErrorDataBuilder(io.crnk.core.engine.document.ErrorDataBuilder) CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) Before(org.junit.Before)

Aggregations

CrnkBoot (io.crnk.core.boot.CrnkBoot)54 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)34 Before (org.junit.Before)34 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)28 Test (org.junit.Test)11 TestModule (io.crnk.test.mock.TestModule)9 SimpleModule (io.crnk.core.module.SimpleModule)7 JsonApiUrlBuilder (io.crnk.core.engine.internal.utils.JsonApiUrlBuilder)6 ResourceMetaProvider (io.crnk.meta.provider.resource.ResourceMetaProvider)6 MetaModule (io.crnk.meta.MetaModule)5 NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)4 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)4 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)4 Task (io.crnk.core.mock.models.Task)4 TaskRepository (io.crnk.core.mock.repository.TaskRepository)4 QuerySpec (io.crnk.core.queryspec.QuerySpec)4 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)4 JaxrsModule (io.crnk.rs.internal.JaxrsModule)4 JsonApiExceptionMapper (io.crnk.core.engine.error.JsonApiExceptionMapper)3 HttpRequestContextProvider (io.crnk.core.engine.http.HttpRequestContextProvider)3