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();
}
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());
}
Aggregations