コード例 #1
0
  @SuppressWarnings("unchecked")
  @Test
  public void rpcCall_OK() {
    // Given : mock future remote call
    doSuccessCallback("returnValue")
        .when(mockedService)
        .myMethod(eq("myParamValue"), any(AsyncCallback.class));

    // When
    MyGwtClass gwtClass = new MyGwtClass();
    gwtClass.myValue = "toto";
    assertThat(gwtClass.myValue).isEqualTo("toto");
    gwtClass.run();

    // Then
    verify(mockedService).myMethod(eq("myParamValue"), any(AsyncCallback.class));

    assertThat(gwtClass.myValue).isEqualTo("returnValue");
  }
コード例 #2
0
  @SuppressWarnings("unchecked")
  @Test
  public void rpcCall_KO() {
    // Given

    // mock future remote call
    doFailureCallback(new Exception())
        .when(mockedService)
        .myMethod(eq("myParamValue"), any(AsyncCallback.class));

    // When
    MyGwtClass gwtClass = new MyGwtClass();
    gwtClass.myValue = "toto";
    assertThat(gwtClass.myValue).isEqualTo("toto");
    gwtClass.run();

    // Then
    assertThat(gwtClass.myValue).isEqualTo("error");
  }