use of io.crnk.core.engine.internal.dispatcher.path.PathBuilder 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);
}
use of io.crnk.core.engine.internal.dispatcher.path.PathBuilder 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.internal.dispatcher.path.PathBuilder in project crnk-framework by crnk-project.
the class ControllerRegistryTest method onUnsupportedRequestRegisterShouldThrowError.
@Test
public void onUnsupportedRequestRegisterShouldThrowError() {
// GIVEN
PathBuilder pathBuilder = new PathBuilder(resourceRegistry);
JsonPath jsonPath = pathBuilder.build("/tasks/");
String requestType = "PATCH";
ControllerRegistry sut = new ControllerRegistry(null);
// THEN
expectedException.expect(MethodNotFoundException.class);
// WHEN
sut.getController(jsonPath, requestType);
}
use of io.crnk.core.engine.internal.dispatcher.path.PathBuilder in project crnk-framework by crnk-project.
the class OperationsModule method enrichTypeIdInformation.
private void enrichTypeIdInformation(List<Operation> operations) {
ResourceRegistry resourceRegistry = moduleContext.getResourceRegistry();
for (Operation operation : operations) {
if (operation.getOp().equalsIgnoreCase(HttpMethod.DELETE.toString())) {
String path = OperationParameterUtils.parsePath(operation.getPath());
JsonPath jsonPath = (new PathBuilder(resourceRegistry)).build(path);
Resource resource = new Resource();
resource.setType(jsonPath.getResourceType());
resource.setId(jsonPath.getIds().getIds().get(0));
operation.setValue(resource);
}
}
}
use of io.crnk.core.engine.internal.dispatcher.path.PathBuilder in project crnk-framework by crnk-project.
the class HttpRequestProcessorImpl method dispatchAction.
@Override
public void dispatchAction(String path, String method, Map<String, Set<String>> parameters) {
JsonPath jsonPath = new PathBuilder(moduleRegistry.getResourceRegistry()).build(path);
// preliminary implementation, more to come in the future
ActionFilterChain chain = new ActionFilterChain();
DefaultFilterRequestContext context = new DefaultFilterRequestContext(jsonPath, null, null, null, method);
chain.doFilter(context);
}
Aggregations