### Question:
QueryParser { public static List<String> parseQuery(String query) { List<String> result = Lists.newArrayList(); if (!Strings.isNullOrEmpty(query)) { query = query.replaceAll("(\\s*[+-]\\s*)", "#SPLIT#$1"); return Arrays.stream(query.split("(#SPLIT#| )")) .map(String::trim) .filter(s -> !s.isEmpty()) .collect(Collectors.toList()); } return result; }  static List<String> parseQuery(String query);  }### Answer:
@Test public void parseQuery() { List<String> parts = QueryParser.parseQuery("+Turkey-Inflation"); assertEquals(Lists.newArrayList("+Turkey", "-Inflation"), parts); parts = QueryParser.parseQuery("+Turkey -Inflation"); assertEquals(Lists.newArrayList("+Turkey", "-Inflation"), parts); parts = QueryParser.parseQuery("Turkey -Inflation"); assertEquals(Lists.newArrayList("Turkey", "-Inflation"), parts); parts = QueryParser.parseQuery("+Turkey attack"); assertEquals(Lists.newArrayList("+Turkey", "attack"), parts); }