use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class DefaultQueryParamsSerializerTest method check.
private void check(String expectedUrl, Object id, QueryParams queryParams) {
RegistryEntry entry = resourceRegistry.getEntryForClass(Task.class);
String actualUrl = urlBuilder.buildUrl(entry.getResourceInformation(), id, queryParams);
assertEquals(expectedUrl, actualUrl);
}
use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class RegistryEntryTest method onValidParentShouldReturnTrue.
@Test
public void onValidParentShouldReturnTrue() throws Exception {
// GIVEN
RegistryEntry thing = new RegistryEntry(newResourceEntry(Thing.class, "things"));
RegistryEntry document = new RegistryEntry(newResourceEntry(Document.class, "documents"));
document.setParentRegistryEntry(thing);
RegistryEntry memorandum = new RegistryEntry(newResourceEntry(Memorandum.class, "memorandum"));
memorandum.setParentRegistryEntry(document);
// WHEN
boolean result = memorandum.isParent(thing);
// THEN
assertThat(result).isTrue();
}
use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class RegistryEntryTest method onInvalidParentShouldReturnFalse.
@Test
public void onInvalidParentShouldReturnFalse() throws Exception {
// GIVEN
RegistryEntry document = new RegistryEntry(newResourceEntry(Document.class, "documents"));
RegistryEntry task = new RegistryEntry(newResourceEntry(Task.class, "tasks"));
// WHEN
boolean result = document.isParent(task);
// THEN
assertThat(result).isFalse();
}
use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class RegistryEntryTest method onInvalidRelationshipClassShouldThrowException.
@Test
public void onInvalidRelationshipClassShouldThrowException() throws Exception {
// GIVEN
ResourceRepositoryInformation repositoryInformation = newRepositoryInformation(Task.class, "tasks");
ResourceField relationshipField = repositoryInformation.getResourceInformation().get().findFieldByUnderlyingName("tasks");
Map relRepos = new HashMap<>();
relRepos.put(relationshipField, new DirectResponseRelationshipEntry(new RepositoryInstanceBuilder(new SampleJsonServiceLocator(), TaskToProjectRepository.class)));
RegistryEntry sut = new RegistryEntry(new DirectResponseResourceEntry(null, repositoryInformation), relRepos);
// THEN
expectedException.expect(ResourceFieldNotFoundException.class);
// WHEN
sut.getRelationshipRepository("users", null);
}
use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class HasNextBasedPagedLinksInformationTest method setup.
@Before
public void setup() {
HasNextPageTestRepository.clear();
super.setup();
RegistryEntry registryEntry = resourceRegistry.getEntry(Task.class);
HasNextPageTestRepository repo = (HasNextPageTestRepository) registryEntry.getResourceRepository(null).getResourceRepository();
repo = Mockito.spy(repo);
adapter = registryEntry.getResourceRepository(null);
QueryAdapter queryAdapter = new QuerySpecAdapter(querySpec(), resourceRegistry);
for (long i = 0; i < 5; i++) {
Task task = new Task();
task.setId(i);
task.setName("myTask");
adapter.create(task, queryAdapter);
}
}
Aggregations