void () { myRepository.setCurrentProject(RedmineRepository.UNSPECIFIED_PROJECT); final List<Element> options = XmlSerializer.serialize(myRepository).getChildren("option"); final String serializedId = StreamEx.of(options) .findFirst(elem -> "currentProject".equals(elem.getAttributeValue("name"))) .map(elem -> elem.getChild("RedmineProject")) .map(elem -> elem.getAttributeValue("id")) .orElse(null); assertEquals("-1", serializedId); }