PossibleLogImporters { public void addMissing(List<LogImporter> toAdd) { final Map<String, LogImporter> availableMap = availableImporters .stream() .collect(Collectors.toMap(PluginableElement::getPluginableId, li -> li)); toAdd .stream() .filter(li -> !availableMap.containsKey(li.getPluginableId())) .forEach(availableImporters::add); } PossibleLogImporters();  PossibleLogImporters(Optional<LogImporter> logImporter); List<LogImporter> getAvailableImporters(); void setAvailableImporters(List<LogImporter> availableImporters); Optional<LogImporter> getLogImporter(); void setLogImporter(Optional<LogImporter> logImporter); void addMissing(List<LogImporter> toAdd);  }
@Test public void testAddMissing() { final PossibleLogImporters possibleLogImporters = new PossibleLogImporters(); possibleLogImporters.getAvailableImporters().addAll(Arrays.asList( new Log4jXmlLogImporter() )); final List<LogImporter> toAdd = Arrays.asList( new Log4jXmlLogImporter(), new LogImporterUsingParser(new Log4j2JsonLogParser()) ); possibleLogImporters.addMissing(toAdd); assertEquals(possibleLogImporters.getAvailableImporters().size(),2); }