List of usage examples for java.util Set containsAll
boolean containsAll(Collection<?> c);
From source file:org.apache.olingo.client.core.edm.EdmClientImpl.java
@Override protected EdmFunction createUnboundFunction(final FullQualifiedName functionName, final List<String> parameterNames) { EdmFunction result = null;//from w ww .j a va 2 s . c o m final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace()); if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema) .getFunctions(functionName.getName()); boolean found = false; for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) { final Function function = itor.next(); if (!function.isBound()) { final Set<String> functionParamNames = new HashSet<String>(); for (CommonParameter param : function.getParameters()) { functionParamNames.add(param.getName()); } found = parameterNames == null ? functionParamNames.isEmpty() : functionParamNames.containsAll(parameterNames); result = EdmFunctionImpl.getInstance(this, functionName, function); } } } else { for (EntityContainer entityContainer : schema.getEntityContainers()) { @SuppressWarnings("unchecked") final List<FunctionImport> functionImports = (List<FunctionImport>) entityContainer .getFunctionImports(functionName.getName()); boolean found = false; for (final Iterator<FunctionImport> itor = functionImports.iterator(); itor.hasNext() && !found;) { final FunctionImport functionImport = itor.next(); if (FunctionImportUtils.canProxyFunction(functionImport) && !functionImport.isBindable()) { final Set<String> functionParamNames = new HashSet<String>(); for (CommonParameter param : functionImport.getParameters()) { functionParamNames.add(param.getName()); } found = parameterNames == null ? functionParamNames.isEmpty() : functionParamNames.containsAll(parameterNames); result = EdmFunctionProxy.getInstance(this, functionName, functionImport); } } } } return result; }
From source file:org.thingsboard.server.controller.BaseEntityViewControllerTest.java
@Test public void testTheCopyOfAttrsOutOfTSForTheView() throws Exception { Set<String> actualAttributesSet = getAttributesByKeys( "{\"caKey1\":\"value1\", \"caKey2\":true, \"caKey3\":42.0, \"caKey4\":73}"); Set<String> expectedActualAttributesSet = new HashSet<>( Arrays.asList("caKey1", "caKey2", "caKey3", "caKey4")); assertTrue(actualAttributesSet.containsAll(expectedActualAttributesSet)); List<Map<String, Object>> valueTelemetryOfDevices = doGetAsync( "/api/plugins/telemetry/DEVICE/" + testDevice.getId().getId().toString() + "/values/attributes?keys=" + String.join(",", actualAttributesSet), List.class); EntityView view = new EntityView(); view.setEntityId(testDevice.getId()); view.setTenantId(savedTenant.getId()); view.setName("Test entity view"); view.setType("default"); view.setKeys(telemetry);/* w ww .j a v a 2 s . c o m*/ view.setStartTimeMs((long) getValue(valueTelemetryOfDevices, "lastActivityTime") * 10); view.setEndTimeMs((long) getValue(valueTelemetryOfDevices, "lastActivityTime") / 10); EntityView savedView = doPost("/api/entityView", view, EntityView.class); Thread.sleep(1000); List<Map<String, Object>> values = doGetAsync( "/api/plugins/telemetry/ENTITY_VIEW/" + savedView.getId().getId().toString() + "/values/attributes?keys=" + String.join(",", actualAttributesSet), List.class); assertEquals(0, values.size()); }
From source file:podd.util.WebappInitialisationUtil.java
private boolean testSameOntology(OWLOntology curOntology, OWLClass concept, Set<OWLAxiom> axiomSet) { final Set<OWLAxiom> oldAxiomSet = new HashSet<OWLAxiom>(); oldAxiomSet.addAll(curOntology.getAxioms(concept)); oldAxiomSet.addAll(curOntology.getAnnotationAssertionAxioms(concept.getIRI())); final int oldCount = oldAxiomSet.size(); final int newCount = axiomSet.size(); return oldCount == newCount && oldAxiomSet.containsAll(axiomSet); }
From source file:org.apache.solr.cloud.TestConfigSetsAPI.java
@Test public void testList() throws Exception { final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString(); final SolrClient solrClient = getHttpSolrClient(baseUrl); SolrZkClient zkClient = new SolrZkClient(solrCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null); try {//from w w w . jav a 2 s.c om // test empty List list = new List(); ConfigSetAdminResponse.List response = list.process(solrClient); Collection<String> actualConfigSets = response.getConfigSets(); assertEquals(0, actualConfigSets.size()); // test multiple Set<String> configSets = new HashSet<String>(); for (int i = 0; i < 5; ++i) { String configSet = "configSet" + i; solrCluster.uploadConfigSet(configset("configset-2"), configSet); configSets.add(configSet); } response = list.process(solrClient); actualConfigSets = response.getConfigSets(); assertEquals(configSets.size(), actualConfigSets.size()); assertTrue(configSets.containsAll(actualConfigSets)); } finally { zkClient.close(); } solrClient.close(); }
From source file:org.apache.asterix.optimizer.rules.subplan.InlineAllNtsInSubplanVisitor.java
@Override public ILogicalOperator visitUnnestMapOperator(UnnestMapOperator op, Void arg) throws AlgebricksException { visitSingleInputOperator(op);//from ww w . j a v a2s.c o m Set<LogicalVariable> liveVars = new HashSet<>(); VariableUtilities.getLiveVariables(op, liveVars); if (!liveVars.containsAll(correlatedKeyVars)) { op.setPropagatesInput(true); } return op; }
From source file:org.apache.ranger.plugin.model.validation.RangerPolicyValidator.java
/** * Returns the subset of all hierarchies that are a superset of the policy's resources. * @param policyResources//from ww w.ja v a2 s .c o m * @param hierarchies * @return */ Set<List<RangerResourceDef>> filterHierarchies_hierarchyHasAllPolicyResources(Set<String> policyResources, Set<List<RangerResourceDef>> hierarchies, RangerServiceDefHelper defHelper) { // helper function skipping sanity checks of getting null arguments passed Set<List<RangerResourceDef>> result = new HashSet<List<RangerResourceDef>>(hierarchies.size()); for (List<RangerResourceDef> aHierarchy : hierarchies) { Set<String> hierarchyResources = defHelper.getAllResourceNames(aHierarchy); if (hierarchyResources.containsAll(policyResources)) { result.add(aHierarchy); } } return result; }
From source file:se.cambio.cds.controller.guide.SimpleGuideManager.java
public Collection<String> getGuideIdsStrict(ElementInstanceCollection elementInstancesCollection) { Set<String> guideIds = new HashSet<String>(); //Get all idElements Set<String> idElementsEHR = elementInstancesCollection.getElementIdsByIdDomain(Domains.EHR_ID); for (String idGuide : _elementInstanceCollectionByIdGuideMap.keySet()) { ElementInstanceCollection eic = _elementInstanceCollectionByIdGuideMap.get(idGuide); Set<String> idElementsEHRAux = new HashSet<String>(); idElementsEHRAux.addAll(eic.getElementIdsByIdDomain(Domains.EHR_ID)); idElementsEHRAux.addAll(eic.getElementIdsByIdDomain(ElementInstanceCollection.EMPTY_CODE)); if (idElementsEHR.containsAll(idElementsEHRAux)) { guideIds.add(idGuide);/*w w w .ja va 2s .c om*/ } } return guideIds; }
From source file:com.bmwcarit.barefoot.matcher.MatcherTest.java
@Test public void TestCandidates() throws JSONException { Matcher filter = new Matcher(map, router, cost, spatial); {/*from w ww .j a v a 2 s .co m*/ filter.setMaxRadius(100); Point sample = new Point(11.001, 48.001); Set<Tuple<MatcherCandidate, Double>> candidates = filter.candidates(new HashSet<MatcherCandidate>(), new MatcherSample(0, sample)); assertEquals(0, candidates.size()); } { double radius = 200; filter.setMaxRadius(radius); Point sample = new Point(11.001, 48.001); Set<Tuple<MatcherCandidate, Double>> candidates = filter.candidates(new HashSet<MatcherCandidate>(), new MatcherSample(0, sample)); Set<Long> refset = new HashSet<>(Arrays.asList(0L, 1L)); Set<Long> set = new HashSet<>(); for (Tuple<MatcherCandidate, Double> candidate : candidates) { assertTrue(refset.contains(candidate.one().point().edge().id())); assertCandidate(candidate, sample); set.add(candidate.one().point().edge().id()); } assertEquals(refset.size(), candidates.size()); assertTrue(set.containsAll(refset)); } { double radius = 200; filter.setMaxRadius(radius); Point sample = new Point(11.010, 48.000); Set<Tuple<MatcherCandidate, Double>> candidates = filter.candidates(new HashSet<MatcherCandidate>(), new MatcherSample(0, sample)); Set<Long> refset = new HashSet<>(Arrays.asList(0L, 3L)); Set<Long> set = new HashSet<>(); for (Tuple<MatcherCandidate, Double> candidate : candidates) { assertTrue(Long.toString(candidate.one().point().edge().id()), refset.contains(candidate.one().point().edge().id())); assertCandidate(candidate, sample); set.add(candidate.one().point().edge().id()); } assertEquals(refset.size(), candidates.size()); assertTrue(set.containsAll(refset)); } { double radius = 200; filter.setMaxRadius(radius); Point sample = new Point(11.011, 48.001); Set<Tuple<MatcherCandidate, Double>> candidates = filter.candidates(new HashSet<MatcherCandidate>(), new MatcherSample(0, sample)); Set<Long> refset = new HashSet<>(Arrays.asList(0L, 2L, 3L)); Set<Long> set = new HashSet<>(); for (Tuple<MatcherCandidate, Double> candidate : candidates) { assertTrue(Long.toString(candidate.one().point().edge().id()), refset.contains(candidate.one().point().edge().id())); assertCandidate(candidate, sample); set.add(candidate.one().point().edge().id()); } assertEquals(refset.size(), candidates.size()); assertTrue(set.containsAll(refset)); } { double radius = 300; filter.setMaxRadius(radius); Point sample = new Point(11.011, 48.001); Set<Tuple<MatcherCandidate, Double>> candidates = filter.candidates(new HashSet<MatcherCandidate>(), new MatcherSample(0, sample)); Set<Long> refset = new HashSet<>(Arrays.asList(0L, 2L, 3L, 8L)); Set<Long> set = new HashSet<>(); for (Tuple<MatcherCandidate, Double> candidate : candidates) { assertTrue(Long.toString(candidate.one().point().edge().id()), refset.contains(candidate.one().point().edge().id())); assertCandidate(candidate, sample); set.add(candidate.one().point().edge().id()); } assertEquals(refset.size(), candidates.size()); assertTrue(set.containsAll(refset)); } { double radius = 200; filter.setMaxRadius(radius); Point sample = new Point(11.019, 48.001); Set<Tuple<MatcherCandidate, Double>> candidates = filter.candidates(new HashSet<MatcherCandidate>(), new MatcherSample(0, sample)); Set<Long> refset = new HashSet<>(Arrays.asList(2L, 3L, 5L, 10L)); Set<Long> set = new HashSet<>(); for (Tuple<MatcherCandidate, Double> candidate : candidates) { assertTrue(Long.toString(candidate.one().point().edge().id()), refset.contains(candidate.one().point().edge().id())); assertCandidate(candidate, sample); set.add(candidate.one().point().edge().id()); } assertEquals(refset.size(), candidates.size()); assertTrue(set.containsAll(refset)); } }
From source file:edu.umass.cs.reconfiguration.AbstractReconfiguratorDB.java
private boolean differByOne(Set<NodeIDType> s1, Set<NodeIDType> s2) { return (s1.containsAll(s2) && (s1.size() == (s2.size() + 1))) || (s2.containsAll(s1) && (s2.size() == (s1.size() + 1))); }
From source file:alfio.manager.AdminReservationManager.java
@Transactional public void removeTickets(String eventName, String reservationId, List<Integer> ticketIds, List<Integer> toRefund, boolean notify, String username) { loadReservation(eventName, reservationId, username).ifSuccess((res) -> { Event e = res.getRight(); TicketReservation reservation = res.getLeft(); List<Ticket> tickets = res.getMiddle(); Map<Integer, Ticket> ticketsById = tickets.stream() .collect(Collectors.toMap(Ticket::getId, Function.identity())); Set<Integer> ticketIdsInReservation = tickets.stream().map(Ticket::getId).collect(toSet()); // ensure that all the tickets ids are present in tickets Assert.isTrue(ticketIdsInReservation.containsAll(ticketIds), "Some ticket ids are not contained in the reservation"); Assert.isTrue(ticketIdsInReservation.containsAll(toRefund), "Some ticket ids to refund are not contained in the reservation"); ////from ww w . j ava 2 s . c o m removeTicketsFromReservation(reservationId, e, ticketIds, notify, username, false); // handleTicketsRefund(toRefund, e, reservation, ticketsById, username); if (tickets.size() - ticketIds.size() <= 0) { markAsCancelled(reservation); additionalServiceItemRepository.updateItemsStatusWithReservationUUID(reservation.getId(), AdditionalServiceItem.AdditionalServiceItemStatus.CANCELLED); } }); }