use of io.crnk.legacy.locator.JsonServiceLocator in project crnk-framework by crnk-project.
the class CrnkBootTest method setServiceLocator.
@Test
public void setServiceLocator() {
JsonServiceLocator locator = mock(JsonServiceLocator.class);
PropertiesProvider propertiesProvider = mock(PropertiesProvider.class);
Mockito.when(propertiesProvider.getProperty(eq(CrnkProperties.RESOURCE_SEARCH_PACKAGE))).thenReturn("a.b.c");
CrnkBoot boot = new CrnkBoot();
boot.setPropertiesProvider(propertiesProvider);
boot.setServiceLocator(locator);
boot.setServiceDiscoveryFactory(mock(ServiceDiscoveryFactory.class));
boot.boot();
ReflectionsServiceDiscovery serviceDiscovery = (ReflectionsServiceDiscovery) boot.getServiceDiscovery();
Assert.assertSame(locator, serviceDiscovery.getLocator());
}
use of io.crnk.legacy.locator.JsonServiceLocator in project crnk-framework by crnk-project.
the class AbstractQueryParamsTest method setup.
@Before
public void setup() {
JsonServiceLocator jsonServiceLocator = new SampleJsonServiceLocator();
ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(new NullPropertiesProvider(), (PagingBehavior) null, new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
SimpleModule testModule = new SimpleModule("test");
CrnkBoot boot = new CrnkBoot();
boot.addModule(testModule);
boot.boot();
moduleRegistry = boot.getModuleRegistry();
resourceRegistry = boot.getResourceRegistry();
converter = new DefaultQueryParamsConverter(resourceRegistry);
paramsToSpecConverter = new DefaultQuerySpecConverter(moduleRegistry);
}
use of io.crnk.legacy.locator.JsonServiceLocator 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.locator.JsonServiceLocator 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