ImmutableFeatureDefinition implements FeatureDefinition { public static Builder getBuilder(final DefinitionIdentifier firstIdentifier) { return Builder.getInstance().add(checkNotNull(firstIdentifier, "first identifier")); } private  ImmutableFeatureDefinition(final Collection<DefinitionIdentifier> identifiers); static ImmutableFeatureDefinition fromJson(final JsonArray featureDefinitionEntriesAsJsonArray); static Builder getBuilder(final DefinitionIdentifier firstIdentifier); @Override DefinitionIdentifier getFirstIdentifier(); @Override int getSize(); @Override Stream<DefinitionIdentifier> stream(); @Override Iterator<DefinitionIdentifier> iterator(); @Override JsonArray toJson(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void tryToGetBuilderWithNullIdentifier() { assertThatNullPointerException() .isThrownBy(() -> ImmutableFeatureDefinition.getBuilder(null)) .withMessage("The %s must not be null!", "first identifier") .withNoCause(); }
@Test public void addIdentifierToBuilderWorksAsExpected() { final FeatureDefinitionBuilder underTest = ImmutableFeatureDefinition.getBuilder(FIRST_IDENTIFIER); underTest.add(SECOND_IDENTIFIER); assertThat(underTest).containsExactly(FIRST_IDENTIFIER, SECOND_IDENTIFIER); }
@Test public void addAllToBuilderWorksAsExpected() { final List<DefinitionIdentifier> additionalIdentifiers = Arrays.asList(THIRD_IDENTIFIER, SECOND_IDENTIFIER); final FeatureDefinitionBuilder underTest = ImmutableFeatureDefinition.getBuilder(FIRST_IDENTIFIER); underTest.addAll(additionalIdentifiers); assertThat(underTest).containsExactly(FIRST_IDENTIFIER, THIRD_IDENTIFIER, SECOND_IDENTIFIER); }
@Test public void removeIdentifierFromBuilderWorksAsExpected() { final FeatureDefinitionBuilder underTest = ImmutableFeatureDefinition.getBuilder(FIRST_IDENTIFIER); underTest.add(SECOND_IDENTIFIER); underTest.remove(FIRST_IDENTIFIER); assertThat(underTest).containsOnly(SECOND_IDENTIFIER); }
@Test public void tryToBuildFeatureDefinitionWithEmptyBuilder() { final FeatureDefinitionBuilder underTest = ImmutableFeatureDefinition.getBuilder(FIRST_IDENTIFIER); underTest.remove(FIRST_IDENTIFIER); assertThatExceptionOfType(IndexOutOfBoundsException.class) .isThrownBy(underTest::build) .withMessage("This builder does not contain at least one Identifier!") .withNoCause(); }
@Test public void valuesAreInExpectedOrder() { final ImmutableFeatureDefinition underTest = ImmutableFeatureDefinition.getBuilder(SECOND_IDENTIFIER) .add(THIRD_IDENTIFIER) .add(FIRST_IDENTIFIER) .build(); assertThat(underTest).containsExactly(SECOND_IDENTIFIER, THIRD_IDENTIFIER, FIRST_IDENTIFIER); }