use of io.crnk.legacy.registry.RepositoryInstanceBuilder in project crnk-framework by crnk-project.
the class AnnotatedRelationshipEntryBuilderTest method onInstanceOfAnonymousDescendantOfAnnotatedRelationshipRepositoryShouldReturnTargetClass.
@Test
public void onInstanceOfAnonymousDescendantOfAnnotatedRelationshipRepositoryShouldReturnTargetClass() {
// GIVEN
final AnnotatedRelationshipEntryBuilder builder = new AnnotatedRelationshipEntryBuilder(moduleRegistry, new RepositoryInstanceBuilder(new JsonServiceLocator() {
@Override
public <T> T getInstance(Class<T> clazz) {
return (T) new SimpleRelationshipRepository() {
};
}
}, SimpleRelationshipRepository.class));
// WHEN
final String targetResourceType = builder.getTargetResourceType();
// THEN
assertThat(targetResourceType).isEqualTo("projects");
}
use of io.crnk.legacy.registry.RepositoryInstanceBuilder in project crnk-framework by crnk-project.
the class RepositoryInstanceBuilderTest method onExistingInstanceShouldReturnValue.
@Test
public void onExistingInstanceShouldReturnValue() throws Exception {
// GIVEN
RepositoryInstanceBuilder<TaskRepository> sut = new RepositoryInstanceBuilder<>(new SampleJsonServiceLocator(), TaskRepository.class);
// WHEN
TaskRepository result = sut.buildRepository();
// THEN
assertThat(sut.getRepositoryClass()).isEqualTo(TaskRepository.class);
assertThat(result).isInstanceOf(TaskRepository.class);
}
use of io.crnk.legacy.registry.RepositoryInstanceBuilder in project crnk-framework by crnk-project.
the class RepositoryInstanceBuilderTest method onNullInstanceShouldThrowException.
@Test(expected = RepositoryInstanceNotFoundException.class)
public void onNullInstanceShouldThrowException() throws Exception {
// GIVEN
RepositoryInstanceBuilder<TaskRepository> sut = new RepositoryInstanceBuilder<>(new JsonServiceLocator() {
@Override
public <T> T getInstance(Class<T> clazz) {
return null;
}
}, TaskRepository.class);
// WHEN
sut.buildRepository();
}
Aggregations