### Question:
FilterRepository { void save(final Filter filter) { if (filter == null) { throw new IllegalArgumentException("Can't save null filter"); } if (exists(filter.getId())) { throw new IllegalArgumentException( String.format("Filter with id %s already exists", filter.getId())); } filters.put(filter.getId(), filter); } FilterRepository();   }### Answer:
@Test public void saveNullFilterShouldFail() { final Throwable throwable = catchThrowable(() -> repository.save(null)); assertThat(throwable) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Can't save null filter"); }
@Test public void saveFilterWithSameIdShouldFail() { final BlockFilter filter = new BlockFilter("x"); repository.save(filter); final Throwable throwable = catchThrowable(() -> repository.save(filter)); assertThat(throwable) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Filter with id x already exists"); }