Search in sources :

Example 1 with TestServiceDiscovery

use of io.crnk.core.module.discovery.TestServiceDiscovery 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 2 with TestServiceDiscovery

use of io.crnk.core.module.discovery.TestServiceDiscovery in project crnk-framework by crnk-project.

the class CustomResourceRegistryTest method test.

@Test
public void test() {
    CrnkBoot boot = new CrnkBoot();
    boot.addModule(new CustomRegistryPartModule());
    boot.setServiceDiscovery(new TestServiceDiscovery());
    boot.boot();
    ResourceRegistry resourceRegistry = boot.getResourceRegistry();
    RegistryEntry entry = resourceRegistry.getEntry("somePrefix/custom");
    Assert.assertNotNull(entry);
    ResourceRepositoryAdapter adapter = entry.getResourceRepository();
    QueryAdapter queryAdapter = new QuerySpecAdapter(new QuerySpec("somePrefix/custom"), resourceRegistry);
    JsonApiResponse response = adapter.findAll(queryAdapter);
    Assert.assertNotNull(response.getEntity());
    List<Resource> resources = (List<Resource>) response.getEntity();
    Assert.assertEquals(1, resources.size());
}
Also used : QueryAdapter(io.crnk.core.engine.query.QueryAdapter) Resource(io.crnk.core.engine.document.Resource) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) CrnkBoot(io.crnk.core.boot.CrnkBoot) TestServiceDiscovery(io.crnk.core.module.discovery.TestServiceDiscovery) ResourceRepositoryAdapter(io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter) JsonApiResponse(io.crnk.core.repository.response.JsonApiResponse) List(java.util.List) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Aggregations

CrnkBoot (io.crnk.core.boot.CrnkBoot)2 TestServiceDiscovery (io.crnk.core.module.discovery.TestServiceDiscovery)2 Resource (io.crnk.core.engine.document.Resource)1 ResourceRepositoryAdapter (io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter)1 QueryAdapter (io.crnk.core.engine.query.QueryAdapter)1 ProjectRepository (io.crnk.core.mock.repository.ProjectRepository)1 ProjectToTaskRepository (io.crnk.core.mock.repository.ProjectToTaskRepository)1 TaskRepository (io.crnk.core.mock.repository.TaskRepository)1 SimpleModule (io.crnk.core.module.SimpleModule)1 QuerySpec (io.crnk.core.queryspec.QuerySpec)1 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)1 JsonApiResponse (io.crnk.core.repository.response.JsonApiResponse)1 List (java.util.List)1 Before (org.junit.Before)1 Test (org.junit.Test)1