SerializableReIndexingExecutionFailures { public static SerializableReIndexingExecutionFailures from(ReIndexingExecutionFailures reIndexingExecutionFailures) { return new SerializableReIndexingExecutionFailures( reIndexingExecutionFailures.messageFailures() .stream() .map(failure -> new SerializableReIndexingExecutionFailures.SerializableReIndexingFailure(failure.getMailboxId(), failure.getUid())) .collect(Guavate.toImmutableList())); } SerializableReIndexingExecutionFailures(List<SerializableReIndexingFailure> failures); static SerializableReIndexingExecutionFailures from(ReIndexingExecutionFailures reIndexingExecutionFailures); @JsonValue Multimap<String, SerializableReIndexingFailure> failures();  }
@Test void failuresShouldBeSerializedAsEmptyArrayWhenNone() throws Exception { ReIndexingExecutionFailures failures = new ReIndexingExecutionFailures(ImmutableList.of(), ImmutableList.of()); assertThatJson(objectMapper.writeValueAsString(SerializableReIndexingExecutionFailures.from(failures))) .when(Option.IGNORING_ARRAY_ORDER) .isEqualTo("{}"); }
@Test void failuresShouldBeSerializedGroupedByMailboxId() throws Exception { ReIndexingExecutionFailures failures = new ReIndexingExecutionFailures(ImmutableList.of( new ReIndexingExecutionFailures.ReIndexingFailure(InMemoryId.of(45), MessageUid.of(34)), new ReIndexingExecutionFailures.ReIndexingFailure(InMemoryId.of(45), MessageUid.of(33)), new ReIndexingExecutionFailures.ReIndexingFailure(InMemoryId.of(44), MessageUid.of(31)), new ReIndexingExecutionFailures.ReIndexingFailure(InMemoryId.of(44), MessageUid.of(34)), new ReIndexingExecutionFailures.ReIndexingFailure(InMemoryId.of(41), MessageUid.of(18)), new ReIndexingExecutionFailures.ReIndexingFailure(InMemoryId.of(16), MessageUid.of(24))), ImmutableList.of()); assertThatJson(objectMapper.writeValueAsString(SerializableReIndexingExecutionFailures.from(failures))) .when(Option.IGNORING_ARRAY_ORDER) .isEqualTo("{" + " \"45\":[{\"uid\":34}, {\"uid\":33}]," + " \"44\":[{\"uid\":31}, {\"uid\":34}]," + " \"41\":[{\"uid\":18}]," + " \"16\":[{\"uid\":24}]" + "}"); }