XMLParser { protected String operatingSystemSelector() { if (operatingSystems.size() == 0) { return ""; } StringBuilder operatingSystemsSelector = new StringBuilder(); operatingSystemsSelector.append("["); for (Iterator<OperatingSystem> iterator = operatingSystems.iterator(); iterator.hasNext(); ) { String operatingSystem = iterator.next().toString().toLowerCase(); operatingSystemsSelector.append("parent::").append(operatingSystem); if (iterator.hasNext()) { operatingSystemsSelector.append("|"); } } operatingSystemsSelector.append("]"); return operatingSystemsSelector.toString(); } XMLParser(InputStream repositoryMap, Set<OperatingSystem> operatingSystems, Map<String, String> driverVersions, boolean thirtyTwoBit, boolean sixtyFourBit); NodeList getAllNodesInScope();  }
@Test public void returnsNoOperatingSystemsByDefault() { Set<OperatingSystem> none = new HashSet<OperatingSystem>(); XMLParser parser = new XMLParser(null, none, null, false, false); assertThat(parser.operatingSystemSelector(), is(equalTo(""))); }
@Test public void returnsASingleOperatingSystemWhenAListWithOnEntryIsSupplied() { Set<OperatingSystem> one = new HashSet<OperatingSystem>(); one.add(WINDOWS); XMLParser parser = new XMLParser(null, one, null, false, false); assertThat(parser.operatingSystemSelector(), is(equalTo("[parent::windows]"))); }
@Test public void returnsACorrectlyFormattedStringWhenMultipleOperatingSystemsAreSupplied() { Set<OperatingSystem> two = new HashSet<OperatingSystem>(); two.add(WINDOWS); two.add(LINUX); XMLParser parser = new XMLParser(null, two, null, false, false); assertThat(parser.operatingSystemSelector(), isOneOf("[parent::windows|parent::linux]", "[parent::linux|parent::windows]") ); }