예제 #1
0
  @Test
  public void shouldReturnSameRequestWithoutEventsIfCannotCommitDeltaToLibraryBackend()
      throws Exception {
    when(syncTemplate.postForObject(
            anyString(), eq(JsonConverter.toJson(request)), eq(String.class)))
        .thenThrow(new RuntimeException("Some server error"));
    assertNotNull(request.getEvents());

    messEngine.send(commitRequest);

    @SuppressWarnings("unchecked")
    Message<SyncValueObject> response =
        (Message<SyncValueObject>)
            messEngine.getMessage(MessEngineConstants.SYNC_SEND_DELTA_RESPONSE);
    assertNotNull(response);
    assertEquals(request, response.getBody());
    assertNull(request.getEvents());
  }
예제 #2
0
  @Test
  public void shouldForwardCommitRequestToLibraryBackendAndReturnResponseWithoutEvents()
      throws Exception {
    when(syncTemplate.postForObject(
            anyString(), eq(JsonConverter.toJson(request)), eq(String.class)))
        .thenReturn(JsonConverter.toJson(expectedResponse));
    assertNotNull(request.getEvents());
    assertNotNull(expectedResponse.getEvents());

    messEngine.send(commitRequest);

    @SuppressWarnings("unchecked")
    Message<SyncValueObject> response =
        (Message<SyncValueObject>)
            messEngine.getMessage(MessEngineConstants.SYNC_SEND_DELTA_RESPONSE);
    assertNotNull(response);
    SyncValueObject actualResponse = response.getBody();
    assertEquals(expectedResponse, actualResponse);
    assertNull(actualResponse.getEvents());
  }