List of usage examples for java.util Set containsAll
boolean containsAll(Collection<?> c);
From source file:org.apache.geode.internal.util.CollectionUtilsJUnitTest.java
@Test public void testAsSetWithNonUniqueElements() { final Integer[] numbers = { 0, 1, 2, 1, 0 }; final Set<Integer> numberSet = CollectionUtils.asSet(numbers); assertNotNull(numberSet);//from w ww.java 2s . c o m assertFalse(numberSet.isEmpty()); assertEquals(3, numberSet.size()); assertTrue(numberSet.containsAll(Arrays.asList(numbers))); }
From source file:org.georchestra.console.ws.backoffice.roles.RolesController.java
public void checkAuthorization(String delegatedAdmin, List<String> users, List<String> putRole, List<String> deleteRole) throws AccessDeniedException { // Verify authorization Set<String> usersUnderDelegation = this.advancedDelegationDao.findUsersUnderDelegation(delegatedAdmin); if (!usersUnderDelegation.containsAll(users)) throw new AccessDeniedException("Some users are not under delegation"); DelegationEntry delegation = this.delegationDao.findOne(delegatedAdmin); if (!Arrays.asList(delegation.getRoles()).containsAll(putRole)) throw new AccessDeniedException("Some roles are not under delegation (put)"); if (!Arrays.asList(delegation.getRoles()).containsAll(deleteRole)) throw new AccessDeniedException("Some roles are not under delegation (delete)"); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testServicesBoundOnFirstDeploy() throws Exception { CloudFoundryBootDashModel target = harness.createCfTarget(CfTestTargetParams.fromEnv()); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); List<String> bindServices = ImmutableList.of(services.createTestService(), services.createTestService()); ACondition.waitFor("services exist " + bindServices, 30_000, () -> { Set<String> services = client.getServices().stream().map(CFServiceInstance::getName) .collect(Collectors.toSet()); System.out.println("services = " + services); assertTrue(services.containsAll(bindServices)); });/*w w w . ja v a2 s . co m*/ final String appName = appHarness.randomAppName(); harness.answerDeploymentPrompt(ui, appName, appName, bindServices); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); new ACondition("wait for app '" + appName + "'to be RUNNING", APP_DEPLOY_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.RUNNING, element.getRunState()); return true; } }; Set<String> actualServices = client.getBoundServicesSet(appName).block(); assertEquals(ImmutableSet.copyOf(bindServices), actualServices); }
From source file:dk.netarkivet.harvester.indexserver.distribute.TestIndexRequestServer.java
/** * Method that handles generating an index; supposed to be run in its own thread, because it blocks while the index * is generated.// w ww. java 2 s . c om * * @param irMsg A message requesting an index * @see #visit(IndexRequestMessage) */ private void doGenerateIndex(final IndexRequestMessage irMsg) { final boolean mustReturnIndex = irMsg.mustReturnIndex(); try { checkMessage(irMsg); RequestType type = irMsg.getRequestType(); Set<Long> requestedJobIDs = irMsg.getRequestedJobs(); log.info("Generating an index of type '{}' for the jobs [{}]", type, StringUtils.conjoin(",", defaultIDs)); FileBasedCache<Set<Long>> handler = handlers.get(type); Set<Long> foundIDs = handler.cache(defaultIDs); if (!foundIDs.containsAll(defaultIDs)) { defaultIDs = foundIDs; } irMsg.setFoundJobs(requestedJobIDs); // Say that everything was found log.info("Returning default index"); File cacheFile = handler.getCacheFile(defaultIDs); if (mustReturnIndex) { // return index now! (default behaviour) if (cacheFile.isDirectory()) { // This cache uses multiple files stored in a directory, // so transfer them all. File[] cacheFiles = cacheFile.listFiles(); List<RemoteFile> resultFiles = new ArrayList<RemoteFile>(cacheFiles.length); for (File f : cacheFiles) { resultFiles.add(RemoteFileFactory.getCopyfileInstance(f)); } irMsg.setResultFiles(resultFiles); } else { irMsg.setResultFile(RemoteFileFactory.getCopyfileInstance(cacheFile)); } } } catch (Throwable t) { log.warn("Unable to generate index for jobs [{}]", StringUtils.conjoin(",", irMsg.getRequestedJobs()), t); irMsg.setNotOk(t); } finally { // Remove job from currentJobs Set synchronized (currentJobs) { currentJobs.remove(irMsg.getID()); } // delete stored message deleteStoredMessage(irMsg); String state = "failed"; if (irMsg.isOk()) { state = "successful"; } if (mustReturnIndex) { log.info("Sending {} reply for IndexRequestMessage back to sender '{}'.", state, irMsg.getReplyTo()); JMSConnectionFactory.getInstance().reply(irMsg); } else { log.info("Sending{} IndexReadyMessage to Scheduler", state); boolean isindexready = true; if (state.equalsIgnoreCase("failed")) { isindexready = false; } if (alwaysReturnFalseMode) { log.info("Setting isindexready = false in return message"); isindexready = false; } IndexReadyMessage irm = new IndexReadyMessage(irMsg.getHarvestId(), isindexready, irMsg.getReplyTo(), Channels.getTheIndexServer()); JMSConnectionFactory.getInstance().send(irm); } } }
From source file:org.apache.geode.internal.util.CollectionUtilsJUnitTest.java
@Test public void testAsSet() { final Integer[] numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; final Set<Integer> numberSet = CollectionUtils.asSet(numbers); assertNotNull(numberSet);/*from w w w . ja v a 2 s . com*/ assertFalse(numberSet.isEmpty()); assertEquals(numbers.length, numberSet.size()); assertTrue(numberSet.containsAll(Arrays.asList(numbers))); assertTrue(numberSet.remove(1)); assertEquals(numbers.length - 1, numberSet.size()); }
From source file:org.freebxml.omar.server.plugin.RequestInterceptorManager.java
private List getApplicablePlugins(ServerRequestContext context) throws RegistryException { List applicablePlugins = new ArrayList(); try {//w ww.j av a 2s. com if (getInterceptors().size() > 0) { String requestAction = bu.getActionFromRequest(context.getCurrentRegistryRequest()); //Get roles associated with user associated with this RequestContext Set subjectRoles = ServerCache.getInstance().getRoles(context); //Now get those RequestInterceptors whose roles are a proper subset of subjectRoles Iterator iter = getInterceptors().iterator(); while (iter.hasNext()) { RequestInterceptor interceptor = (RequestInterceptor) iter.next(); Set interceptorRoles = interceptor.getRoles(); Set interceptorActions = interceptor.getActions(); if ((subjectRoles.containsAll(interceptorRoles))) { applicablePlugins.add(interceptor); } } } } catch (JAXRException e) { throw new RegistryException(e); } return applicablePlugins; }
From source file:org.primeframework.mvc.test.RequestResult.java
/** * Verifies that the system contains the given message(s). The message(s) might be in the request, flash, session or * application scopes./*from ww w.j av a2s . co m*/ * * @param type The message type (ERROR, INFO, WARNING). * @param messages The fully rendered message(s) (not the code). * @return This. */ public RequestResult assertContainsMessages(MessageType type, String... messages) { Set<String> inMessageStore = new HashSet<>(); MessageStore messageStore = get(MessageStore.class); List<Message> msgs = messageStore.getGeneralMessages(); for (Message msg : msgs) { if (msg.getType() == type) { inMessageStore.add(msg.toString()); } } if (!inMessageStore.containsAll(asList(messages))) { throw new AssertionError( "The MessageStore does not contain the [" + type + "] message " + asList(messages) + ""); } return this; }
From source file:specminers.smartic.MergingBlock.java
public boolean pairIsUnifiable(Automaton<String> x, State<String> nodeX, Automaton<String> y, State<String> nodeY) { Set<List<Step<String>>> prefixesX = this.getPrefixes(x, nodeX); Set<List<Step<String>>> prefixesY = this.getPrefixes(y, nodeY); return prefixesX.containsAll(prefixesY) && prefixesY.containsAll(prefixesX); }
From source file:specminers.smartic.MergingBlock.java
public boolean pairIsMergeable(Automaton<String> x, State<String> nodeX, Automaton<String> y, State<String> nodeY) { Set<List<Step<String>>> suffixesX = this.getSuffixes(x, nodeX); Set<List<Step<String>>> suffixesY = this.getSuffixes(y, nodeY); return suffixesX.containsAll(suffixesY) && suffixesY.containsAll(suffixesX); }
From source file:org.apache.hadoop.hive.ql.lib.LevelOrderWalker.java
/** * starting point for walking.//from w w w. j a v a 2s . c o m * * @throws SemanticException */ @SuppressWarnings("unchecked") @Override public void startWalking(Collection<Node> startNodes, HashMap<Node, Object> nodeOutput) throws SemanticException { toWalk.addAll(startNodes); // Starting from the startNodes, add the children whose parents have been // included in the list. Set<Node> addedNodes = new HashSet<>(startNodes); int index = 0; while (index < toWalk.size()) { List<? extends Node> children = toWalk.get(index).getChildren(); if (CollectionUtils.isNotEmpty(children)) { for (Node child : children) { Operator<? extends OperatorDesc> childOP = (Operator<? extends OperatorDesc>) child; if (!addedNodes.contains(child) && (childOP.getParentOperators() == null || addedNodes.containsAll(childOP.getParentOperators()))) { toWalk.add(child); addedNodes.add(child); } } } ++index; } for (Node nd : toWalk) { if (!nodeTypes.isEmpty() && !nodeTypes.contains(nd.getClass())) { continue; } opStack.clear(); opStack.push(nd); walk(nd, 0, opStack); if (nodeOutput != null && getDispatchedList().contains(nd)) { nodeOutput.put(nd, retMap.get(nd)); } } }