List of usage examples for java.util Set containsAll
boolean containsAll(Collection<?> c);
From source file:net.tbnr.gearz.command.NetCommandDispatch.java
/** * This will handle a command, and send calls to the respective NetCommand handlers. * * @param object The JSON Object that represents the command sent * @return If the NetCommand was handled. *//*from w ww.j a v a2 s . co m*/ public boolean handleCommand(JSONObject object) { String command; try { command = object.getString("command"); NetCommandHandler netCommandHandler = this.nameToAnnotationMap.get(command); if (netCommandHandler == null) { GearzBungee.getInstance().getLogger() .info("Unhandled command " + command + " " + object.toString()); return false; } JSONObject data = object.getJSONObject("data"); HashMap<String, Object> stringObjectHashMap = objectToHashMap(data); Set<String> strings = stringObjectHashMap.keySet(); if (!strings.containsAll(Arrays.asList(netCommandHandler.args()))) return false; RegisteredNetCommand registeredNetCommand = this.netCommands.get(netCommandHandler); registeredNetCommand.callHandlers(stringObjectHashMap); } catch (JSONException e) { e.printStackTrace(); return false; } return true; }
From source file:org.apache.ode.store.ProcessCleanupConfImpl.java
ProcessCleanupConfImpl(TDeployment.Process pinfo) { for (TCleanup cleanup : pinfo.getCleanupArray()) { if (cleanup.getOn() == TCleanup.On.SUCCESS || cleanup.getOn() == TCleanup.On.ALWAYS) { processACleanup(successCategories, Arrays.asList(cleanup.getCategoryArray())); }/*from w w w . j a va 2 s. c o m*/ if (cleanup.getOn() == TCleanup.On.FAILURE || cleanup.getOn() == TCleanup.On.ALWAYS) { processACleanup(failureCategories, Arrays.asList(cleanup.getCategoryArray())); } } // validate configurations Set<CLEANUP_CATEGORY> categories = getCleanupCategories(true); if (categories.contains(CLEANUP_CATEGORY.INSTANCE) && !categories.containsAll(EnumSet.of(CLEANUP_CATEGORY.CORRELATIONS, CLEANUP_CATEGORY.VARIABLES))) { throw new ContextException( "Cleanup configuration error: the instance category requires both the correlations and variables categories specified together!!!"); } categories = getCleanupCategories(false); if (categories.contains(CLEANUP_CATEGORY.INSTANCE) && !categories.containsAll(EnumSet.of(CLEANUP_CATEGORY.CORRELATIONS, CLEANUP_CATEGORY.VARIABLES))) { throw new ContextException( "Cleanup configuration error: the instance category requires both the correlations and variables categories specified together!!!"); } }
From source file:org.camelcookbook.splitjoin.aggregate.AggregateCompletionConditionSpringTest.java
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2);//from w ww.j a v a2 s .co m template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); List<Exchange> receivedExchanges = mockOut.getReceivedExchanges(); @SuppressWarnings("unchecked") Set<String> odd = Collections.checkedSet(receivedExchanges.get(0).getIn().getBody(Set.class), String.class); assertTrue(odd.containsAll(Arrays.asList("One", "Three", "Five", "Seven", "Nine"))); @SuppressWarnings("unchecked") Set<String> even = Collections.checkedSet(receivedExchanges.get(1).getIn().getBody(Set.class), String.class); assertTrue(even.containsAll(Arrays.asList("Two", "Four", "Six", "Eight", "Ten"))); }
From source file:com.cognifide.aet.job.common.datafilters.removelines.RemoveLinesDataModifier.java
private String modify(String data, Set<Integer> indexesToRemove) { List<String> lines = Arrays.asList(StringUtils.split(data, NEWLINE)); Set<Integer> dataIndexes = ContiguousSet.create(Range.closed(1, lines.size()), DiscreteDomain.integers()); if (!dataIndexes.containsAll(indexesToRemove)) { LOGGER.warn("Some of defined ranges exceed source lenght. Source length is: " + lines.size()); }//from w ww . j a v a 2s .c om Set<Integer> filtereedIndexesToRemove = Sets.intersection(dataIndexes, indexesToRemove); List<String> modifiedLines = new ArrayList<String>(lines.size() - filtereedIndexesToRemove.size()); for (int i = 0; i < lines.size(); i++) { if (!filtereedIndexesToRemove.contains(i + 1)) { modifiedLines.add(lines.get(i)); } } return StringUtils.join(modifiedLines, NEWLINE); }
From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannelCountryGHZ5Test.java
@Test public void testChannelsChinaSouthKorea() throws Exception { final int expectedSize = CHANNELS_SET1.size() + CHANNELS_SET3.size(); List<String> countries = Arrays.asList("CN", "KR"); IterableUtils.forEach(countries, new Closure<String>() { @Override// w ww . ja v a 2s. com public void execute(String country) { Set<Integer> actual = fixture.findChannels(country); assertEquals(expectedSize, actual.size()); assertTrue(actual.containsAll(CHANNELS_SET1)); assertTrue(actual.containsAll(CHANNELS_SET3)); assertFalse(actual.containsAll(CHANNELS_SET2)); } }); }
From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannelCountryGHZ5Test.java
@Test public void testChannelsJapanTurkeySouthAfrica() throws Exception { final int expectedSize = CHANNELS_SET1.size() + CHANNELS_SET2.size(); List<String> countries = Arrays.asList("JP", "TR", "ZA"); IterableUtils.forEach(countries, new Closure<String>() { @Override// w ww. ja v a 2 s . co m public void execute(String country) { Set<Integer> actual = fixture.findChannels(country); assertEquals(expectedSize, actual.size()); assertTrue(actual.containsAll(CHANNELS_SET1)); assertTrue(actual.containsAll(CHANNELS_SET2)); assertFalse(actual.containsAll(CHANNELS_SET3)); } }); }
From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannelCountryGHZ5Test.java
@Test public void testChannelsOther() throws Exception { final int expectedSize = CHANNELS_SET1.size() + CHANNELS_SET2.size() + CHANNELS_SET3.size(); List<String> countries = Arrays.asList("US", "RU", "XYZ"); IterableUtils.forEach(countries, new Closure<String>() { @Override/*ww w . j ava 2s . c o m*/ public void execute(String country) { Set<Integer> actual = fixture.findChannels(country); assertEquals(expectedSize, actual.size()); assertTrue(actual.containsAll(CHANNELS_SET1)); assertTrue(actual.containsAll(CHANNELS_SET2)); assertTrue(actual.containsAll(CHANNELS_SET3)); } }); }
From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannelCountryGHZ5Test.java
@Test public void testChannelsAustraliaCanada() throws Exception { final SortedSet<Integer> exclude = new TreeSet<>(Arrays.asList(120, 124, 128)); final int expectedSize = CHANNELS_SET1.size() + CHANNELS_SET2.size() + CHANNELS_SET3.size() - exclude.size();//from www . j av a 2 s . c om List<String> countries = Arrays.asList("AU", "CA"); IterableUtils.forEach(countries, new Closure<String>() { @Override public void execute(String country) { Set<Integer> actual = fixture.findChannels(country); assertEquals(expectedSize, actual.size()); assertTrue(actual.containsAll(CHANNELS_SET1)); assertTrue(actual.containsAll(CHANNELS_SET3)); assertFalse(actual.containsAll(exclude)); } }); }
From source file:fi.vrk.xroad.catalog.persistence.MemberRepositoryTest.java
@Test public void testGetChangedSince() { LocalDateTime changedSince = testUtil.createDate(1, 1, 2017); Iterable<Member> members = memberRepository.findActiveChangedSince(changedSince); // members 3-7 have been changed since 1/1/2017, // 3-6 have different parts changed, #7 has all parts changed log.info("found changed members with ids: " + testUtil.getIds(members)); assertEquals(5, Iterables.size(members)); Set ids = testUtil.getIds(members); assertTrue(ids.containsAll(Arrays.asList(3L, 4L, 5L, 6L, 7L))); log.info("found members:"); for (Member member : members) { log(member);/* w w w . j a v a 2 s . c o m*/ } // verify that member #7 was fetched correctly with all the bits and pieces Optional optionalMember = testUtil.getEntity(members, 7L); assertTrue(optionalMember.isPresent()); Member member7 = (Member) optionalMember.get(); assertEquals(3, member7.getActiveSubsystems().size()); ArrayList<Service> allServices7 = new ArrayList<>(); for (Subsystem s : member7.getActiveSubsystems()) { allServices7.addAll(s.getAllServices()); } assertEquals(6, allServices7.size()); ArrayList<Wsdl> allWsdls7 = new ArrayList<>(); for (Service s : allServices7) { if (s.getWsdl() != null) { allWsdls7.add(s.getWsdl()); } } // test data: // member (7) -> subsystem (8) -> service (6) -> wsdl (4) // member (7) -> subsystem (8) -> service (8, removed) -> wsdl (6) // member (7) -> subsystem (8) -> service (9, removed) -> wsdl (7, removed) // member (7) -> subsystem (8) -> service (10) -> (-) // member (7) -> subsystem (9) -> service (7) -> wsdl (5) assertEquals(4, allWsdls7.size()); }
From source file:org.apache.vxquery.indexing.MetaFileUtilTest.java
/** * Validate the content of the file./*from www. j a va 2 s. c om*/ */ @Test public void step3_testValidateMetadataFile() { ConcurrentHashMap<String, XmlMetadata> fromFile = metaFileUtil.getMetadata(); Set<String> from = fromFile.keySet(); Set<String> initial = initialMap.keySet(); Assert.assertTrue(from.containsAll(initial)); for (String key : initial) { Assert.assertEquals(TestConstants.getXMLMetadataString(initialMap.get(key)), TestConstants.getXMLMetadataString(fromFile.get(key))); } }