Example usage for java.util List containsAll

List of usage examples for java.util List containsAll

Introduction

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

Prototype

boolean containsAll(Collection<?> c);

Source Link

Document

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

Usage

From source file:de.acosix.alfresco.site.hierarchy.repo.integration.ManagementViaWebScriptsTest.java

protected HierarchicSite checkHierarchySite(final WebTarget webTarget, final String ticket,
        final HierarchicSiteManagementRequest site, final String parentSite, final List<String> childSites,
        final String showInHierarchyMode, final String autoMembershipMode) {
    final HierarchicSite hierarchicSite = webTarget
            .path("/acosix/api/sites/" + URLEncoder.encode(site.getShortName()) + "/hierarchy")
            .queryParam("alf_ticket", ticket).request(MediaType.APPLICATION_JSON).get(HierarchicSite.class);

    if (parentSite == null) {
        Assert.assertNull("Site should not have a parent site", hierarchicSite.getParent());
    } else {//from   w w w . j a v a  2 s . com
        Assert.assertEquals("Parent site does not match", parentSite,
                hierarchicSite.getParent().getShortName());
    }

    if (childSites == null || childSites.isEmpty()) {
        Assert.assertTrue("Site should not have any children",
                hierarchicSite.getChildren() == null || hierarchicSite.getChildren().isEmpty());
    } else {
        Assert.assertTrue("Site should have children",
                hierarchicSite.getChildren() != null && !hierarchicSite.getChildren().isEmpty());
        Assert.assertEquals("Number of child sites does not match", childSites.size(),
                hierarchicSite.getChildren().size());

        final List<String> foundChildSites = new ArrayList<>();
        hierarchicSite.getChildren().forEach(childSite -> {
            foundChildSites.add(childSite.getShortName());
        });

        Assert.assertTrue("Site should have expected site(s) as children",
                foundChildSites.containsAll(childSites));
    }

    Assert.assertEquals("ShowInHierarchyMode does not match expectation",
            site.getAco6sh_showInHierarchyMode() != null ? site.getAco6sh_showInHierarchyMode()
                    : (showInHierarchyMode != null ? showInHierarchyMode
                            : SiteHierarchyModel.CONSTRAINT_SHOW_IN_HIERARCHY_MODES_NEVER),
            hierarchicSite.getShowInHierarchyMode());
    Assert.assertEquals("AutoMembershipMode does not match expectation",
            site.getAco6sh_autoMembershipMode() != null ? site.getAco6sh_autoMembershipMode()
                    : (autoMembershipMode != null ? autoMembershipMode
                            : SiteHierarchyModel.CONSTRAINT_AUTO_MEMBERSHIP_MODES_NONE),
            hierarchicSite.getAutoMembershipMode());

    return hierarchicSite;
}

From source file:org.omegat.core.spellchecker.DictionaryManager.java

/**
 * installs a remote dictionary by downloading the corresponding zip file
 * from the net and by installing the aff and dic file to the dictionary
 * directory./*from w w  w  .java2 s.  c  o m*/
 *
 * @param langCode
 *            : the language code (xx_YY)
 */
public void installRemoteDictionary(String langCode) throws MalformedURLException, IOException {
    String from = Preferences.getPreference(Preferences.SPELLCHECKER_DICTIONARY_URL) + "/" + langCode + ".zip";

    // Dirty hack for the French dictionary. Since it is named
    // fr_FR_1-3-2.zip, we remove the "_1-3-2" portion
    // [ 2138846 ] French dictionary cannot be downloaded and installed
    int pos = langCode.indexOf("_1-3-2", 0);
    if (pos != -1) {
        langCode = langCode.substring(0, pos);
    }
    List<String> expectedFiles = Arrays.asList(langCode + OConsts.SC_AFFIX_EXTENSION,
            langCode + OConsts.SC_DICTIONARY_EXTENSION);

    URL url = new URL(from);
    URLConnection conn = url.openConnection();
    conn.setConnectTimeout(TIMEOUT_MS);
    conn.setReadTimeout(TIMEOUT_MS);
    try (InputStream in = conn.getInputStream()) {
        List<String> extracted = StaticUtils.extractFromZip(in, dir, expectedFiles::contains);
        if (!expectedFiles.containsAll(extracted)) {
            throw new FileNotFoundException("Could not extract expected files from zip; expected: "
                    + expectedFiles + ", extracted: " + extracted);
        }
    } catch (IllegalArgumentException ex) {
        throw new FlakyDownloadException(ex);
    }
}

From source file:com.hortonworks.streamline.streams.actions.topology.service.TopologyTestRunner.java

private boolean equalsOutputRecords(Map<String, List<Map<String, Object>>> expectedOutputRecordsMap,
        Map<String, List<Map<String, Object>>> actualOutputRecordsMap) {
    if (expectedOutputRecordsMap.size() != actualOutputRecordsMap.size()) {
        return false;
    }/*  w w  w. ja va2 s  .  c  o  m*/

    for (Map.Entry<String, List<Map<String, Object>>> expectedEntry : expectedOutputRecordsMap.entrySet()) {
        String sinkName = expectedEntry.getKey();

        if (!actualOutputRecordsMap.containsKey(sinkName)) {
            return false;
        }

        List<Map<String, Object>> expectedRecords = expectedEntry.getValue();
        List<Map<String, Object>> actualRecords = actualOutputRecordsMap.get(sinkName);

        // both should be not null
        if (expectedRecords == null || actualRecords == null) {
            return false;
        } else if (expectedRecords.size() != actualRecords.size()) {
            return false;
        } else if (!expectedRecords.containsAll(actualRecords)) {
            return false;
        }
    }

    return true;
}

From source file:edu.scripps.fl.pubchem.promiscuity.PCPromiscuityFactory.java

private void checkIfActiveSummary(List<Long> xrefAIDs, List<Long> allAssayActive, Long summaryAID,
        List<Long> summaryActive, Map<Long, List<Protein>> aidProteinMap,
        Map<Long, List<Protein>> summaryProteinMap) {

    List<Long> activeXrefAIDs = (List<Long>) CollectionUtils.intersection(xrefAIDs, allAssayActive);
    if (activeXrefAIDs.size() > 0) {
        Boolean isActive = true;//from  w ww.  jav a 2 s . c om
        int ii = 0;
        List<Protein> summaryProteins = summaryProteinMap.get(summaryAID);

        while (isActive && ii < activeXrefAIDs.size()) {
            Long activeXrefAID = activeXrefAIDs.get(ii);
            List<Protein> xrefProteins = aidProteinMap.get(activeXrefAID);
            if (summaryProteins != null) {
                if (xrefProteins != null) {
                    if (!summaryProteins.containsAll(xrefProteins))
                        isActive = false;
                    else if (summaryProteins.size() > 0 && xrefProteins.size() == 0) {
                        isActive = false;
                    } else
                        ii = ii + 1;
                } else if (xrefProteins == null && summaryProteins.size() > 0)
                    isActive = false;
                else
                    ii = ii + 1;
            } else {
                if (xrefProteins != null && xrefProteins.size() > 0)
                    isActive = false;
                else
                    ii = ii + 1;
            }

        }

        if (isActive)
            summaryActive.add(summaryAID);
    }

}

From source file:org.alfresco.po.share.site.document.UserSearchPage.java

/**
 * Returns true if all the userNames are in the search results.
 *
 * @param searchText//from  w w w .  j  a  v a  2  s.c om
 * @param userNames
 * @return
 */
public boolean usersExistInSearchResults(String searchText, String... userNames) {
    boolean matchNames = false;
    List<UserSearchRow> results = searchUserAndGroup(searchText);
    List<String> resultNames = new ArrayList<>();

    for (UserSearchRow userSearchRow : results) {
        String name = userSearchRow.getUserName();

        name = name.substring(name.indexOf('(') + 1, name.indexOf(')'));

        if (name.startsWith("GROUP_")) {
            name = name.substring(6);
        }

        resultNames.add(name);
    }

    List<String> names = Arrays.asList(userNames);

    matchNames = resultNames.containsAll(names);

    return matchNames;
}

From source file:com.vmware.bdd.service.resmgmt.impl.ResourceService.java

@Override
public boolean isNetworkAccessibleByCluster(List<String> networkList,
        List<com.vmware.bdd.spectypes.VcCluster> clusters) {
    // refresh all resource when at beginning of creating/resizing/resuming cluster
    //      refreshNetwork();

    Set<String> portGroupNames = new HashSet<String>();
    for (String networkName : networkList) {
        VcNetwork vcNetwork = getNetworkByName(networkName);
        if (vcNetwork == null) {
            throw VcProviderException.NETWORK_NOT_FOUND(networkName);
        }//from ww w . j  ava2s . com
        portGroupNames.add(vcNetwork.getName());
    }

    for (com.vmware.bdd.spectypes.VcCluster cluster : clusters) {
        List<VcHost> hosts = getHostsByClusterName(cluster.getName());
        for (VcHost vcHost : hosts) {
            List<VcNetwork> vcNetworks = vcHost.getNetworks();
            List<String> hostNetworkNames = new ArrayList<String>();
            for (VcNetwork vcNetwork : vcNetworks) {
                hostNetworkNames.add(vcNetwork.getName());
            }
            if (hostNetworkNames.containsAll(portGroupNames)) {
                return true;
            }
        }
    }
    return false;
}

From source file:de.dhke.projects.cutil.collections.cow.CopyOnWriteMultiMapEntrySetTest.java

/**
 * Test of toArray method, of class CopyOnWriteMultiMapEntrySet.
 *///from  w w w  .  j a v a 2s  . c  o m
@Test
public void testToArray_0args() {
    List<Map.Entry<String, Collection<String>>> referenceList = new ArrayList<>();
    referenceList.add(new DefaultMapEntry<String, Collection<String>>("1", Arrays.asList("a", "A")));
    referenceList.add(new DefaultMapEntry<String, Collection<String>>("2", Arrays.asList("b", "B")));
    referenceList.add(new DefaultMapEntry<String, Collection<String>>("3", Arrays.asList("c", "C")));
    Object[] resultArray = _entrySet.toArray();
    assertEquals(3, resultArray.length);
    assertTrue(referenceList.containsAll(Arrays.asList(resultArray)));
}

From source file:org.apache.hadoop.hive.metastore.client.TestAppendPartitions.java

private void verifyPartitionNames(Table table, List<String> expectedPartNames) throws Exception {
    List<String> partitionNames = client.listPartitionNames(table.getDbName(), table.getTableName(),
            (short) -1);
    Assert.assertEquals(expectedPartNames.size(), partitionNames.size());
    Assert.assertTrue(partitionNames.containsAll(expectedPartNames));
}

From source file:com.vmware.bdd.service.resmgmt.impl.ResourceService.java

@Override
public List<String> filterHostsByNetwork(List<String> networkList,
        List<com.vmware.bdd.spectypes.VcCluster> clusters) {
    // refresh all resource when at beginning of creating/resizing/resuming cluster
    //refreshNetwork();
    Set<String> networkNames = new HashSet<String>();
    networkNames.addAll(networkList);/*from w  w w .  j  a v  a2  s . c  o  m*/
    Set<String> portGroupNames = new HashSet<String>();
    for (String networkName : networkNames) {
        VcNetwork vcNetwork = getNetworkByName(networkName);
        if (vcNetwork == null) {
            throw VcProviderException.NETWORK_NOT_FOUND(networkName);
        }
        portGroupNames.add(vcNetwork.getName());
    }

    List<String> noNetworkHosts = new ArrayList<String>();
    for (com.vmware.bdd.spectypes.VcCluster cluster : clusters) {
        List<VcHost> hosts = getHostsByClusterName(cluster.getName());
        for (VcHost vcHost : hosts) {
            // check each host has all the networks
            List<VcNetwork> vcNetworks = vcHost.getNetworks();
            List<String> hostNetworkNames = new ArrayList<String>();
            for (VcNetwork vcNetwork : vcNetworks) {
                hostNetworkNames.add(vcNetwork.getName());
            }
            if (!hostNetworkNames.containsAll(portGroupNames)) {
                logger.info("host" + vcHost.getName() + " has networks " + vcNetworks
                        + " does not have target network " + portGroupNames);
                noNetworkHosts.add(vcHost.getName());
            }
        }
    }
    return noNetworkHosts;
}

From source file:uk.ac.ebi.phenotype.service.MpathOntologyServiceTest.java

/**
 * Test of getSynonyms method, of class MpOntologyService.
 * //from  w  w  w.ja v a2  s  .c o m
 * @throws SQLException
 */
//@Ignore
@Test
public void testGetSynonyms3Synonyms() throws SQLException {
    System.out.println("testGetSynonyms3Synonyms");
    String[] expectedSynonymsArray = new String[] { "cornification", "hyperorthokeratosis",
            "hyperparakeratosis" };
    List<String> actualSynonyms = instance.getSynonyms("MPATH:154");

    List<String> expectedSynonyms = Arrays.asList(expectedSynonymsArray);

    String errMsg = "Expected at least 3 synonyms. Actual # synonyms = " + actualSynonyms.size() + ".";
    assertTrue(errMsg, actualSynonyms.size() >= 3);

    if (!actualSynonyms.containsAll(expectedSynonyms)) {
        fail("Expected synonyms " + expectedSynonyms + ". Actual synonyms = "
                + StringUtils.join(actualSynonyms, ", "));
    }
}