Search in sources :

Example 6 with RepositoryInstanceBuilder

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");
}
Also used : AnnotatedRelationshipEntryBuilder(io.crnk.legacy.registry.AnnotatedRelationshipEntryBuilder) JsonServiceLocator(io.crnk.legacy.locator.JsonServiceLocator) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) RepositoryInstanceBuilder(io.crnk.legacy.registry.RepositoryInstanceBuilder) Test(org.junit.Test)

Example 7 with RepositoryInstanceBuilder

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);
}
Also used : TaskRepository(io.crnk.core.mock.repository.TaskRepository) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) RepositoryInstanceBuilder(io.crnk.legacy.registry.RepositoryInstanceBuilder) Test(org.junit.Test)

Example 8 with RepositoryInstanceBuilder

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();
}
Also used : TaskRepository(io.crnk.core.mock.repository.TaskRepository) JsonServiceLocator(io.crnk.legacy.locator.JsonServiceLocator) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) RepositoryInstanceBuilder(io.crnk.legacy.registry.RepositoryInstanceBuilder) Test(org.junit.Test)

Aggregations

RepositoryInstanceBuilder (io.crnk.legacy.registry.RepositoryInstanceBuilder)8 SampleJsonServiceLocator (io.crnk.legacy.locator.SampleJsonServiceLocator)5 Test (org.junit.Test)5 ResourceRepositoryInformation (io.crnk.core.engine.information.repository.ResourceRepositoryInformation)3 DirectResponseRelationshipEntry (io.crnk.legacy.internal.DirectResponseRelationshipEntry)3 DirectResponseResourceEntry (io.crnk.legacy.internal.DirectResponseResourceEntry)3 ResourceField (io.crnk.core.engine.information.resource.ResourceField)2 TaskRepository (io.crnk.core.mock.repository.TaskRepository)2 JsonServiceLocator (io.crnk.legacy.locator.JsonServiceLocator)2 AnnotatedRelationshipEntryBuilder (io.crnk.legacy.registry.AnnotatedRelationshipEntryBuilder)2 RelationshipRepositoryStubImpl (io.crnk.client.internal.RelationshipRepositoryStubImpl)1 ResourceRepositoryStubImpl (io.crnk.client.internal.ResourceRepositoryStubImpl)1 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)1 ResourceRepositoryInformationImpl (io.crnk.core.engine.internal.information.repository.ResourceRepositoryInformationImpl)1 RelationshipRepositoryAdapter (io.crnk.core.engine.internal.repository.RelationshipRepositoryAdapter)1 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)1 AnnotatedResourceEntry (io.crnk.legacy.registry.AnnotatedResourceEntry)1 RelationshipRepository (io.crnk.legacy.repository.RelationshipRepository)1 JsonApiResourceRepository (io.crnk.legacy.repository.annotations.JsonApiResourceRepository)1