use of io.crnk.core.engine.url.ConstantServiceUrlProvider 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.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class FilterTest method prepare.
@Before
public void prepare() {
boot = new CrnkBoot();
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
// GIVEN
filter = mock(TestFilter.class);
SimpleModule filterModule = new SimpleModule("filter");
filterModule.addFilter(filter);
boot.addModule(filterModule);
boot.boot();
resourceRegistry = boot.getResourceRegistry();
moduleRegistry = boot.getModuleRegistry();
pathBuilder = new PathBuilder(resourceRegistry);
ControllerRegistry controllerRegistry = new ControllerRegistry(null);
collectionGet = mock(CollectionGet.class);
controllerRegistry.addController(collectionGet);
QuerySpecAdapterBuilder queryAdapterBuilder = new QuerySpecAdapterBuilder(new DefaultQuerySpecDeserializer(), moduleRegistry);
dispatcher = new HttpRequestProcessorImpl(moduleRegistry, controllerRegistry, null, queryAdapterBuilder);
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class RepositoryFilterTest method prepare.
@Before
public void prepare() {
boot = new CrnkBoot();
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
SimpleModule filterModule = new SimpleModule("filter");
filterModule.addRepositoryFilter(filter);
boot.addModule(filterModule);
boot.boot();
resourceRegistry = boot.getResourceRegistry();
querySpec = new QuerySpec(User.class);
querySpec.setPagingSpec(new OffsetLimitPagingSpec());
queryAdapter = new QuerySpecAdapter(querySpec, resourceRegistry);
scheduleInfo = resourceRegistry.getEntry(Schedule.class).getResourceInformation();
RegistryEntry userEntry = resourceRegistry.getEntry(User.class);
resourceAdapter = userEntry.getResourceRepository(null);
projectRelationAdapter = userEntry.getRelationshipRepository("assignedProjects", null);
taskRelationAdapter = userEntry.getRelationshipRepository("assignedTasks", null);
userInfo = userEntry.getResourceInformation();
UserRepository resourceRepository = (UserRepository) resourceAdapter.getResourceRepository();
user1 = new User();
user1.setId(1L);
resourceRepository.save(user1);
user2 = new User();
user2.setId(2L);
resourceRepository.save(user2);
UserToProjectRepository userProjectRepository = (UserToProjectRepository) ((AnnotatedRelationshipRepositoryAdapter<?, ?, ?, ?>) projectRelationAdapter.getRelationshipRepository()).getImplementationObject();
userProjectRepository.setRelation(user1, 11L, "assignedProjects");
UserToTaskRepository userTaskRepository = new UserToTaskRepository();
userTaskRepository.addRelations(user1, Arrays.asList(21L), "assignedTasks");
userTaskRepository.addRelations(user2, Arrays.asList(22L), "assignedTasks");
assignedTasksField = resourceRegistry.getEntry(User.class).getResourceInformation().findRelationshipFieldByName("assignedTasks");
assignedProjectsField = resourceRegistry.getEntry(User.class).getResourceInformation().findRelationshipFieldByName("assignedProjects");
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class MetaModuleTest method setupBoot.
private void setupBoot() {
boot = new CrnkBoot();
boot.addModule(new JaxrsModule(null));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.addModule(metaModule);
boot.boot();
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class JpaExceptionMapperTests method setup.
@Before
public void setup() {
boot = new CrnkBoot();
boot.addModule(JpaModule.newClientModule());
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.jpa.mock.model", new SampleJsonServiceLocator()));
boot.boot();
}
Aggregations