### Question:
FilterAccessor { public String getMandatory(String filter) { ensureFilterValue(filter); return getFilters().get(filter); } FilterAccessor(Map<String, String> filters); String getMandatory(String filter); S getMandatory(String filter, ValueConverter<S> converter);  }### Answer:
@Test public void testWeCanRetrieveMandatoryValue() throws Exception { FilterAccessor filterAccess = new FilterAccessor(Collections.singletonMap("key", "value")); String value = filterAccess.getMandatory("key"); assertEquals("value", value); }
@Test(expected = APIFilterMandatoryException.class) public void testAccessToMandatoryValueWhichItDoesntExitThrowException() { FilterAccessor filterAccess = new FilterAccessor(Collections.<String, String> emptyMap()); filterAccess.getMandatory("key"); }
@Test(expected = APIFilterMandatoryException.class) public void testAccessToMandatoryValueNotConvertibleThrowException() { FilterAccessor filterAccess = new FilterAccessor(Collections.singletonMap("key", "value")); filterAccess.getMandatory("key", new MemberTypeConverter()); }