Example usage for java.util TreeSet containsAll

List of usage examples for java.util TreeSet containsAll

Introduction

In this page you can find the example usage for java.util TreeSet 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:edu.ku.brc.specify.datamodel.WorkbenchTemplate.java

/**
 * @param template//ww  w .j a  va2s .  c  o  m
 * @return return if the template's mappings are a subset of this object's mappings
 */
public boolean containsAllMappings(WorkbenchTemplate template) {
    Comparator<WorkbenchTemplateMappingItem> comp = new Comparator<WorkbenchTemplateMappingItem>() {

        @Override
        public int compare(WorkbenchTemplateMappingItem arg0, WorkbenchTemplateMappingItem arg1) {
            int result = arg0.getTableName().compareTo(arg1.getTableName());
            if (result == 0) {
                result = arg0.getFieldName().compareTo(arg1.getFieldName());
            }
            return result;
        }

    };
    TreeSet<WorkbenchTemplateMappingItem> theseMaps = new TreeSet<WorkbenchTemplateMappingItem>(comp);
    //TreeSet<WorkbenchTemplateMappingItem> thoseMaps = new TreeSet<WorkbenchTemplateMappingItem>(comp);
    theseMaps.addAll(workbenchTemplateMappingItems);
    //thoseMaps.addAll(template.workbenchTemplateMappingItems);
    //return theseMaps.containsAll(thoseMaps);
    return theseMaps.containsAll(template.workbenchTemplateMappingItems);
}

From source file:org.apache.hadoop.hdfs.server.namenode.bookkeeper.metadata.TestBookKeeperJournalMetadataManager.java

@Test
public void testListLedgers() throws Exception {
    Set<EditLogLedgerMetadata> metadata = ImmutableSet.of(
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION, 1, 1, 100),
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION, 2, 101, 200),
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION, 3, 201, -1),
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION - 1, 4, 11, -1),
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION - 1, 5, 2, 10));
    for (EditLogLedgerMetadata e : metadata) {
        String fullLedgerPath = manager.fullyQualifiedPathForLedger(e);
        manager.writeEditLogLedgerMetadata(fullLedgerPath, e);
    }//from   w  w w .j ava  2 s. com
    Collection<EditLogLedgerMetadata> allLedgers = manager.listLedgers(true);
    assertTrue("listLedgers(true) returns all ledgers and all ledgers once",
            allLedgers.containsAll(metadata) && metadata.containsAll(allLedgers));

    EditLogLedgerMetadata prev = null;
    for (EditLogLedgerMetadata curr : allLedgers) {
        if (prev != null) {
            assertTrue("List must be ordered by firsTxId", prev.getFirstTxId() <= curr.getFirstTxId());
        }
        prev = curr;
    }

    Collection<EditLogLedgerMetadata> finalizedOnly = manager.listLedgers(false);
    for (EditLogLedgerMetadata e : finalizedOnly) {
        assertFalse("listLedgers(false) does not return in-progress ledgers" + e, e.getLastTxId() == -1);
    }
    TreeSet<EditLogLedgerMetadata> expectedFinalizedOnly = new TreeSet<EditLogLedgerMetadata>();
    for (EditLogLedgerMetadata e : allLedgers) {
        if (e.getLastTxId() != -1) {
            expectedFinalizedOnly.add(e);
        }
    }
    assertTrue("listLedgers(false) returns all finalized ledgers",
            finalizedOnly.containsAll(expectedFinalizedOnly)
                    && expectedFinalizedOnly.containsAll(finalizedOnly));
}

From source file:org.apache.solr.update.processor.UpdateIndexAuthorizationProcessorTest.java

/**
 * Ensure no new methods have been added to base class that are not invoking
 * Sentry//  w w  w. jav a 2s. c  o m
 */
@Test
public void testAllMethodsChecked() throws Exception {
    Method[] methods = UpdateRequestProcessor.class.getDeclaredMethods();
    TreeSet<String> foundNames = new TreeSet<String>();
    for (Method method : methods) {
        if (Modifier.isPublic(method.getModifiers())) {
            foundNames.add(method.getName());
        }
    }
    assertEquals(methodNames.size(), foundNames.size());
    assertTrue(foundNames.containsAll(methodNames));
}