Example usage for java.util Set containsAll

List of usage examples for java.util Set containsAll

Introduction

In this page you can find the example usage for java.util Set containsAll.

Prototype

boolean containsAll(Collection<?> c);

Source Link

Document

Returns true if this set contains all of the elements of the specified collection.

Usage

From source file:org.apache.vxquery.indexing.MetaFileUtilTest.java

/**
 * Validate the updated metadata.// ww  w .ja va  2 s . co  m
 */
@Test
public void step6_testVerifyMetadataChange() {
    ConcurrentHashMap<String, XmlMetadata> fromFile = metaFileUtil.getMetadata();
    Set<String> from = fromFile.keySet();
    Set<String> modified = modifiedMap.keySet();

    Assert.assertTrue(from.containsAll(modified));

    for (String key : modified) {
        Assert.assertEquals(TestConstants.getXMLMetadataString(modifiedMap.get(key)),
                TestConstants.getXMLMetadataString(fromFile.get(key)));
    }
}

From source file:org.camelcookbook.splitjoin.aggregate.AggregateDynamicCompletionSizeSpringTest.java

@Test
public void testAggregation() throws InterruptedException {
    MockEndpoint mockOut = getMockEndpoint("mock:out");
    mockOut.setExpectedMessageCount(2);//w w w .ja va  2s. c o  m

    Map<String, Object> oddHeaders = new HashMap<String, Object>();
    oddHeaders.put("group", "odd");
    oddHeaders.put("batchSize", "5");

    Map<String, Object> evenHeaders = new HashMap<String, Object>();
    evenHeaders.put("group", "even");
    evenHeaders.put("batchSize", "4");

    template.sendBodyAndHeaders("direct:in", "One", oddHeaders);
    template.sendBodyAndHeaders("direct:in", "Two", evenHeaders);
    template.sendBodyAndHeaders("direct:in", "Three", oddHeaders);
    template.sendBodyAndHeaders("direct:in", "Four", evenHeaders);
    template.sendBodyAndHeaders("direct:in", "Five", oddHeaders);
    template.sendBodyAndHeaders("direct:in", "Six", evenHeaders);
    template.sendBodyAndHeaders("direct:in", "Seven", oddHeaders);
    template.sendBodyAndHeaders("direct:in", "Eight", evenHeaders);
    template.sendBodyAndHeaders("direct:in", "Nine", oddHeaders);

    assertMockEndpointsSatisfied();

    List<Exchange> receivedExchanges = mockOut.getReceivedExchanges();
    @SuppressWarnings("unchecked")
    Set<String> even = Collections.checkedSet(receivedExchanges.get(0).getIn().getBody(Set.class),
            String.class);
    assertTrue(even.containsAll(Arrays.asList("Two", "Four", "Six", "Eight")));

    @SuppressWarnings("unchecked")
    Set<String> odd = Collections.checkedSet(receivedExchanges.get(1).getIn().getBody(Set.class), String.class);
    assertTrue(odd.containsAll(Arrays.asList("One", "Three", "Five", "Seven", "Nine")));
}

From source file:info.novatec.testit.livingdoc.repository.FileSystemRepositoryTest.java

@Test
public void testShouldListAllVisibleHtmlFilesInDirectory() throws Exception {
    List<String> specFiles = createSpecificationFiles(root);
    createOtherFiles(root);/*from  www .j  a  v  a2  s . c  o  m*/
    Set<String> listing = new HashSet<String>(repository.listDocuments("/specs"));

    assertTrue(listing.containsAll(specFiles));
    assertTrue(specFiles.containsAll(listing));
}

From source file:org.camelcookbook.splitjoin.aggregatetimeouts.AggregateCompletionTimeoutSpringTest.java

@Test
public void testAggregation() throws InterruptedException {
    MockEndpoint mockOut = getMockEndpoint("mock:out");
    mockOut.setExpectedMessageCount(2);/*from   ww  w  .  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();

    for (Exchange exchange : mockOut.getReceivedExchanges()) {
        @SuppressWarnings("unchecked")
        Set<String> set = Collections.checkedSet(exchange.getIn().getBody(Set.class), String.class);
        if (set.contains("One")) { // odd
            assertTrue(set.containsAll(Arrays.asList("One", "Three", "Five", "Seven", "Nine")));
        } else { // even
            assertTrue(set.containsAll(Arrays.asList("Two", "Four", "Six", "Eight", "Ten")));
        }
    }
}

From source file:com.greenpepper.repository.FileSystemRepositoryTest.java

public void testShouldListAllVisibleHtmlFilesInDirectory() throws Exception {
    List<String> specFiles = createSpecificationFiles(root);
    createOtherFiles(root);//w  w w  .  j  a v a 2  s .c  o m
    Set<String> listing = new HashSet<String>(repository.listDocuments("/specs"));

    assertTrue(listing.containsAll(specFiles));
    assertTrue(specFiles.containsAll(listing));
}

From source file:biz.ganttproject.impex.csv.RecordGroup.java

boolean isHeader(CSVRecord record) {
    Set<String> thoseFields = Sets.newHashSet();
    for (Iterator<String> it = record.iterator(); it.hasNext();) {
        thoseFields.add(it.next());/*from  w  ww . j  a  v a 2s. c  o m*/
    }
    return thoseFields.containsAll(myMandatoryFields);
}

From source file:de.dal33t.powerfolder.util.collection.CompositeSet.java

/**
 * @see Set#equals//from  ww  w  . j ava2 s  .com
 */
public boolean equals(Object obj) {
    if (obj instanceof Set) {
        Set set = (Set) obj;
        if (set.containsAll(this) && set.size() == this.size()) {
            return true;
        }
    }
    return false;
}

From source file:com.cybernostics.jsp2thymeleaf.api.util.AlternateFormatStrings.java

public Optional<CandidateFormat> formatWhichUsesValues(Map<String, Object> attributeMap) {
    Set<String> availableValues = attributeMap.keySet();
    return candidateFormats.stream().filter((item) -> availableValues.containsAll(item.getRequiredAttributes()))
            .findFirst();/*from   w w w. j a  v  a2s.  c om*/
}

From source file:org.openmhealth.data.generator.Application.java

/**
 * @return true if the requests are valid, false otherwise
 *///w  w w . j  a v a 2 s.  c om
private boolean areMeasureGenerationRequestsValid() {

    List<MeasureGenerationRequest> requests = dataGenerationSettings.getMeasureGenerationRequests();
    Joiner joiner = Joiner.on(", ");

    for (int i = 0; i < requests.size(); i++) {
        MeasureGenerationRequest request = requests.get(i);

        Set<ConstraintViolation<MeasureGenerationRequest>> constraintViolations = validator.validate(request);

        if (!constraintViolations.isEmpty()) {
            log.error("The measure generation request with index {} is not valid.", i);
            log.error(request.toString());
            log.error(constraintViolations.toString());
            return false;
        }

        if (!dataPointGeneratorMap.containsKey(request.getGeneratorName())) {
            log.error("The data generator '{}' in request {} doesn't exist.", request.getGeneratorName(), i);
            log.error(request.toString());
            log.error("The allowed data generators are: {}", joiner.join(dataPointGeneratorMap.keySet()));
            return false;
        }

        DataPointGenerator<?> generator = dataPointGeneratorMap.get(request.getGeneratorName());

        Set<String> specifiedTrendKeys = request.getTrends().keySet();
        Set<String> requiredTrendKeys = generator.getRequiredValueGroupKeys();

        if (!specifiedTrendKeys.containsAll(requiredTrendKeys)) {
            log.error("Request {} for generator '{}' is missing required trend keys.", i, generator.getName());
            log.error("The generator requires the following missing keys: {}.",
                    joiner.join(Sets.difference(requiredTrendKeys, specifiedTrendKeys)));
            return false;
        }

        Set<String> supportedTrendKeys = generator.getSupportedValueGroupKeys();

        if (!supportedTrendKeys.containsAll(specifiedTrendKeys)) {
            log.warn("Request {} for generator '{}' specifies unsupported trend keys.", i, generator.getName());
            log.warn("The generator supports the following keys: {}.", joiner.join(supportedTrendKeys));
            log.warn("The following keys are being ignored: {}.",
                    joiner.join(Sets.difference(specifiedTrendKeys, supportedTrendKeys)));
        }
    }

    return true;
}

From source file:com.vrem.wifianalyzer.wifi.timegraph.DataManagerTest.java

@Test
public void testGetNewSeries() throws Exception {
    // setup/*ww  w . j  a  v a  2s  . c  om*/
    Set<WiFiDetail> wiFiDetails = new TreeSet<>(makeWiFiDetails());
    Set<WiFiDetail> moreWiFiDetails = new TreeSet<>(makeMoreWiFiDetails());
    when(timeGraphCache.active()).thenReturn(moreWiFiDetails);
    // execute
    Set<WiFiDetail> actual = fixture.getNewSeries(wiFiDetails);
    // validate
    assertTrue(actual.containsAll(wiFiDetails));
    assertTrue(actual.containsAll(moreWiFiDetails));
    verify(timeGraphCache).active();
}