use of io.crnk.core.engine.url.ServiceUrlProvider in project crnk-framework by crnk-project.
the class CrnkFeatureTest method testServiceServiceUrlProvider.
@Test
public void testServiceServiceUrlProvider() {
CrnkFeature feature = new CrnkFeature();
ServiceUrlProvider serviceUrlProvider = Mockito.mock(ServiceUrlProvider.class);
feature.setServiceUrlProvider(serviceUrlProvider);
Assert.assertSame(serviceUrlProvider, feature.getBoot().getServiceUrlProvider());
}
use of io.crnk.core.engine.url.ServiceUrlProvider in project crnk-framework by crnk-project.
the class CrnkBootTest method setConstantServiceUrlProvider.
@Test
public void setConstantServiceUrlProvider() {
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscoveryFactory(serviceDiscoveryFactory);
final Properties properties = new Properties();
properties.put(CrnkProperties.RESOURCE_DEFAULT_DOMAIN, "http://something");
PropertiesProvider propertiesProvider = new PropertiesProvider() {
@Override
public String getProperty(String key) {
return (String) properties.get(key);
}
};
boot.setPropertiesProvider(propertiesProvider);
boot.boot();
ServiceUrlProvider serviceUrlProvider = boot.getServiceUrlProvider();
Assert.assertTrue(serviceUrlProvider instanceof ConstantServiceUrlProvider);
Assert.assertEquals("http://something", serviceUrlProvider.getUrl());
}
use of io.crnk.core.engine.url.ServiceUrlProvider in project crnk-framework by crnk-project.
the class CrnkBootTest method boot.
@Test
public void boot() {
CrnkBoot boot = new CrnkBoot();
boot.setDefaultServiceUrlProvider(new ServiceUrlProvider() {
@Override
public String getUrl() {
return "http://127.0.0.1";
}
});
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.addModule(new SimpleModule("test"));
boot.boot();
RequestDispatcher requestDispatcher = boot.getRequestDispatcher();
ResourceRegistry resourceRegistry = boot.getResourceRegistry();
RegistryEntry taskEntry = resourceRegistry.getEntry(Task.class);
Assert.assertNotEquals(0, taskEntry.getRelationshipEntries().size());
ResourceRepositoryAdapter<?, ?> repositoryAdapter = taskEntry.getResourceRepository(null);
Assert.assertNotNull(repositoryAdapter.getResourceRepository());
JsonApiResponse response = repositoryAdapter.findAll(new QueryParamsAdapter(taskEntry.getResourceInformation(), new QueryParams(), boot.getModuleRegistry()));
Assert.assertNotNull(response);
Assert.assertNotNull(requestDispatcher);
ServiceDiscovery serviceDiscovery = boot.getServiceDiscovery();
Assert.assertNotNull(serviceDiscovery);
Assert.assertNotNull(boot.getModuleRegistry());
Assert.assertNotNull(boot.getExceptionMapperRegistry());
List<Module> modules = boot.getModuleRegistry().getModules();
Assert.assertEquals(4, modules.size());
boot.setDefaultPageLimit(20L);
boot.setMaxPageLimit(100L);
Assert.assertEquals(1, boot.getPagingBehaviors().size());
Assert.assertTrue(boot.getPagingBehaviors().get(0) instanceof OffsetLimitPagingBehavior);
}
use of io.crnk.core.engine.url.ServiceUrlProvider in project crnk-framework by crnk-project.
the class CrnkBootTest method setDefaultServiceUrlProvider.
@Test
public void setDefaultServiceUrlProvider() {
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscoveryFactory(serviceDiscoveryFactory);
ServiceUrlProvider serviceUrlProvider = mock(ServiceUrlProvider.class);
boot.setDefaultServiceUrlProvider(serviceUrlProvider);
boot.boot();
Assert.assertEquals(serviceUrlProvider, boot.getDefaultServiceUrlProvider());
Assert.assertEquals(serviceUrlProvider, boot.getServiceUrlProvider());
Assert.assertEquals(serviceUrlProvider, boot.getServiceUrlProvider());
}
use of io.crnk.core.engine.url.ServiceUrlProvider in project crnk-framework by crnk-project.
the class JerseyActionStubFactory method createStub.
@Override
public <T> T createStub(Class<T> interfaceClass) {
ServiceUrlProvider serviceUrlProvider = context.getServiceUrlProvider();
String serviceUrl = serviceUrlProvider.getUrl();
WebTarget target = client.target(serviceUrl);
return WebResourceFactory.newResource(interfaceClass, target);
}
Aggregations