AdvertisementFilter { @Nonnull public static AdvertisementFilter valueOf(String filter) { Objects.requireNonNull(filter, "filter"); if (filter.trim().isEmpty()) { throw new IllegalArgumentException("Advertisement filter is empty"); } String trimmed = filter.trim(); if (ALL.type.code.equalsIgnoreCase(trimmed)) { return ALL; } if (NONE.type.code.equalsIgnoreCase(trimmed)) { return NONE; } throw new InvalidFormatException("Advertisement filter: unsupported value '" + trimmed + "'. Only " + "'all' or 'none' are supported"); } private  AdvertisementFilter(FilterType type); @Nonnull static AdvertisementFilter valueOf(String filter); boolean isSendAdvertisement(); static final AdvertisementFilter ALL; static final AdvertisementFilter NONE; }
@Test(expected = InvalidFormatException.class) public void testInvalidFormat() { AdvertisementFilter.valueOf("something"); }
@Test(expected = IllegalArgumentException.class) public void testEmptyFilterConfig() { AdvertisementFilter.valueOf(""); }
@Test(expected = NullPointerException.class) public void testNullFilterConfig() { AdvertisementFilter.valueOf(null); }