use of io.crnk.legacy.locator.SampleJsonServiceLocator in project crnk-framework by crnk-project.
the class FallbackServiceDiscoveryFactoryTest method fallbackToReflectionsIfNoDefaultAvailable.
@Test
public void fallbackToReflectionsIfNoDefaultAvailable() {
PropertiesProvider propertiesProvider = Mockito.mock(PropertiesProvider.class);
Mockito.when(propertiesProvider.getProperty(Mockito.eq(CrnkProperties.RESOURCE_SEARCH_PACKAGE))).thenReturn("a.b.c");
ServiceDiscoveryFactory defaultFactory = new ServiceDiscoveryFactory() {
@Override
public ServiceDiscovery getInstance() {
return null;
}
};
FallbackServiceDiscoveryFactory fallbackFactory = new FallbackServiceDiscoveryFactory(defaultFactory, new SampleJsonServiceLocator(), propertiesProvider);
Assert.assertTrue(fallbackFactory.getInstance() instanceof ReflectionsServiceDiscovery);
}
use of io.crnk.legacy.locator.SampleJsonServiceLocator 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.SampleJsonServiceLocator 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.legacy.locator.SampleJsonServiceLocator in project crnk-framework by crnk-project.
the class ValidationMetaProviderTest method setup.
private void setup(boolean addValidationProvider) {
CrnkBoot boot = new CrnkBoot();
boot.addModule(new JaxrsModule(null));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.validation.mock", new SampleJsonServiceLocator()));
boot.boot();
resourceMetaProvider = new ResourceMetaProvider();
lookup = new MetaLookup();
lookup.setModuleContext(boot.getModuleRegistry().getContext());
lookup.addProvider(resourceMetaProvider);
if (addValidationProvider) {
lookup.addProvider(new ValidationMetaProvider());
}
lookup.initialize();
}
use of io.crnk.legacy.locator.SampleJsonServiceLocator 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);
}
Aggregations