use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.
the class ResourceRepositoryBaseTest method setup.
@Before
public void setup() {
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.setPropertiesProvider(new PropertiesProvider() {
@Override
public String getProperty(String key) {
if (key.equals(CrnkProperties.RETURN_404_ON_NULL)) {
return "true";
}
return null;
}
});
boot.boot();
repository = new TestRepository();
repository.setResourceRegistry(boot.getResourceRegistry());
}
use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.
the class CustomResourceRegistryTest method test.
@Test
public void test() {
CrnkBoot boot = new CrnkBoot();
boot.addModule(new CustomRegistryPartModule());
boot.setServiceDiscovery(new TestServiceDiscovery());
boot.boot();
ResourceRegistry resourceRegistry = boot.getResourceRegistry();
RegistryEntry entry = resourceRegistry.getEntry("somePrefix/custom");
Assert.assertNotNull(entry);
ResourceRepositoryAdapter adapter = entry.getResourceRepository();
QueryAdapter queryAdapter = new QuerySpecAdapter(new QuerySpec("somePrefix/custom"), resourceRegistry);
JsonApiResponse response = adapter.findAll(queryAdapter);
Assert.assertNotNull(response.getEntity());
List<Resource> resources = (List<Resource>) response.getEntity();
Assert.assertEquals(1, resources.size());
}
use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.
the class JsonApiFormatTest method setup.
@Before
public void setup() {
MetaModuleConfig config = new MetaModuleConfig();
config.addMetaProvider(new ResourceMetaProvider());
MetaModule metaModule = MetaModule.createServerModule(config);
this.module = Mockito.spy(HomeModule.create(HomeFormat.JSON_API));
boot = new CrnkBoot();
boot.addModule(module);
boot.addModule(metaModule);
boot.addModule(new TestModule());
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.boot();
}
use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.
the class GuiceServiceDiscoveryTest method exceptionMapperDiscovery.
@Test
public void exceptionMapperDiscovery() {
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscovery(discovery);
boot.boot();
Optional<JsonApiExceptionMapper> mapper = boot.getExceptionMapperRegistry().findMapperFor(TestException.class);
Assert.assertTrue(mapper.isPresent());
Assert.assertTrue(mapper.get() instanceof TestExceptionMapper);
}
use of io.crnk.core.boot.CrnkBoot in project crnk-framework by crnk-project.
the class JsonHomeFormatTest method setup.
@Before
public void setup() {
MetaModuleConfig config = new MetaModuleConfig();
config.addMetaProvider(new ResourceMetaProvider());
MetaModule metaModule = MetaModule.createServerModule(config);
this.module = Mockito.spy(HomeModule.create(HomeFormat.JSON_HOME));
boot = new CrnkBoot();
boot.addModule(module);
boot.addModule(metaModule);
boot.addModule(new TestModule());
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.boot();
}
Aggregations