MultimailboxesSearchQuery { public static Builder from(SearchQuery searchQuery) { return new Builder(searchQuery); } @VisibleForTesting  MultimailboxesSearchQuery(SearchQuery searchQuery, ImmutableSet<MailboxId> inMailboxes, ImmutableSet<MailboxId> notInMailboxes, Namespace namespace); static Builder from(SearchQuery searchQuery); ImmutableSet<MailboxId> getInMailboxes(); ImmutableSet<MailboxId> getNotInMailboxes(); SearchQuery getSearchQuery(); Namespace getNamespace();  }
@Test void buildShouldThrowWhenQueryIsNull() { assertThatThrownBy(() -> MultimailboxesSearchQuery.from(null)) .isInstanceOf(NullPointerException.class); }
@Test void buildShouldBuildWheninMailboxes() { ImmutableSet<MailboxId> inMailboxes = ImmutableSet.of(); ImmutableSet<MailboxId> notInMailboxes = ImmutableSet.of(); MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, inMailboxes, notInMailboxes, new AccessibleNamespace()); MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).build(); assertThat(actual).isEqualToComparingFieldByField(expected); }
@Test void buildShouldBuildWhenEmptyMailboxes() { ImmutableSet<MailboxId> inMailboxes = ImmutableSet.of(); ImmutableSet<MailboxId> notInMailboxes = ImmutableSet.of(); MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, inMailboxes, notInMailboxes, new AccessibleNamespace()); MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).inMailboxes().build(); assertThat(actual).isEqualToComparingFieldByField(expected); }
@Test void buildShouldBuildWhenEmptyNotInMailboxes() { ImmutableSet<MailboxId> inMailboxes = ImmutableSet.of(); ImmutableSet<MailboxId> notInMailboxes = ImmutableSet.of(); MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, inMailboxes, notInMailboxes, new AccessibleNamespace()); MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).notInMailboxes().build(); assertThat(actual).isEqualToComparingFieldByField(expected); }
@Test void buildShouldBuildWhenOneMailbox() { ImmutableSet<MailboxId> inMailboxes = ImmutableSet.of(ID_1); ImmutableSet<MailboxId> notInMailboxes = ImmutableSet.of(); MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, inMailboxes, notInMailboxes, new AccessibleNamespace()); MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).inMailboxes(ID_1).build(); assertThat(actual).isEqualToComparingFieldByField(expected); }
@Test void buildShouldBuildWhenOneNotInMailbox() { ImmutableSet<MailboxId> inMailboxes = ImmutableSet.of(); ImmutableSet<MailboxId> notInMailboxes = ImmutableSet.of(ID_1); MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, inMailboxes, notInMailboxes, new AccessibleNamespace()); MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).notInMailboxes(ID_1).build(); assertThat(actual).isEqualToComparingFieldByField(expected); }
@Test void buildShouldBuildWhenAllDefined() { ImmutableSet<MailboxId> inMailboxes = ImmutableSet.of(ID_1); ImmutableSet<MailboxId> notInMailboxes = ImmutableSet.of(ID_2); MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, inMailboxes, notInMailboxes, new AccessibleNamespace()); MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).inMailboxes(ID_1).notInMailboxes(ID_2).build(); assertThat(actual).isEqualToComparingFieldByField(expected); }