MailetUtil { public static int getInitParameterAsStrictlyPositiveInteger(String condition, int defaultValue) throws MessagingException { String defaultStringValue = String.valueOf(defaultValue); return getInitParameterAsStrictlyPositiveInteger(condition, Optional.of(defaultStringValue)); }  static Optional<Boolean> getInitParameter(MailetConfig config, String name); static int getInitParameterAsStrictlyPositiveInteger(String condition, int defaultValue); static int getInitParameterAsStrictlyPositiveInteger(String condition);  }
@Test void getInitParameterAsStrictlyPositiveIntegerShouldThrowOnEmptyString() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger("")) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerShouldThrowOnNull() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger(null)) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerShouldThrowOnInvalid() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger("invalid")) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerShouldThrowOnNegativeNumber() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger("-1")) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerShouldThrowOnZero() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger("0")) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerShouldParseCorrectValue() throws Exception { assertThat(MailetUtil.getInitParameterAsStrictlyPositiveInteger("1")) .isEqualTo(1); }
@Test void getInitParameterAsStrictlyPositiveIntegerWithDefaultValueShouldThrowOnEmptyString() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger("", DEFAULT_VALUE)) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerWithDefaultValueShouldReturnDefaultValueOnNull() throws Exception { assertThat(MailetUtil.getInitParameterAsStrictlyPositiveInteger(null, DEFAULT_VALUE)) .isEqualTo(DEFAULT_VALUE); }
@Test void getInitParameterAsStrictlyPositiveIntegerWithDefaultValueShouldThrowOnInvalid() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger("invalid", DEFAULT_VALUE)) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerWithDefaultValueShouldThrowOnNegativeNumber() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger("-1", DEFAULT_VALUE)) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerWithDefaultValueShouldThrowOnZero() { assertThatThrownBy(() -> MailetUtil.getInitParameterAsStrictlyPositiveInteger("0", DEFAULT_VALUE)) .isInstanceOf(MessagingException.class); }
@Test void getInitParameterAsStrictlyPositiveIntegerWithDefaultValueShouldParseCorrectValue() throws Exception { assertThat(MailetUtil.getInitParameterAsStrictlyPositiveInteger("1", DEFAULT_VALUE)) .isEqualTo(1); }