### Question:
Icinga2Result { public boolean isSuccess() { return getCodeOfFirstElement().filter(c -> c == 200).isPresent() && getStatusOfFirstElement().filter(s -> s.toLowerCase().startsWith("successful")).isPresent(); }  List<Map<String, String>> getResults(); void setResults(List<Map<String, String>> results); Optional<String> getStatusOfFirstElement(); Optional<Integer> getCodeOfFirstElement(); boolean isSuccess(); String getFirstElementAsString();  }### Answer:
@Test public void testIsSuccess() throws Exception { Icinga2Result result = new Icinga2Result(); result.setResults(Collections.singletonList(null)); assertFalse(result.isSuccess()); result.setResults(Collections.singletonList(new HashMap<>())); assertFalse(result.isSuccess()); Map<String, String> map = new HashMap<>(); map.put("code", null); map.put("status", null); result.setResults(Collections.singletonList(map)); assertFalse(result.isSuccess()); map.put("code", "200.00"); assertFalse(result.isSuccess()); map.put("status", "unsuccessful"); assertFalse(result.isSuccess()); map.put("status", "Successfully processed"); assertTrue(result.isSuccess()); assertEquals(result.getFirstElementAsString(), "[200] - Successfully processed"); }