Codota Logo
JRestlessHandlerContainer.handleRequest
Code IndexAdd Codota to your IDE (free)

How to use
handleRequest
method
in
com.jrestless.core.container.JRestlessHandlerContainer

Best Java code snippets using com.jrestless.core.container.JRestlessHandlerContainer.handleRequest (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: bbilger/jrestless

/**
 * Shortcut for
 * {@link #handleRequest(JRestlessContainerRequest, JRestlessResponseWriter, SecurityContext, Consumer)}
 * with noop containerRequestEnhancer.
 *
 * @param request
 * @param responseWriter
 * @param securityContext
 */
public void handleRequest(@Nonnull RequestT request, @Nonnull JRestlessResponseWriter responseWriter,
    @Nonnull SecurityContext securityContext) {
  handleRequest(request, responseWriter, securityContext, req -> { });
}
origin: bbilger/jrestless

@Test
public void handleRequest_ContainerRequestGiven_ShouldInvokeAppHandler() {
  ContainerRequest request = mock(ContainerRequest.class);
  container.handleRequest(request);
  verify(container, times(1)).handleRequest(eq(request));
}
origin: bbilger/jrestless

@SuppressWarnings("unchecked")
private RequestScopedInitializer getSetRequestScopedInitializer(JsonObject request) {
  ArgumentCaptor<Consumer<ContainerRequest>> containerEnhancerCaptor = ArgumentCaptor.forClass(Consumer.class);
  handler.delegateJsonRequest(request);
  verify(container).handleRequest(any(), any(), any(), containerEnhancerCaptor.capture());
  ContainerRequest containerRequest = mock(ContainerRequest.class);
  containerEnhancerCaptor.getValue().accept(containerRequest);
  ArgumentCaptor<RequestScopedInitializer> requestScopedInitializerCaptor = ArgumentCaptor.forClass(RequestScopedInitializer.class);
  verify(containerRequest).setRequestScopedInitializer(requestScopedInitializerCaptor.capture());
  return requestScopedInitializerCaptor.getValue();
}
origin: bbilger/jrestless

@SuppressWarnings({ "unchecked", "rawtypes" })
private RequestScopedInitializer getSetRequestScopedInitializer(Context context, ServiceRequest request) {
  ServiceRequestAndLambdaContext reqAndContext = new ServiceRequestAndLambdaContext(request, context);
  ArgumentCaptor<Consumer> containerEnhancerCaptor = ArgumentCaptor.forClass(Consumer.class);
  serviceHandler.delegateRequest(reqAndContext);
  verify(container).handleRequest(any(), any(), any(), containerEnhancerCaptor.capture());
  ContainerRequest containerRequest = mock(ContainerRequest.class);
  containerEnhancerCaptor.getValue().accept(containerRequest);
  ArgumentCaptor<RequestScopedInitializer> requestScopedInitializerCaptor = ArgumentCaptor.forClass(RequestScopedInitializer.class);
  verify(containerRequest).setRequestScopedInitializer(requestScopedInitializerCaptor.capture());
  return requestScopedInitializerCaptor.getValue();
}
origin: bbilger/jrestless

@SuppressWarnings("unchecked")
private RequestScopedInitializer getSetRequestScopedInitializer(Context context, GatewayRequest request) {
  GatewayRequestAndLambdaContext reqAndContext = new GatewayRequestAndLambdaContext(request, context);
  ArgumentCaptor<Consumer<ContainerRequest>> containerEnhancerCaptor = ArgumentCaptor.forClass(Consumer.class);
  gatewayHandler.delegateRequest(reqAndContext);
  verify(container).handleRequest(any(), any(), any(), containerEnhancerCaptor.capture());
  ContainerRequest containerRequest = mock(ContainerRequest.class);
  containerEnhancerCaptor.getValue().accept(containerRequest);
  ArgumentCaptor<RequestScopedInitializer> requestScopedInitializerCaptor = ArgumentCaptor.forClass(RequestScopedInitializer.class);
  verify(containerRequest).setRequestScopedInitializer(requestScopedInitializerCaptor.capture());
  return requestScopedInitializerCaptor.getValue();
}
origin: bbilger/jrestless

@SuppressWarnings({ "unchecked", "rawtypes" })
private RequestScopedInitializer getSetRequestScopedInitializer(Context context, SNSRecord snsRecord) {
  SnsRecordAndLambdaContext reqAndContext = new SnsRecordAndLambdaContext(snsRecord, context);
  ArgumentCaptor<Consumer> containerEnhancerCaptor = ArgumentCaptor.forClass(Consumer.class);
  snsHandler.delegateRequest(reqAndContext);
  verify(container).handleRequest(any(), any(), any(), containerEnhancerCaptor.capture());
  ContainerRequest containerRequest = mock(ContainerRequest.class);
  containerEnhancerCaptor.getValue().accept(containerRequest);
  ArgumentCaptor<RequestScopedInitializer> requestScopedInitializerCaptor = ArgumentCaptor.forClass(RequestScopedInitializer.class);
  verify(containerRequest).setRequestScopedInitializer(requestScopedInitializerCaptor.capture());
  return requestScopedInitializerCaptor.getValue();
}
origin: bbilger/jrestless

@Test
public void updateArticle_ArticleBodyGiven_ShouldReturnUpdatedArticle() throws IOException {
  when(testService.updateArticle(1, "some updated article text")).thenReturn("some updated persisted article text");
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  container.handleRequest(new TestRequest("/articles/1", "PUT", new ByteArrayInputStream("some updated article text".getBytes())), responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.OK), any(), eqBaos("some updated persisted article text"));
}
origin: bbilger/jrestless

@Test
public void getPrincipalName_PrincipalNameGiven_ShouldReturnPrincipalName() throws IOException {
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  TestRequest req = new TestRequest("/info", "GET");
  SecurityContext sc = mock(SecurityContext.class);
  Principal p = mock(Principal.class);
  when(p.getName()).thenReturn("someName");
  when(sc.getUserPrincipal()).thenReturn(p);
  container.handleRequest(req, responseWriter, sc);
  verify(responseWriter, times(1)).writeResponse(eq(Status.OK), any(), eqBaos("someName"));
}
origin: bbilger/jrestless

@Test
public void updateArticle_ArticleBodyWithNonSupportedContentTypeGiven_ShouldReturnUpdatedArticle() throws IOException {
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  TestRequest req = new TestRequest("/articles/1", "PUT", new ByteArrayInputStream("{\"text\": \"some updated article text\"}".getBytes()));
  req.getHeadersAsMultimap().add("Content-Type",  MediaType.APPLICATION_JSON);
  container.handleRequest(req, responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.UNSUPPORTED_MEDIA_TYPE), any(), emptyBaos());
}
origin: bbilger/jrestless

@Test
public void getArticles_ContainsGiven_ShouldReturnArticles() throws IOException {
  when(testService.getArticles("test")).thenReturn(Arrays.asList("test article 1", "test article 2"));
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  TestRequest req = new TestRequest("/articles?contains=test", "GET");
  container.handleRequest(req, responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.OK), any(), eqBaos("test article 1, test article 2"));
}
origin: bbilger/jrestless

@Test
public void deleteApp_AdminUserGiven_ShouldAllowAccess() throws IOException {
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  SecurityContext sc = mock(SecurityContext.class);
  Principal p = mock(Principal.class);
  when(sc.getUserPrincipal()).thenReturn(p);
  when(sc.isUserInRole("admin")).thenReturn(true);
  container.handleRequest(new TestRequest("/app", "DELETE"), responseWriter, sc);
  verify(responseWriter, times(1)).writeResponse(eq(Status.NO_CONTENT), any(), emptyBaos());
}
origin: bbilger/jrestless

@Test
public void getArticle_ServiceExceptionGiven_ShouldReturnInternalServerError() throws IOException {
  when(testService.getArticle(1)).thenThrow(new RuntimeException());
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  container.handleRequest(new TestRequest("/articles/1", "GET"), responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.INTERNAL_SERVER_ERROR), any(), emptyBaos());
}
origin: bbilger/jrestless

@Test
public void deleteApp_NoAdminUserGiven_ShouldForbidAccess() throws IOException {
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  SecurityContext sc = mock(SecurityContext.class);
  Principal p = mock(Principal.class);
  when(sc.getUserPrincipal()).thenReturn(p);
  when(sc.isUserInRole("admin")).thenReturn(false);
  container.handleRequest(new TestRequest("/app", "DELETE"), responseWriter, sc);
  verify(responseWriter, times(1)).writeResponse(eq(Status.FORBIDDEN), any(), emptyBaos());
}
origin: bbilger/jrestless

@Test
public void getArticle_NonExistingIdGiven_ShouldReturnNotFound() throws IOException {
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  container.handleRequest(new TestRequest("/articles/1", "GET"), responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.NOT_FOUND), any(), emptyBaos());
}
origin: bbilger/jrestless

@Test
public void getArticle_ExistingIdGiven_ShouldReturnArticle() throws IOException {
  when(testService.getArticle(1)).thenReturn("some article");
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  container.handleRequest(new TestRequest("/articles/1", "GET"), responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.OK), any(), eqBaos("some article"));
}
origin: bbilger/jrestless

@Test
public void getArticle_NonSupportedAccept_ShouldReturnNotAcceptable() throws IOException {
  when(testService.getArticle(1)).thenReturn("some article");
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  TestRequest req = new TestRequest("/articles/1", "GET");
  req.getHeadersAsMultimap().add("Accept", MediaType.APPLICATION_XML);
  container.handleRequest(req, responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.NOT_ACCEPTABLE), any(), emptyBaos());
}
origin: bbilger/jrestless

@Test
public void getArticle_NonSupportedMethodGiven_ShouldReturnInternalServerError() throws IOException {
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  container.handleRequest(new TestRequest("/articles/1", "PATCH"), responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.METHOD_NOT_ALLOWED), any(), emptyBaos());
}
origin: bbilger/jrestless

@Test
public void getArticle_OneSupportedAcceptGiven_ShouldReturnArticle() throws IOException {
  when(testService.getArticle(1)).thenReturn("some article");
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  TestRequest req = new TestRequest("/articles/1", "GET");
  req.getHeadersAsMultimap().add("Accept", MediaType.APPLICATION_XML + "," + MediaType.TEXT_PLAIN);
  container.handleRequest(req, responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.OK), any(), eqBaos("some article"));
}
origin: bbilger/jrestless

@Test
public void getHeaderParam_HeaderParamNameGiven_ShouldReturnHeaderParam() throws IOException {
  JRestlessResponseWriter responseWriter = createResponseWriterMock();
  TestRequest req = new TestRequest("/header", "GET");
  req.getHeadersAsMultimap().add("key", "value");
  container.handleRequest(req, responseWriter, mock(SecurityContext.class));
  verify(responseWriter, times(1)).writeResponse(eq(Status.OK), any(), eqBaos("value"));
}
origin: bbilger/jrestless

@Test
public void delegateRequest_ContainerException_ShouldInvokeCallbacks() {
  JRestlessContainerRequest request = createMinimalRequest();
  RuntimeException containerException = new RuntimeException();
  doThrow(containerException).when(container).handleRequest(any(), any(), any(), any());
  SimpleContainerResponse response = handler.delegateRequest(request);
  assertEquals(500, response.getStatusType().getStatusCode());
  assertTrue(response.getHeaders().isEmpty());
  assertEquals(null, response.getBody());
  verify(handler, times(1)).beforeHandleRequest(eq(request), any());
  verify(handler, times(1)).onRequestFailure(same(containerException), eq(request), any());
}
com.jrestless.core.containerJRestlessHandlerContainerhandleRequest

Javadoc

Shortcut for #handleRequest(JRestlessContainerRequest,JRestlessResponseWriter,SecurityContext,Consumer)with noop containerRequestEnhancer.

Popular methods of JRestlessHandlerContainer

  • <init>
  • createContainerRequest
    Creates a new ContainerRequest for the given input.
  • createNewApplicationHandler
  • getConfiguration
  • onShutdown
    Inform this container that the server is being stopped. This method must be implicitly called before
  • onStartup
    Inform this container that the server has been started. This method must be implicitly called after
  • reload
  • getApplicationHandler

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • setContentView (Activity)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
  • JComboBox (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now