JMAPConfiguration { public static Builder builder() { return new Builder(); } @VisibleForTesting  JMAPConfiguration(boolean enabled, Optional<Port> port); static Builder builder(); boolean isEnabled(); Optional<Port> getPort();  }
@Test void buildShouldThrowWhenEnableIsMissing() { assertThatThrownBy(() -> JMAPConfiguration.builder().build()) .isInstanceOf(IllegalStateException.class) .hasMessage("You should specify if JMAP server should be started"); }
@Test void buildShouldWorkWhenRandomPort() { JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(ENABLED, Optional.empty()); JMAPConfiguration jmapConfiguration = JMAPConfiguration.builder() .enable() .randomPort() .build(); assertThat(jmapConfiguration).isEqualToComparingFieldByField(expectedJMAPConfiguration); }
@Test void buildShouldWorkWhenFixedPort() { JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(ENABLED, Optional.of(Port.of(80))); JMAPConfiguration jmapConfiguration = JMAPConfiguration.builder() .enable() .port(Port.of(80)) .build(); assertThat(jmapConfiguration).isEqualToComparingFieldByField(expectedJMAPConfiguration); }
@Test void buildShouldWorkWhenDisabled() { JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(DISABLED, Optional.empty()); JMAPConfiguration jmapConfiguration = JMAPConfiguration.builder() .disable() .build(); assertThat(jmapConfiguration).isEqualToComparingFieldByField(expectedJMAPConfiguration); }