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:com.tilab.fiware.metaware.service.DataSourceServiceTest.java

/**
 * Test of getDataSourcesList method, of class DataSourceService.
 *//*from  w  w w  .  j a  v  a  2s  . c  o  m*/
@Test
public void testGetDataSourcesList() {
    System.out.println("getDataSourcesList");
    DataSourceService instance = new DataSourceService();
    List<DataSource> expResult = new ArrayList<>();
    expResult.add(datas1);
    expResult.add(datas2);
    List<DataSource> result = instance.getDataSourcesList();
    assertTrue(expResult.containsAll(result) && result.containsAll(expResult));
}

From source file:org.finra.herd.dao.Ec2DaoTest.java

@Test
public void testAddSecurityGroupsToEc2Instance() {
    // Add the security groups to an EC2 instance.
    List<String> testSecurityGroups = Arrays.asList(EC2_SECURITY_GROUP_1, EC2_SECURITY_GROUP_2);
    List<String> resultSecurityGroups = ec2Dao.addSecurityGroupsToEc2Instance(EC2_INSTANCE_ID,
            testSecurityGroups, awsHelper.getAwsParamsDto());

    // Validate the results.
    assertNotNull(resultSecurityGroups);
    assertTrue(resultSecurityGroups.containsAll(testSecurityGroups));
}

From source file:org.phenotips.diagnosis.internal.DefaultDiagnosisServiceTest.java

@Test
public void returnsCorrectDiagnosis() throws ComponentLookupException, IOException, InterruptedException {
    String tempDir = System.getProperty("java.io.tmpdir");

    /** This test is prone to outdated ontologies. */
    List<List<String>> phenotypes = new LinkedList<>();
    List<List<String>> disorderIds = new LinkedList<>();
    phenotypes.add(Arrays.asList(new String[0]));
    disorderIds.add(Arrays.asList(new String[0]));
    phenotypes.add(/*from w  ww .ja  v  a2s. c o m*/
            Arrays.asList("HP:0000028", "HP:0000049", "HP:0000202", "HP:0000204", "HP:0000316", "HP:0001869"));
    disorderIds.add(Arrays.asList("MIM:100050"));
    phenotypes.add(Arrays.asList("HP:0000707", "HP:0001939", "HP:0003811"));
    disorderIds.add(Arrays.asList("MIM:306300"));
    phenotypes.add(Arrays.asList("HP:0001417", "HP:0001287"));
    disorderIds.add(Arrays.asList("MIM:308250"));
    /* Harder tests */
    phenotypes.add(Arrays.asList("HP:0001419", "HP:0001939", "HP:0001005"));
    disorderIds.add(Arrays.asList("MIM:308600"));
    phenotypes.add(Arrays.asList("HP:0011495", "HP:0000502", "HP:0001005", "HP:0000534"));
    disorderIds.add(Arrays.asList("MIM:308800"));
    /* An empty/invalid HPO term will fail to find a boqa index and should be handled correctly */
    phenotypes.add(Arrays.asList("HP:"));
    disorderIds.add(Arrays.asList(new String[0]));
    phenotypes.add(Arrays.asList("HP:0000028", "HP:0000049", "HP:", "HP:0000202", "HP:0000204", "HP:0000316",
            "HP:0001869"));
    disorderIds.add(Arrays.asList("MIM:100050"));

    int invalidPhenotypes = 2;

    VocabularyManager vocabulary = this.mocker.getInstance(VocabularyManager.class);
    Environment env = this.mocker.getInstance(Environment.class);
    Utils utils = this.mocker.getInstance(Utils.class);

    File tempMock = mock(File.class);
    doReturn(tempMock).when(env).getTemporaryDirectory();
    doReturn(tempDir).when(tempMock).getPath();

    Environment utilsEnv = this.workingUtils.getInstance(Environment.class);
    Utils workingUtilsComponent = this.workingUtils.getComponentUnderTest();
    String annotationPath = stream2file(BOQA.class.getClassLoader().getResourceAsStream("new_phenotype.gz"))
            .getPath();
    String vocabularyPath = stream2file(BOQA.class.getClassLoader().getResourceAsStream("hp.obo.gz")).getPath();

    File tempSpyObj = new File(tempDir);
    File tempSpy = spy(tempSpyObj);
    doReturn(tempSpy).when(utilsEnv).getTemporaryDirectory();
    workingUtilsComponent.loadDataFiles(vocabularyPath, annotationPath);

    doAnswer(new Answer<VocabularyTerm>() {
        @Override
        public VocabularyTerm answer(InvocationOnMock invocationOnMock) throws Throwable {
            String id = (String) invocationOnMock.getArguments()[0];
            VocabularyTerm term = mock(VocabularyTerm.class);
            doReturn(id).when(term).getId();
            doReturn("test").when(term).getName();
            return term;
        }
    }).when(vocabulary).resolveTerm(anyString());

    doReturn(tempSpy).when(env).getTemporaryDirectory();
    doReturn(workingUtilsComponent.getGraph()).when(utils).getGraph();
    doReturn(workingUtilsComponent.getDataAssociation()).when(utils).getDataAssociation();
    DiagnosisService diagnosisService = this.mocker.getComponentUnderTest();

    int limit = 3;
    int i = 0;
    List<String> nonstandardPhenotypeSet = new LinkedList<>();
    nonstandardPhenotypeSet.add("Non-standard term");
    for (List<String> phenotypeSet : phenotypes) {
        List<VocabularyTerm> diagnoses = diagnosisService.getDiagnosis(phenotypeSet, nonstandardPhenotypeSet,
                limit);
        List<String> diagnosisIds = new LinkedList<>();
        for (VocabularyTerm diagnosis : diagnoses) {
            diagnosisIds.add(diagnosis.getId());
        }
        assertTrue(diagnosisIds.containsAll(disorderIds.get(i)));
        i++;
    }
    verify(vocabulary, times(limit * (i - invalidPhenotypes))).resolveTerm(anyString());
}

From source file:android.support.transition.FragmentTransitionSupport.java

@Override
public void replaceTargets(Object transitionObj, ArrayList<View> oldTargets, ArrayList<View> newTargets) {
    Transition transition = (Transition) transitionObj;
    if (transition instanceof TransitionSet) {
        TransitionSet set = (TransitionSet) transition;
        int numTransitions = set.getTransitionCount();
        for (int i = 0; i < numTransitions; i++) {
            Transition child = set.getTransitionAt(i);
            replaceTargets(child, oldTargets, newTargets);
        }//from   w  w  w.  j  a  v  a  2  s.  c  o  m
    } else if (!hasSimpleTarget(transition)) {
        List<View> targets = transition.getTargets();
        if (targets.size() == oldTargets.size() && targets.containsAll(oldTargets)) {
            // We have an exact match. We must have added these earlier in addTargets
            final int targetCount = newTargets == null ? 0 : newTargets.size();
            for (int i = 0; i < targetCount; i++) {
                transition.addTarget(newTargets.get(i));
            }
            for (int i = oldTargets.size() - 1; i >= 0; i--) {
                transition.removeTarget(oldTargets.get(i));
            }
        }
    }
}

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

@Test
public void testShouldListAllVisibleHtmlFilesInDirectory() throws Exception {
    List<String> specFiles = createSpecificationFiles(root);
    createOtherFiles(root);/* w  w  w . ja  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:org.kuali.rice.krad.datadictionary.validation.constraint.DatePatternConstraint.java

/**
 * Returns a regex representing all the allowed formats in the system. If allowedFormats is
 * supplied, returns a regex representing only those formats.
 *
 * @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidDataPatternConstraint#getRegexString()
 *//*from w  w w . j a v  a2 s.com*/
@Override
protected String getRegexString() {
    List<String> dateFormatParams = loadFormats(CoreConstants.STRING_TO_DATE_FORMATS,
            CoreConstants.STRING_TO_DATE_FORMATS_DEFAULT);
    if (allowedFormats != null && !allowedFormats.isEmpty()) {
        if (dateFormatParams.containsAll(allowedFormats)) {
            dateFormatParams = allowedFormats;
        } else {
            //throw new Exception("Some of these formats do not exist in configured allowed date formats: " + allowedFormats.toString());
        }
    }

    String regex = "";
    int i = 0;
    for (String format : dateFormatParams) {
        if (i == 0) {
            regex = "(^" + convertDateFormatToRegex(format.trim()) + "$)";
        } else {
            regex = regex + "|(^" + convertDateFormatToRegex(format.trim()) + "$)";
        }
        i++;
    }
    return regex;
}

From source file:org.opentestsystem.authoring.testauth.service.impl.AssessmentServiceImpl.java

private boolean arraysOrderAgnosticEqual(final String[] leftArray, final String[] rightArray) {
    if (leftArray == null || rightArray == null || leftArray.length == 0 || rightArray.length == 0) {
        return false;
    }/*from ww  w .j ava2  s. c o m*/
    final List<String> leftList = Lists.newArrayList(leftArray);
    final List<String> rightList = Lists.newArrayList(rightArray);
    return leftList.containsAll(rightList) && rightList.containsAll(leftList);
}

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

@Test
public void testQueryNestedObjects() {
    userRepository.save(/*from   w  ww .j a va2 s.c o m*/
            createUserWithAddresses("jonDoe", createAddress("100 Main St.", "Portland", State.OREGON, "12345"),
                    createAddress("500 Walker Ave.", "Portland", State.MAINE, "12345"),
                    createAddress("200 Barnes Rd.", "Butte", State.MONTANA, "12345")));
    userRepository.save(createUserWithAddresses("janeDoe",
            createAddress("100 Main St.", "Portland", State.OREGON, "12345")));
    userRepository.save(createUserWithAddresses("pieDoe",
            createAddress("100 Main St.", "Portland", State.OREGON, "12345")));
    userRepository.save(createUserWithAddresses("cookieDoe",
            createAddress("100 Main St.", "Portland", State.OREGON, "12345")));
    userRepository.save(createUserWithAddresses("jackHandy",
            createAddress("1500 Washington Ave.", "New York", State.NEW_YORK, "12345")));
    userRepository.save(createUserWithAddresses("sandyHandy",
            createAddress("1500 Washington Ave.", "New York", State.NEW_YORK, "12345")));
    userRepository.save(createUserWithAddresses("imaPigg",
            createAddress("131 SE 13th St.", "Jackson", State.MISSISSIPPI, "12345")));
    userRepository.save(createUser("joeBlow"));
    //userRepository.save(createUserWithAddresses("joeBlow", createAddress("4141 NW 5th St.", "Los Angeles", State.CALIFORNIA, "12345")));

    assertEquals(8l, userRepository.count());

    List<User> results = userRepository.findUsersInCity("Portland");

    assertNotNull(results);
    assertFalse(results.isEmpty());
    //assertEquals(4, results.size());
    assertTrue(String.format("Expected [jonDoe, janeDoe, pieDoe, cookieDoe]; but was (%1$s)", results),
            results.containsAll(Arrays.asList(createUser("jonDoe"), createUser("janeDoe"), createUser("pieDoe"),
                    createUser("cookieDoe"))));
}

From source file:org.glite.slcs.group.Group.java

/**
 * Checks if the user, identified by his {@link Attribute}s, is member of
 * this group.//from w  ww  . j a  v  a2 s  .  com
 * 
 * @param userAttributes
 *            The user {@link Attribute}s
 * @return <code>true</code> if the user is member of the group.
 */
public boolean isMember(List userAttributes) {
    Iterator iterator = members_.iterator();
    while (iterator.hasNext()) {
        GroupMember member = (GroupMember) iterator.next();
        List memberAttributes = member.getAttributes();
        if (userAttributes.containsAll(memberAttributes)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Group " + name_ + " membership: " + memberAttributes);
            }
            return true;
        }
    }
    return false;
}

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

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

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