use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class CrnkConfigV3 method crnkBoot.
@Bean
@ConditionalOnMissingBean(CrnkBoot.class)
public CrnkBoot crnkBoot(ServiceDiscovery serviceDiscovery) {
CrnkBoot boot = new CrnkBoot();
boot.setObjectMapper(objectMapper);
if (properties.getDomainName() != null && properties.getPathPrefix() != null) {
String baseUrl = properties.getDomainName() + properties.getPathPrefix();
boot.setServiceUrlProvider(new ConstantServiceUrlProvider(baseUrl));
}
boot.setServiceDiscovery(serviceDiscovery);
boot.setDefaultPageLimit(properties.getDefaultPageLimit());
boot.setMaxPageLimit(properties.getMaxPageLimit());
boot.setPropertiesProvider(new PropertiesProvider() {
@Override
public String getProperty(String key) {
if (CrnkProperties.RESOURCE_SEARCH_PACKAGE.equals(key)) {
return properties.getResourcePackage();
}
if (CrnkProperties.RESOURCE_DEFAULT_DOMAIN.equals(key)) {
return properties.getDomainName();
}
if (CrnkProperties.WEB_PATH_PREFIX.equals(key)) {
return properties.getPathPrefix();
}
if (CrnkProperties.ALLOW_UNKNOWN_ATTRIBUTES.equals(key)) {
return String.valueOf(properties.getAllowUnknownAttributes());
}
if (CrnkProperties.ALLOW_UNKNOWN_PARAMETERS.equals(key)) {
return String.valueOf(properties.getAllowUnknownParameters());
}
if (CrnkProperties.RETURN_404_ON_NULL.equals(key)) {
return String.valueOf(properties.getReturn404OnNull());
}
return applicationContext.getEnvironment().getProperty(key);
}
});
boot.setAllowUnknownAttributes();
boot.addModule(new ServletModule(boot.getModuleRegistry().getHttpRequestContextProvider()));
boot.boot();
return boot;
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class HomeResourceFilteringTest method setup.
@Before
public void setup() {
filter = Mockito.mock(ResourceFilter.class);
SimpleModule filterModule = new SimpleModule("filter");
filterModule.addResourceFilter(filter);
this.module = Mockito.spy(HomeModule.create());
boot = new CrnkBoot();
boot.addModule(module);
boot.addModule(new TestModule());
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.addModule(filterModule);
boot.boot();
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class JsonApiRequestProcessorTest method setup.
@Before
public void setup() {
TaskRepository.clear();
boot = new CrnkBoot();
boot.addModule(new Module() {
@Override
public String getModuleName() {
return "test";
}
@Override
public void setupModule(ModuleContext context) {
moduleContext = context;
}
});
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost:8080"));
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.boot();
Task task = new Task();
task.setId(1L);
task.setName("SomeTask");
task.setLinksInformation(new TaskLinks());
TaskRepository tasks = new TaskRepository();
tasks.save(task);
processor = new JsonApiRequestProcessor(moduleContext);
requestContextBase = Mockito.mock(HttpRequestContextBase.class);
requestContext = new HttpRequestContextBaseAdapter(requestContextBase);
HttpRequestContextProvider requestContextProvider = boot.getModuleRegistry().getHttpRequestContextProvider();
requestContextProvider.onRequestStarted(requestContext);
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class ResourceFilterTest 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.addResourceFilter(filter);
boot.addModule(filterModule);
boot.boot();
resourceRegistry = boot.getResourceRegistry();
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class BaseControllerTest method prepare.
@Before
public void prepare() {
modificationFilter = Mockito.spy(new ResourceModificationFilterBase());
modificationFilters = Arrays.asList(modificationFilter);
CrnkBoot boot = new CrnkBoot();
boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.boot();
objectMapper = boot.getObjectMapper();
resourceRegistry = boot.getResourceRegistry();
moduleRegistry = boot.getModuleRegistry();
pathBuilder = new PathBuilder(resourceRegistry);
typeParser = moduleRegistry.getTypeParser();
documentMapper = boot.getDocumentMapper();
MockRepositoryUtil.clear();
emptyTaskQuery = new QuerySpecAdapter(new QuerySpec(Task.class), resourceRegistry);
emptyProjectQuery = new QuerySpecAdapter(new QuerySpec(Project.class), resourceRegistry);
emptyUserQuery = new QuerySpecAdapter(new QuerySpec(User.class), resourceRegistry);
emptyComplexPojoQuery = new QuerySpecAdapter(new QuerySpec(ComplexPojo.class), resourceRegistry);
emptyMemorandumQuery = new QuerySpecAdapter(new QuerySpec(Memorandum.class), resourceRegistry);
}
Aggregations