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:org.apache.brooklyn.launcher.BrooklynLauncherRebindCatalogTest.java

private static <T> boolean compareIterablesWithoutOrderMatters(Iterable<T> a, Iterable<T> b) {
    List<T> aList = IteratorUtils.toList(a.iterator());
    List<T> bList = IteratorUtils.toList(b.iterator());

    return aList.containsAll(bList) && bList.containsAll(aList);
}

From source file:org.gatherdata.data.core.model.impl.FlatFormSupport.java

public static boolean deepEquals(FlatForm lhs, FlatForm rhs) {
    boolean areEqual = true;

    if (lhs != rhs) { // don't bother comparing object to itself
        areEqual = UniqueEntitySupport.deepEquals(lhs, rhs);

        if (areEqual) { // check namespace
            areEqual = new EqualsBuilder().append(lhs.getNamespace(), rhs.getNamespace()).isEquals();

            if (areEqual) { // check RenderedValues
                List<? extends RenderedValue> lhsValues = lhs.getValues();
                List<? extends RenderedValue> rhsValues = rhs.getValues();
                if (lhsValues != null) {
                    if (rhsValues != null) {
                        areEqual = lhsValues.containsAll(rhsValues);
                        if (areEqual) {
                            areEqual = rhsValues.containsAll(lhsValues);
                        }// w  w w .  jav  a2 s. c  om

                    } else {
                        areEqual = false;
                    }
                } else {
                    areEqual = (rhsValues == null);
                }

            }
        }
    }

    return areEqual;
}

From source file:IntrospectionUtil.java

public static boolean isSameSignature(Method methodA, Method methodB) {
    if (methodA == null)
        return false;
    if (methodB == null)
        return false;

    List parameterTypesA = Arrays.asList(methodA.getParameterTypes());
    List parameterTypesB = Arrays.asList(methodB.getParameterTypes());

    if (methodA.getName().equals(methodB.getName()) && parameterTypesA.containsAll(parameterTypesB))
        return true;

    return false;
}

From source file:com.google.u2f.server.data.SecurityKeyData.java

/**
 * Compares the two Lists of Transports and says if they are equal.
 *
 * @param transports1 first List of Transports
 * @param transports2 second List of Transports
 * @return true if both lists are null or if both lists contain the same transport values
 *///from   w  ww  . j  av  a 2  s . c o  m
public static boolean containSameTransports(List<Transports> transports1, List<Transports> transports2) {
    if (transports1 == null && transports2 == null) {
        return true;
    } else if (transports1 == null || transports2 == null) {
        return false;
    }
    return transports1.containsAll(transports2) && transports2.containsAll(transports1);
}

From source file:org.jboss.tools.ws.ui.bot.test.websocket.StubMethodsHelper.java

/**
 * Stub proposal should be in current proposals if and only if
 * collection shouldBe contains it.// w  ww  .  j ava2 s.c om
 *
 * @param editor   
 * @param shouldBe
 */
static void assertThereAreOnlySpecifiedStubProposals(TextEditor editor, Collection<String> shouldBe) {

    //Preparing collections
    List<String> proposals = new ArrayList<>(EXPECTED_PROPOSALS);
    proposals.removeAll(shouldBe);
    List<String> shouldNotBe = proposals;

    ContentAssistant contentAssistant = openContentAssistant(editor);
    List<String> actualProposals = contentAssistant.getProposals();
    contentAssistant.close();

    //check
    assertTrue("There are not all expected proposals!", actualProposals.containsAll(shouldBe));
    assertTrue("There are proposals those should not be there!",
            Collections.disjoint(actualProposals, shouldNotBe));
}

From source file:org.codehaus.groovy.grails.plugins.springsecurity.AuthorizeTools.java

/**
 * Check if the current user has all of the specified roles.
 * @param roles  a comma-delimited list of role names
 * @return <code>true</code> if the user is authenticated and has all the roles
 *//*from w w w  . jav a2 s.  com*/
public static boolean ifAllGranted(final String roles) {
    List<GrantedAuthority> granted = getPrincipalAuthorities();
    return granted.containsAll(parseAuthoritiesString(roles));
}

From source file:org.spring.data.gemfire.cache.RepositoryQueriesTest.java

protected static void assertQueryResults(final Iterable<User> actualUsers, final String... expectedUsernames) {
    assertNotNull("The query did not return any results!", actualUsers);

    List<String> actualUsernames = new ArrayList<>(expectedUsernames.length);

    for (User actualUser : actualUsers) {
        actualUsernames.add(actualUser.getUsername());
    }//from  www.ja v a2s .  c  o m

    assertEquals(expectedUsernames.length, actualUsernames.size());
    assertTrue(actualUsernames.containsAll(Arrays.asList(expectedUsernames)));
}

From source file:eu.earthobservatory.testsuite.utils.Utils.java

public static void testQuery(String queryFile, String resultsFile, boolean orderOn)
        throws IOException, MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException,
        URISyntaxException, QueryResultParseException, UnsupportedQueryResultFormatException {
    ByteArrayOutputStream resultsStream = new ByteArrayOutputStream();
    String query = FileUtils.readFileToString(new File(Utils.class.getResource(prefixesFile).toURI())) + "\n"
            + FileUtils.readFileToString(new File(Utils.class.getResource(queryFile).toURI()));

    //Pose the query
    strabon.query(query, Format.XML, strabon.getSailRepoConnection(), resultsStream);

    //Check if the results of the query are the expected
    TupleQueryResult expectedResults = QueryResultIO.parse(Utils.class.getResourceAsStream(resultsFile),
            TupleQueryResultFormat.SPARQL);
    TupleQueryResult actualResults = QueryResultIO
            .parse((new ByteArrayInputStream(resultsStream.toByteArray())), TupleQueryResultFormat.SPARQL);

    List<String> eBindingNames = expectedResults.getBindingNames();
    List<String> aBindingNames = actualResults.getBindingNames();
    assertTrue("Results are not the expected. QueryFile: " + queryFile,
            aBindingNames.containsAll(aBindingNames) && eBindingNames.containsAll(aBindingNames));

    //Sort each binding's values
    List<String> eBindingList = new ArrayList<String>();
    List<String> aBindingList = new ArrayList<String>();

    while (expectedResults.hasNext() && actualResults.hasNext()) {
        BindingSet eBinding = expectedResults.next();
        BindingSet aBinding = actualResults.next();

        String eBindingValues = "";
        String aBindingValues = "";
        for (String bindingName : eBindingNames) {
            eBindingValues += eBinding.getValue(bindingName).stringValue();
            aBindingValues += aBinding.getValue(bindingName).stringValue();
        }//from  w  ww  .j a v a  2  s . com

        eBindingList.add(eBindingValues);
        aBindingList.add(aBindingValues);
    }

    assertFalse("Results are not the expected. QueryFile: " + queryFile,
            expectedResults.hasNext() || actualResults.hasNext());

    if (!orderOn) {
        //Sort bindings alphabetically
        Collections.sort(eBindingList);
        Collections.sort(aBindingList);
    }
    //Check bindings one by one
    Iterator<String> eBindingListIterator = eBindingList.iterator();
    Iterator<String> aBindingListIterator = aBindingList.iterator();

    while (eBindingListIterator.hasNext() && aBindingListIterator.hasNext()) {
        assertEquals("Results are not the expected. QueryFile: " + queryFile, eBindingListIterator.next(),
                aBindingListIterator.next());
    }

    actualResults.close();
    expectedResults.close();
}

From source file:it.eng.spagobi.engines.worksheet.bo.WorkSheetDefinition.java

public static Map<String, List<String>> mergeDomainValuesFilters(List<Attribute> globalFilters,
        List<Attribute> sheetFilters) throws WrongConfigurationForFiltersOnDomainValuesException {
    Iterator<Attribute> globalFiltersIt = globalFilters.iterator();
    Map<String, List<String>> toReturn = new HashMap<String, List<String>>();
    while (globalFiltersIt.hasNext()) {
        Attribute aGlobalFilter = globalFiltersIt.next();
        if (sheetFilters.contains(aGlobalFilter)) { // the filter is defined globally and also on sheets
            // wins the more restrictive filter
            int index = sheetFilters.indexOf(aGlobalFilter);
            Attribute sheetsFilter = sheetFilters.get(index);
            List<String> aGlobalFilterValues = aGlobalFilter.getValuesAsList();
            List<String> sheetsFilterValues = sheetsFilter.getValuesAsList();
            if (aGlobalFilterValues.containsAll(sheetsFilterValues)) {
                // the sheets filters are less or equal to the global filters (this should always happen)
                toReturn.put(aGlobalFilter.getEntityId(), sheetsFilterValues);
            } else {
                logger.error("The global filter on field " + aGlobalFilter.getAlias()
                        + " is overridden by the sheet.");
                throw new WrongConfigurationForFiltersOnDomainValuesException(
                        "The global filter on field " + aGlobalFilter.getAlias()
                                + " is overridden by the sheet. Please expand the global filter's values.");
            }//www.  j ava  2 s  .  c om
        } else {
            toReturn.put(aGlobalFilter.getEntityId(), aGlobalFilter.getValuesAsList());
        }
    }
    Iterator<Attribute> sheetFiltersIt = sheetFilters.iterator();
    while (sheetFiltersIt.hasNext()) {
        Attribute aSheetsFilter = sheetFiltersIt.next();
        if (toReturn.containsKey(aSheetsFilter.getEntityId())) {
            // conflict already solved
            continue;
        }
        toReturn.put(aSheetsFilter.getEntityId(), aSheetsFilter.getValuesAsList());
    }
    return toReturn;
}

From source file:nl.surfnet.coin.selfservice.filter.SpringSecurityUtil.java

protected static void assertRoleIsGranted(CoinAuthority.Authority... expectedAuthorities) {
    CoinUser user = SpringSecurity.getCurrentUser();
    List<CoinAuthority.Authority> actualAuthorities = user.getAuthorityEnums();
    assertEquals(//from w w w.jav a2s  . c  o  m
            "expected roles: " + Arrays.asList(expectedAuthorities) + ", actual roles: " + actualAuthorities,
            expectedAuthorities.length, actualAuthorities.size());
    assertTrue("expected roles: " + Arrays.asList(expectedAuthorities) + ", actual roles: " + actualAuthorities,
            actualAuthorities.containsAll(Arrays.asList(expectedAuthorities)));
}