@Test
public void errorMessageContainsRootBulkErrorCausedByInfoIfAvailable() {

    // given
    String expectedType = UUID.randomUUID().toString();
    String expectedReason = UUID.randomUUID().toString();
    String expectedCausedByType = UUID.randomUUID().toString();
    String expectedCausedByReason = UUID.randomUUID().toString();
    BulkError causedByError = new BulkError();
    causedByError.setType(expectedCausedByType);
    causedByError.setReason(expectedCausedByReason);
    BulkError error = new BulkError();
    error.setType(expectedType);
    error.setReason(expectedReason);
    error.setCausedBy(causedByError);
    BufferedBulkResult result = createTestBufferedBulkResult(false, error);
    // when
    String actualMessage = result.getErrorMessage(DEFAULT_TEST_MESSAGE);
    // then
    assertTrue(actualMessage.contains(expectedCausedByType));
    assertTrue(actualMessage.contains(expectedCausedByReason));
    assertFalse(actualMessage.contains(expectedType));
    assertFalse(actualMessage.contains(expectedReason));
}