Search in sources :

Example 1 with IGwtRpcSerializationPolicyCache

use of org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache in project pentaho-platform by pentaho.

the class AbstractGwtRpcRequestMatcherTest method testConstructWithSerializationPolicyCache.

// endregion
// region Serialization Policy Cache
@Test
public void testConstructWithSerializationPolicyCache() {
    IGwtRpcSerializationPolicyCache cache = mock(IGwtRpcSerializationPolicyCache.class);
    AbstractGwtRpcRequestMatcher matcher = new TestRequestMatcher(TEST_PATTERN, TEST_RPC_METHODS_SINGLE, cache);
    assertEquals(cache, matcher.getSerializationPolicyCache());
}
Also used : IGwtRpcSerializationPolicyCache(org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache) Test(org.junit.Test)

Example 2 with IGwtRpcSerializationPolicyCache

use of org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache in project pentaho-platform by pentaho.

the class SystemGwtRpcRequestMatcherTest method testGetGwtRpcReturnsASystemGwtRpc.

// endregion
// region getGwtRpc integration
@Test
public void testGetGwtRpcReturnsASystemGwtRpc() {
    HttpServletRequest requestMock = createRequestMock(HttpMethod.POST, TEST_PATH);
    IGwtRpcSerializationPolicyCache serializationPolicyCache = (moduleBaseURL, strongName, sourceProvider) -> {
        throw new UnsupportedOperationException();
    };
    SystemGwtRpcRequestMatcher matcher = spy(new SystemGwtRpcRequestMatcher(TEST_PATTERN, TEST_RPC_METHODS_SINGLE, serializationPolicyCache));
    // ---
    AbstractGwtRpc gwtRpc = matcher.getGwtRpc(requestMock);
    assertNotNull(gwtRpc);
    assertTrue(gwtRpc instanceof SystemGwtRpc);
    assertEquals(requestMock, gwtRpc.getServletRequest());
    assertEquals(serializationPolicyCache, gwtRpc.getSerializationPolicyCache());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AbstractGwtRpc(org.pentaho.platform.web.gwt.rpc.AbstractGwtRpc) SystemGwtRpc(org.pentaho.platform.web.gwt.rpc.SystemGwtRpc) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) IGwtRpcSerializationPolicyCache(org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache) Mockito.spy(org.mockito.Mockito.spy) HttpMethod(javax.ws.rs.HttpMethod) Mockito.verify(org.mockito.Mockito.verify) HttpServletRequest(javax.servlet.http.HttpServletRequest) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) NonNull(edu.umd.cs.findbugs.annotations.NonNull) Collections(java.util.Collections) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) IGwtRpcSerializationPolicyCache(org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache) AbstractGwtRpc(org.pentaho.platform.web.gwt.rpc.AbstractGwtRpc) SystemGwtRpc(org.pentaho.platform.web.gwt.rpc.SystemGwtRpc) Test(org.junit.Test)

Example 3 with IGwtRpcSerializationPolicyCache

use of org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache in project pentaho-platform by pentaho.

the class PluginGwtRpcRequestMatcherTest method testGetGwtRpcReturnsAPluginGwtRpc.

// endregion
// region getGwtRpc integration
@Test
public void testGetGwtRpcReturnsAPluginGwtRpc() {
    HttpServletRequest requestMock = createRequestMock(HttpMethod.POST, TEST_PATH);
    IGwtRpcSerializationPolicyCache serializationPolicyCache = (moduleBaseURL, strongName, sourceProvider) -> {
        throw new UnsupportedOperationException();
    };
    PluginGwtRpcRequestMatcher matcher = spy(new PluginGwtRpcRequestMatcher(TEST_PATTERN, TEST_RPC_METHODS_SINGLE, serializationPolicyCache));
    // ---
    AbstractGwtRpc gwtRpc = matcher.getGwtRpc(requestMock);
    assertNotNull(gwtRpc);
    assertTrue(gwtRpc instanceof PluginGwtRpc);
    assertEquals(requestMock, gwtRpc.getServletRequest());
    assertEquals(serializationPolicyCache, gwtRpc.getSerializationPolicyCache());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AbstractGwtRpc(org.pentaho.platform.web.gwt.rpc.AbstractGwtRpc) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) IGwtRpcSerializationPolicyCache(org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache) Mockito.spy(org.mockito.Mockito.spy) PluginGwtRpc(org.pentaho.platform.web.gwt.rpc.PluginGwtRpc) HttpMethod(javax.ws.rs.HttpMethod) Mockito.verify(org.mockito.Mockito.verify) HttpServletRequest(javax.servlet.http.HttpServletRequest) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) NonNull(edu.umd.cs.findbugs.annotations.NonNull) Collections(java.util.Collections) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) IGwtRpcSerializationPolicyCache(org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache) AbstractGwtRpc(org.pentaho.platform.web.gwt.rpc.AbstractGwtRpc) PluginGwtRpc(org.pentaho.platform.web.gwt.rpc.PluginGwtRpc) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 IGwtRpcSerializationPolicyCache (org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache)3 NonNull (edu.umd.cs.findbugs.annotations.NonNull)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpMethod (javax.ws.rs.HttpMethod)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertFalse (org.junit.Assert.assertFalse)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 Assert.assertNull (org.junit.Assert.assertNull)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 Mockito.doReturn (org.mockito.Mockito.doReturn)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.spy (org.mockito.Mockito.spy)2 Mockito.times (org.mockito.Mockito.times)2 Mockito.verify (org.mockito.Mockito.verify)2 Mockito.when (org.mockito.Mockito.when)2