@Test
public void canDeserializeSuccessWithFailedItemsResponse() throws IOException {

    // given
    Random random = new Random();
    BulkResultItem bulkResultItem = createTestErrorBulkResultItem(random.nextInt(1000));
    int took = random.nextInt(1000);
    TestResult testResult = new TestResult();
    testResult.errors = true;
    testResult.took = took;
    testResult.items = new ArrayList<>();
    testResult.items.add(bulkResultItem);
    BufferedBulk.Builder builder = createDefaultTestMockedBuilder();
    builder.withObjectReader(new BufferedBulkOperations(mock(PooledItemSourceFactory.class)).configuredReader());
    BufferedBulk bulk = builder.build();
    ObjectMapper mapper = new ObjectMapper()
            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
            .addMixIn(BulkResultItem.class, BulkResultItemMixIn.class);
    InputStream inputStream = new ByteArrayInputStream(mapper.writeValueAsBytes(testResult));
    // when
    BufferedBulkResult result = bulk.deserializeResponse(inputStream);
    // then
    assertFalse(result.isSucceeded());
    assertEquals(testResult.took, result.getTook());
    BulkResultItem resultItem = testResult.items.get(0);
    assertEquals(bulkResultItem, resultItem);
}