### Question:
CommonResource extends ServerResource { protected Map<String, String> parseFilters(final List<String> parameters) { if (parameters == null) { return null; } final Map<String, String> results = new HashMap<>(); for (final String parameter : parameters) { final String[] split = parameter.split("="); if (split.length < 2) { results.put(split[0], null); } else { results.put(split[0], parameter.substring(split[0].length() + 1)); } } return results; }  APISession getEngineSession(); HttpSession getHttpSession(); HttpServletRequest getHttpRequest(); Integer getIntegerParameter(final String parameterName, final boolean mandatory); Long getLongParameter(final String parameterName, final boolean mandatory); String getParameter(final String parameterName, final boolean mandatory); List<String> getParameterAsList(final String name); SearchOptions buildSearchOptions(); @Override String getAttribute(final String name); Long getPathParamAsLong(final String parameterName); List<Long> getParameterAsLongList(final String parameterName); String getPathParam(final String name);  }### Answer:
@Test public void parseFilterShoulReturnNullIfListIsNull() throws Exception { assertThat(new CommonResource().parseFilters(null)).isNull(); }
@Test public void parseFilterShouldBuildExpectedMap() throws Exception { final List<String> filters = Arrays.asList("toto=17", "titi='EN_ECHEC'", "task=task=with=equal=in=name"); final Map<String, String> parseFilters = new CommonResource().parseFilters(filters); assertThat(parseFilters.size()).isEqualTo(3); assertThat(parseFilters.get("toto")).isEqualTo("17"); assertThat(parseFilters.get("titi")).isEqualTo("'EN_ECHEC'"); assertThat(parseFilters.get("task")).isEqualTo("task=with=equal=in=name"); }
@Test public void parseFilterWithSpecialCharactersShouldBuildExpectedMap() throws Exception { final List<String> filters = Arrays.asList("a=b", "c=/d/d,e"); final Map<String, String> parseFilters = new CommonResource().parseFilters(filters); assertThat(parseFilters.size()).isEqualTo(2); assertThat(parseFilters.get("a")).isEqualTo("b"); assertThat(parseFilters.get("c")).isEqualTo("/d/d,e"); }
@Test public void parseFilterShouldBuildMapEvenIfNoValueForParam() throws Exception { final List<String> filters = new ArrayList<>(2); filters.add("nomatchingvalue="); final Map<String, String> parseFilters = new CommonResource().parseFilters(filters); assertThat(parseFilters.size()).isEqualTo(1); assertThat(parseFilters.get("nomatchingvalue")).isNull(); }