Search in sources :

Example 11 with RPCRequest

use of com.google.gwt.user.server.rpc.RPCRequest in project pentaho-platform by pentaho.

the class AbstractGwtRpcTest method testGetRequestFirstTime.

// endregion
// region Request
@Test
public void testGetRequestFirstTime() {
    String requestPayload = "REQUEST_PAYLOAD";
    // new Object would have a null class loader!
    Object target = this;
    RPCRequest rpcRequest = new RPCRequest(null, null, null, 0);
    HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
    TestGwtRpc gwtRpcSpy = spy(new TestGwtRpc(httpRequestMock));
    doReturn(requestPayload).when(gwtRpcSpy).getRequestPayload();
    doReturn(target).when(gwtRpcSpy).resolveTarget();
    try (MockedStatic<RPC> rpc = Mockito.mockStatic(RPC.class)) {
        rpc.when(() -> RPC.decodeRequest(eq(requestPayload), eq(null), any())).thenReturn(rpcRequest);
        RPCRequest result = gwtRpcSpy.getRequest();
        assertEquals(rpcRequest, result);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RPC(com.google.gwt.user.server.rpc.RPC) RPCRequest(com.google.gwt.user.server.rpc.RPCRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Aggregations

RPCRequest (com.google.gwt.user.server.rpc.RPCRequest)11 Method (java.lang.reflect.Method)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 RPC (com.google.gwt.user.server.rpc.RPC)7 SerializationPolicy (com.google.gwt.user.server.rpc.SerializationPolicy)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 SerializationException (com.google.gwt.user.client.rpc.SerializationException)5 GwtRpcProxyException (org.pentaho.platform.web.servlet.GwtRpcProxyException)5 NonNull (edu.umd.cs.findbugs.annotations.NonNull)4 IncompatibleRemoteServiceException (com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException)3 RemoteService (com.google.gwt.user.client.rpc.RemoteService)2 RPCServletUtils (com.google.gwt.user.server.rpc.RPCServletUtils)2 SerializationPolicyLoader (com.google.gwt.user.server.rpc.SerializationPolicyLoader)2 Nullable (edu.umd.cs.findbugs.annotations.Nullable)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 MalformedURLException (java.net.MalformedURLException)2 ParseException (java.text.ParseException)2 Function (java.util.function.Function)2 ServletContext (javax.servlet.ServletContext)2