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:uk.ac.ebi.phenotype.service.MpOntologyServiceTest.java

/**
 * Test of getSynonyms method, of class MpOntologyService.
 * /*from ww w. j  av a 2  s .  c om*/
 * @throws SQLException
 */
//@Ignore
@Test
public void testGetSynonyms3Synonyms() throws SQLException {
    System.out.println("testGetSynonyms3Synonyms");
    List<String> actualSynonyms = instance.getSynonyms("MP:0001293");
    String[] expectedSynonymsArray = new String[] { "absence of eyes", "absent eyes", "eyeless" };

    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, ", "));
    }
}

From source file:com.alibaba.dubbo.util.KetamaNodeLocatorTest.java

@Test
public void testNodeArrays() {
    final int maxSize = 10;
    final List<String> nodes = generateRandomStrings(maxSize);
    final long start1 = System.currentTimeMillis();
    final KetamaNodeLocator locator = new KetamaNodeLocator(nodes);

    // Make sure the initialization doesn't take too long.
    assertTrue((System.currentTimeMillis() - start1) < 100);

    final List<String> keys = generateRandomStrings(5 + RandomUtils.nextInt(5));

    for (final String key : keys) {
        final String single = locator.getPrimary(key);
        final List<String> sublist = locator.getPriorityList(key, 5);
        final List<String> superlist = locator.getPriorityList(key, 15);

        // Don't go over max size.
        assertTrue(superlist.size() <= maxSize);
        assertTrue(sublist.size() <= 5);

        // The primary should be the same across all the sets.
        assertEquals(single, sublist.get(0));
        assertEquals(single, superlist.get(0));

        // Make sure the sublist and superlist agree.
        for (int jx = 0; jx < 5; jx++) {
            assertEquals(sublist.get(jx), superlist.get(jx));
        }/*from w  ww.  j a v a2  s. com*/

        // Should contain every node.
        assertTrue(superlist.containsAll(nodes));
        assertTrue(nodes.containsAll(superlist));

        // Ensure no duplicates in the lists.
        final Set<String> subset = new HashSet<String>(sublist);
        assertEquals(sublist.size(), subset.size());
        final Set<String> superset = new HashSet<String>(superlist);
        assertEquals(superlist.size(), superset.size());
    }
}

From source file:co.cask.cdap.gateway.handlers.metrics.MetricsHandlerTestRun.java

private void verifySearchResultWithTags(String url, List<Map<String, String>> expectedValues) throws Exception {
    HttpResponse response = doPost(url, null);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    String result = EntityUtils.toString(response.getEntity(), Charsets.UTF_8);
    List<Map<String, String>> reply = GSON.fromJson(result, new TypeToken<List<Map<String, String>>>() {
    }.getType());//from w ww .  j  a v a  2  s .  c o m
    Assert.assertTrue(reply.containsAll(expectedValues) && expectedValues.containsAll(reply));
}

From source file:org.fcrepo.http.api.FedoraLdpTest.java

@Test
public void testGetWithObject() throws Exception {
    setResource(Container.class);
    final Response actual = testObj.getResource(null);
    assertEquals(OK.getStatusCode(), actual.getStatus());
    assertTrue("Should advertise Accept-Post flavors", mockResponse.containsHeader("Accept-Post"));
    assertTrue("Should advertise Accept-Patch flavors", mockResponse.containsHeader("Accept-Patch"));

    final RdfNamespacedStream entity = (RdfNamespacedStream) actual.getEntity();
    final Model model = entity.stream.collect(toModel());

    final List<String> rdfNodes = transform(newArrayList(model.listObjects()), RDFNode::toString);
    assertTrue("Expected RDF contexts missing", rdfNodes
            .containsAll(ImmutableSet.of("LDP_CONTAINMENT", "LDP_MEMBERSHIP", "PROPERTIES", "SERVER_MANAGED")));
}

From source file:org.fcrepo.http.api.FedoraLdpTest.java

@Test
public void testGet() throws Exception {
    setResource(FedoraResource.class);
    final Response actual = testObj.getResource(null);
    assertEquals(OK.getStatusCode(), actual.getStatus());
    assertTrue("Should have a Link header", mockResponse.containsHeader("Link"));
    assertTrue("Should have an Allow header", mockResponse.containsHeader("Allow"));
    assertTrue("Should be an LDP Resource",
            mockResponse.getHeaders("Link").contains("<" + LDP_NAMESPACE + "Resource>;rel=\"type\""));

    final RdfNamespacedStream entity = (RdfNamespacedStream) actual.getEntity();
    final Model model = entity.stream.collect(toModel());
    final List<String> rdfNodes = transform(newArrayList(model.listObjects()), RDFNode::toString);

    assertTrue("Expected RDF contexts missing", rdfNodes
            .containsAll(ImmutableSet.of("LDP_CONTAINMENT", "LDP_MEMBERSHIP", "PROPERTIES", "SERVER_MANAGED")));
}

From source file:org.opentestsystem.delivery.testreg.persistence.criteria.verifiers.accommodation.AccommodationOptionsCodeVerifier.java

@Override
public List<FieldError> verify(final Accommodation accommodation) {
    /*/*from  www  .j a v  a 2  s. co m*/
     * we are verfiying 
     * 1)whether their are any duplicate codes in accommodation
      *      
      * 2)if multi-valued resource in accommodation has default value then other options are not compatible with that default value 
      *
     * 3) check the options user enter for each accesiblity resource some options may not be available based on subject and grade
      */
    List<FieldError> errors = new ArrayList<FieldError>();

    List<String> excludeHeaders = new ArrayList<String>();
    excludeHeaders.add("StudentIdentifier");
    excludeHeaders.add("StateAbbreviation");
    excludeHeaders.add("Subject");

    Student student = studentService.findByStudentIdAndStateAbbreviation(accommodation.getStudentId(),
            accommodation.getStateAbbreviation());
    HashMap<String, List<String>> accOptions = accommodationCacheService
            .getResourceOptionCodes(accommodation.getSubject(), student.getGrade());
    HashMap<String, List<String>> masterResourceOptionsCode = masterResourceService.getMasterResourceOptions();

    List<String> headerCodes = templateDownloadMap.get(FormatType.DESIGNATEDSUPPORTSANDACCOMMODATIONS);

    try {
        //colorCodes,AmericanSignLanguage,..
        for (String headerCode : headerCodes) {
            if (!excludeHeaders.contains(headerCode)) {
                String heaerProperty = getHeaderPropertyName(headerCode);
                Object value = PropertyUtils.getProperty(accommodation, heaerProperty);

                if (value != null) {

                    List<String> options = accOptions.get(headerCode);
                    AccommodationResourceType resourceType = masterResourceService.getResourceType(headerCode);
                    List<String> masterOptions = masterResourceOptionsCode.get(headerCode);
                    switch (resourceType) {
                    case MultiSelectResource:

                        List<String> loadedOptions = convertOptionsToList(value);
                        String defaultOptionValue = masterResourceService.getDefaultOption(headerCode);
                        if (value != null & value.toString().length() > 0
                                && !options.containsAll(loadedOptions)) {
                            addFieldError(errors, accommodation, headerCode, value.toString(), headerCode
                                    + " some of these options are not available for this combination of subject and grade");
                        }

                        if (loadedOptions != null && !masterOptions.containsAll(loadedOptions)) {
                            final String message = "Invalid value for " + headerCode + " accommodation ";
                            addFieldError(errors, accommodation, headerCode, value.toString(), message);
                        }

                        final Set<String> duplicates = findDuplicateCodes(loadedOptions);
                        if (!CollectionUtils.isEmpty(duplicates)) {
                            for (final String dupCodes : duplicates) {
                                final String message = "Duplicate code " + dupCodes + " in accommodation";
                                addFieldError(errors, accommodation, headerCode, dupCodes, message);
                            }
                        }

                        if (loadedOptions != null && loadedOptions.contains(defaultOptionValue)
                                && loadedOptions.size() > 0) {
                            final String message = " : Incompatible option combination with"
                                    + defaultOptionValue;
                            addFieldError(errors, accommodation, headerCode, value.toString(),
                                    headerCode + message);
                        }
                        break;
                    case EditResource:
                        //No Validation required.
                        break;
                    case SingleSelectResource:
                        if (value != null && value.toString().length() > 0 && !options.contains(value)
                                && masterOptions.contains(value)) {
                            addFieldError(errors, accommodation, headerCode, value.toString(), headerCode
                                    + " option is not available for this combination of subject and grade");
                        }

                        if (value != null && value.toString().length() > 0 && !masterOptions.contains(value)) {
                            final String message = "Invalid value for " + headerCode + " accommodation ";
                            addFieldError(errors, accommodation, headerCode, value.toString(), message);
                        }
                        break;
                    default:
                        //do nothing
                        break;
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return errors;
}

From source file:gov.nih.nci.ncicb.tcga.dcc.common.dao.ArchiveQueriesJDBCImplSlowTest.java

public void testGetMafArchives() {
    final List<Archive> archives = queries.getProtectedMafArchives();
    assertEquals(2, archives.size());/*from  w  w w.  ja  v a2 s.c om*/
    final List<String> expectedArchives = Arrays.asList("broad.mit.edu_BLCA.IlluminaGA_DNASeq.Level_2.0.0.0",
            "broad.mit.edu_BLCA.IlluminaGA_DNASeq.Level_2.0.1.0");
    final List<String> actualArchives = new ArrayList<String>();
    for (final Archive archive : archives) {
        actualArchives.add(archive.getArchiveName());
    }
    assertTrue(expectedArchives.containsAll(actualArchives));
}

From source file:com.rmn.qa.aws.VmManagerTest.java

@Test
// Test if multiple security groups can be passed when launching a node
public void testLaunchNodesMultipleSecurityGroups() throws NodesCouldNotBeStartedException {
    MockAmazonEc2Client client = new MockAmazonEc2Client(null);
    RunInstancesResult runInstancesResult = new RunInstancesResult();
    Reservation reservation = new Reservation();
    reservation.setInstances(Arrays.asList(new Instance()));
    runInstancesResult.setReservation(reservation);
    client.setRunInstances(runInstancesResult);
    Properties properties = new Properties();
    String region = "east", uuid = "uuid", browser = "chrome", os = null;
    Integer threadCount = 5, maxSessions = 5;
    MockManageVm manageEC2 = new MockManageVm(client, properties, region);
    String userData = "userData";
    String securityGroup = "securityGroup1,securityGroup2,securityGroup3", subnetId = "subnetId",
            keyName = "keyName", linuxImage = "linuxImage";
    String[] splitSecurityGroupdIds = securityGroup.split(",");
    List securityGroupIdsAryLst = new ArrayList();

    if (securityGroup != null) {
        for (int i = 0; i < splitSecurityGroupdIds.length; i++) {
            securityGroupIdsAryLst.add(splitSecurityGroupdIds[i]);
        }/*w  ww.  ja v  a  2 s.  c  om*/
    }
    properties.setProperty(region + "_security_group", securityGroup);
    properties.setProperty(region + "_subnet_id", subnetId);
    properties.setProperty(region + "_key_name", keyName);
    properties.setProperty(region + "_linux_node_ami", linuxImage);
    manageEC2.setUserData(userData);
    manageEC2.launchNodes(uuid, os, browser, null, threadCount, maxSessions);
    RunInstancesRequest request = client.getRunInstancesRequest();
    request.setSecurityGroupIds(securityGroupIdsAryLst);
    List<String> securityGroups = request.getSecurityGroupIds();
    List<String> expectedSecurityGroups = Arrays
            .asList("securityGroup1,securityGroup2,securityGroup3".split(","));
    Assert.assertTrue("Security groups should match all given security groups",
            securityGroups.containsAll(expectedSecurityGroups));

    List<String> invalidSecurityGroups = Arrays
            .asList("securityGroup1,securityGroup2,securityGroup7".split(","));
    Assert.assertFalse("Security groups should match only the set security groups",
            securityGroups.containsAll(invalidSecurityGroups));

    Assert.assertFalse("Security group should not be empty", request.getSecurityGroupIds().isEmpty());
    Assert.assertEquals("More than 1 security group should be set", 3, securityGroups.size());
}

From source file:org.openmrs.module.rwandasphstudyreports.api.db.hibernate.HibernateCDCReportsDAO.java

private boolean matchAlerts(String[] alertsToMatch, List<String> patientAlerts) {
    if (alertsToMatch != null && patientAlerts != null && alertsToMatch.length > 0
            && patientAlerts.size() > 0) {
        List<String> localizedSelectedAlerts = new ArrayList<String>();

        for (String a : alertsToMatch) {
            localizedSelectedAlerts// www.j  a v a 2 s .c o m
                    .add(Context.getMessageSourceService().getMessage("rwandasphstudyreports.alerts." + a));
        }
        if (!patientAlerts.containsAll(localizedSelectedAlerts))
            return false;
    }
    return true;
}

From source file:languageTools.analyzer.mas.MASValidator.java

@Override
public Void visitLaunchPolicy(LaunchPolicyContext ctx) {
    boolean problem = (ctx.exception != null);

    for (LaunchRuleContext rule : ctx.launchRule()) {
        visitLaunchRule(rule);/*from   ww w. j a v a  2  s  .  c  o  m*/
    }

    // MAS program should have non-empty set of launch rules now; otherwise,
    // issue warning
    if (!problem && getProgram().getLaunchRules().isEmpty()) {
        problem = reportWarning(MASWarning.LAUNCH_NO_RULES, ctx);
    }

    // Check that all agent files specified in agentfiles section have been
    // used
    List<File> filesUsed = new ArrayList<File>();
    for (LaunchRule rule : getProgram().getLaunchRules()) {
        for (Launch launch : rule.getInstructions()) {
            filesUsed.add(launch.getAgentFile());
        }
    }
    if (!problem && !filesUsed.containsAll(getProgram().getAgentFiles())) {
        reportWarning(MASWarning.AGENTFILE_UNUSED, ctx);
    }

    // When environment is specified, launchpolicy section should have
    // conditional rules to connect agents to it
    if (!problem && getProgram().hasEnvironment()) {
        boolean crule = false;
        for (LaunchRule rule : getProgram().getLaunchRules()) {
            crule |= rule.getConditional();
        }
        if (!crule) {
            reportWarning(MASWarning.LAUNCH_NO_CONDITIONAL_RULES, ctx);
        }
    }

    return null; // Java says must return something even when Void
}