SetMessagesResponse implements Method.Response { public static Builder builder() { return new Builder(); } @VisibleForTesting  SetMessagesResponse(String accountId, String oldState, String newState, ImmutableMap<CreationMessageId, MessageFullView> created, ImmutableMap<CreationMessageId, MessageId> mdnSent, ImmutableList<MessageId> updated, ImmutableList<MessageId> destroyed,
                                           ImmutableMap<CreationMessageId, SetError> notCreated, ImmutableMap<CreationMessageId, SetError> mdnNotSent, ImmutableMap<MessageId, SetError> notUpdated, ImmutableMap<MessageId, SetError> notDestroyed); static Builder builder(); String getAccountId(); String getOldState(); String getNewState(); ImmutableMap<CreationMessageId, MessageFullView> getCreated(); ImmutableList<MessageId> getUpdated(); ImmutableList<MessageId> getDestroyed(); ImmutableMap<CreationMessageId, SetError> getNotCreated(); ImmutableMap<MessageId, SetError> getNotUpdated(); ImmutableMap<MessageId, SetError> getNotDestroyed(); @JsonProperty("MDNSent") ImmutableMap<CreationMessageId, MessageId> getMDNSent(); @JsonProperty("MDNNotSent") ImmutableMap<CreationMessageId, SetError> getMDNNotSent(); SetMessagesResponse.Builder mergeInto(SetMessagesResponse.Builder responseBuilder);  }
@Test public void builderShouldThrowWhenAccountIdIsGiven() { assertThatThrownBy(() -> SetMessagesResponse.builder().accountId("")) .isInstanceOf(NotImplementedException.class); }
@Test public void builderShouldThrowWhenOldStateGiven() { assertThatThrownBy(() -> SetMessagesResponse.builder().oldState("")) .isInstanceOf(NotImplementedException.class); }
@Test public void builderShouldThrowWhenNewStateIsGiven() { assertThatThrownBy(() -> SetMessagesResponse.builder().newState("")) .isInstanceOf(NotImplementedException.class); }
@Test public void builderShouldWork() { Instant currentDate = Instant.now(); ImmutableMap<CreationMessageId, MessageFullView> created = ImmutableMap.of(CreationMessageId.of("user|created|1"), MessageFullView.builder() .id(TestMessageId.of(1)) .blobId(BlobId.of("blobId")) .threadId("threadId") .mailboxId(InMemoryId.of(123)) .headers(ImmutableMap.of("key", "value")) .subject("subject") .size(123) .date(currentDate) .preview(PREVIEW) .hasAttachment(false) .build()); ImmutableList<MessageId> updated = ImmutableList.of(TestMessageId.of(2)); ImmutableList<MessageId> destroyed = ImmutableList.of(TestMessageId.of(3)); ImmutableMap<CreationMessageId, SetError> notCreated = ImmutableMap.of(CreationMessageId.of("dead-beef-defec8"), SetError.builder().type(SetError.Type.INVALID_PROPERTIES).build()); ImmutableMap<MessageId, SetError> notUpdated = ImmutableMap.of(TestMessageId.of(4), SetError.builder().type(SetError.Type.INVALID_ARGUMENTS).build()); ImmutableMap<MessageId, SetError> notDestroyed = ImmutableMap.of(TestMessageId.of(5), SetError.builder().type(SetError.Type.ERROR).build()); ImmutableMap<CreationMessageId, SetError> mdnNotSent = ImmutableMap.of(CreationMessageId.of("dead-beef-defec9"), SetError.builder().type(SetError.Type.NOT_FOUND).build()); ImmutableMap<CreationMessageId, MessageId> mdnSent = ImmutableMap.of(CreationMessageId.of("dead-beef-defed0"), TestMessageId.of(12)); SetMessagesResponse expected = new SetMessagesResponse(null, null, null, created, mdnSent, updated, destroyed, notCreated, mdnNotSent, notUpdated, notDestroyed); SetMessagesResponse setMessagesResponse = SetMessagesResponse.builder() .created(created) .updated(updated) .destroyed(destroyed) .notCreated(notCreated) .notUpdated(notUpdated) .notDestroyed(notDestroyed) .mdnNotSent(mdnNotSent) .mdnSent(mdnSent) .build(); assertThat(setMessagesResponse).isEqualToComparingFieldByField(expected); }