ReportingUserAgent implements Field { public static Builder builder() { return new Builder(); } private  ReportingUserAgent(String userAgentName, Optional<String> userAgentProduct); static Builder builder(); String getUserAgentName(); Optional<String> getUserAgentProduct(); @Override String formattedValue(); @Override final boolean equals(Object o); @Override final int hashCode(); @Override String toString(); static final Predicate<String> IS_EMPTY; }
@Test void productShouldBeOptional() { assertThat(ReportingUserAgent.builder() .userAgentName(USER_AGENT_NAME) .build()) .isEqualTo(ReportingUserAgent.builder() .userAgentName(USER_AGENT_NAME) .build()); }
@Test void shouldThrowOnNullName() { String userAgentName = null; assertThatThrownBy(() -> ReportingUserAgent.builder() .userAgentName(userAgentName) .build()) .isInstanceOf(NullPointerException.class); }
@Test void shouldThrowOnNullNameWhenSpecifyingProduct() { String userAgentName = null; assertThatThrownBy(() -> ReportingUserAgent.builder() .userAgentName(userAgentName) .userAgentProduct(USER_AGENT_PRODUCT) .build()) .isInstanceOf(NullPointerException.class); }
@Test void shouldThrowOnNullProduct() { String userAgentProduct = null; assertThatThrownBy(() -> ReportingUserAgent.builder() .userAgentName(USER_AGENT_NAME) .userAgentProduct(userAgentProduct) .build()) .isInstanceOf(NullPointerException.class); }
@Test void shouldThrowOnEmptyName() { String userAgentName = ""; assertThatThrownBy(() -> ReportingUserAgent.builder() .userAgentName(userAgentName) .build()) .isInstanceOf(IllegalStateException.class); }
@Test void shouldThrowOnFoldingWhiteSpaceName() { String userAgentName = " "; assertThatThrownBy(() -> ReportingUserAgent.builder() .userAgentName(userAgentName) .build()) .isInstanceOf(IllegalStateException.class); }
@Test void shouldThrowOnNameWithLineBreak() { String userAgentName = "a\nb"; assertThatThrownBy(() -> ReportingUserAgent.builder() .userAgentName(userAgentName) .build()) .isInstanceOf(IllegalStateException.class); }
@Test void shouldThrowOnNameWithLineBreakAtTheEnd() { String userAgentName = "a\n"; assertThatThrownBy(() -> ReportingUserAgent.builder() .userAgentName(userAgentName) .build()) .isInstanceOf(IllegalStateException.class); }
@Test void shouldThrowOnNameWithLineBreakAtTheBeginning() { String userAgentName = "\nb"; assertThatThrownBy(() -> ReportingUserAgent.builder() .userAgentName(userAgentName) .build()) .isInstanceOf(IllegalStateException.class); }