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.searsia.engine.Resource.java

private boolean listEquals(List<?> a, List<?> b) {
    if (a == null && b == null)
        return true;
    if (a == null || b == null)
        return false;
    if (a.size() != b.size())
        return false;
    return a.containsAll(b);
}

From source file:opennlp.tools.fca.ConceptLattice.java

public int AddIntent(List<Integer> intent, LinkedHashSet<Integer> extent, int generator) {
    //System.out.println("add intent "+intent+extent+generator);
    int generator_tmp = GetMaximalConcept(intent, generator);
    generator = generator_tmp;//from   w  w w.j  a  v a2 s.  c o  m
    //System.out.println("   max gen "+generator);
    if (conceptList.get(generator).getIntent().equals(intent)) {
        conceptList.get(generator).addExtents(extent);
        AddExtentToAncestors(extent, generator);
        return generator;
    }
    Set<Integer> generatorParents = conceptList.get(generator).getParents();
    Set<Integer> newParents = new HashSet<Integer>();
    for (int candidate : generatorParents) {
        if (!intent.containsAll(conceptList.get(candidate).getIntent())) {
            List<Integer> intersection = ListUtils.intersection(intent, conceptList.get(candidate).getIntent());
            LinkedHashSet<Integer> new_extent = new LinkedHashSet<Integer>();
            new_extent.addAll(conceptList.get(candidate).extent);
            new_extent.addAll(extent);
            candidate = AddIntent(intersection, new_extent, candidate);
        }

        boolean addParents = true;
        Iterator<Integer> iterator = newParents.iterator();
        while (iterator.hasNext()) {
            Integer parent = iterator.next();
            if (conceptList.get(parent).getIntent().containsAll(conceptList.get(candidate).getIntent())) {
                addParents = false;
                break;
            } else {
                if (conceptList.get(candidate).getIntent().containsAll(conceptList.get(parent).getIntent())) {
                    iterator.remove();
                }
            }
        }
        if (addParents) {
            newParents.add(candidate);
        }
    }

    FormalConcept newConcept = new FormalConcept();
    newConcept.setIntent(intent);
    LinkedHashSet<Integer> new_extent = new LinkedHashSet<Integer>();
    new_extent.addAll(conceptList.get(generator).extent);
    new_extent.addAll(extent);
    newConcept.addExtents(new_extent);
    newConcept.setPosition(conceptList.size());
    conceptList.add(newConcept);
    conceptList.get(generator).getParents().add(newConcept.position);
    conceptList.get(newConcept.position).childs.add(generator);
    for (int newParent : newParents) {
        if (conceptList.get(generator).getParents().contains(newParent)) {
            conceptList.get(generator).getParents().remove(newParent);
            conceptList.get(newParent).childs.remove(generator);
        }
        conceptList.get(newConcept.position).getParents().add(newParent);
        conceptList.get(newParent).addExtents(new_extent);
        AddExtentToAncestors(new_extent, newParent);
        conceptList.get(newParent).childs.add(newConcept.position);
    }

    return newConcept.position;
}

From source file:hsa.awp.user.facade.DBUserFacadeTest.java

/**
 * Creates some special {@link User}s and checks if the inheritance is working correctly.
 *//* ww w  .  j  av  a 2 s. c  o m*/
@Test
public void testGetAllUsersMixed() {

    List<User> created = new ArrayList<User>();

    // create some special participants
    for (int i = 0; i < 45; i++) {
        if (i % 2 == 0) {
            // create Teacher
            SingleUser u = SingleUser.getInstance("userFacadeTest" + i);
            u = facade.saveSingleUser(u);
            created.add(u);
        } else {
            // create UserGroup
            Group g = Group.getInstance();
            g = facade.saveGroup(g);
            created.add(g);
        }
    }

    List<User> found = facade.getAllUsers();
    assertEquals(created.size(), found.size());
    assertTrue(found.containsAll(created));
}

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

@Test
@SuppressWarnings("unchecked")
public void testGetWithBinaryDescription() throws RepositoryException, IOException {

    final NonRdfSourceDescription mockResource = (NonRdfSourceDescription) setResource(
            NonRdfSourceDescription.class);
    when(mockResource.getDescribedResource()).thenReturn(mockBinary);
    when(mockBinary.getTriples(eq(idTranslator), any(TripleCategory.class)))
            .thenReturn(new DefaultRdfStream(createURI("mockBinary")));
    when(mockBinary.getTriples(eq(idTranslator), any(EnumSet.class))).thenReturn(new DefaultRdfStream(
            createURI("mockBinary"),
            of(new Triple(createURI("mockBinary"), createURI("called"), createURI("child:properties")))));
    final Response actual = testObj.getResource(null);
    assertEquals(OK.getStatusCode(), actual.getStatus());
    assertTrue("Should be an LDP RDFSource",
            mockResponse.getHeaders("Link").contains("<" + LDP_NAMESPACE + "RDFSource>;rel=\"type\""));
    assertFalse("Should not advertise Accept-Post flavors", mockResponse.containsHeader("Accept-Post"));
    assertTrue("Should advertise Accept-Patch flavors", mockResponse.containsHeader("Accept-Patch"));
    assertTrue("Should contain a link to the binary", mockResponse.getHeaders("Link")
            .contains("<" + idTranslator.toDomain(binaryPath) + ">; rel=\"describes\""));

    final Model model = ((RdfNamespacedStream) actual.getEntity()).stream.collect(toModel());
    final List<String> rdfNodes = transform(newArrayList(model.listObjects()), RDFNode::toString);
    log.info("Found RDF objects\n{}", rdfNodes);
    assertTrue("Expected RDF contexts missing", rdfNodes
            .containsAll(ImmutableSet.of("LDP_CONTAINMENT", "LDP_MEMBERSHIP", "PROPERTIES", "SERVER_MANAGED")));

}

From source file:org.wso2.carbon.event.publisher.core.internal.util.helper.EventPublisherConfigurationHelper.java

private static boolean validateToPropertyConfiguration(OMElement toElement, String eventAdapterType)
        throws EventPublisherConfigurationException {

    List<String> requiredProperties = new ArrayList<String>();
    List<String> propertiesInConfig = new ArrayList<String>();

    Iterator toElementPropertyIterator = toElement.getChildrenWithName(
            new QName(EventPublisherConstants.EF_CONF_NS, EventPublisherConstants.EF_ELE_PROPERTY));

    OutputEventAdapterService eventAdapterService = EventPublisherServiceValueHolder
            .getOutputEventAdapterService();
    OutputEventAdapterSchema adapterSchema = eventAdapterService.getOutputEventAdapterSchema(eventAdapterType);

    if (adapterSchema == null) {
        throw new EventPublisherValidationException(
                "Event Adapter with type: " + eventAdapterType + " does not exist", eventAdapterType);
    }/*from w w  w  .j  av a 2s.  c om*/

    List<Property> propertyList = new ArrayList<Property>();
    if (adapterSchema.getDynamicPropertyList() != null) {
        propertyList.addAll(adapterSchema.getDynamicPropertyList());
    }
    if (adapterSchema.getDynamicPropertyList() != null) {
        propertyList.addAll(adapterSchema.getDynamicPropertyList());
    }

    if (propertyList.size() > 0) {

        for (Property property : propertyList) {
            if (property.isRequired()) {
                requiredProperties.add(property.getPropertyName());
            }
        }

        while (toElementPropertyIterator.hasNext()) {
            OMElement toElementProperty = (OMElement) toElementPropertyIterator.next();
            String propertyName = toElementProperty
                    .getAttributeValue(new QName(EventPublisherConstants.EF_ATTR_NAME));
            propertiesInConfig.add(propertyName);
        }

        if (!propertiesInConfig.containsAll(requiredProperties)) {
            return false;
        }
    }

    return true;
}

From source file:org.squashtest.tm.service.internal.testcase.CustomTestCaseModificationServiceImpl.java

@Override
public boolean haveSamePerimeter(List<Long> testCaseIds) {
    if (testCaseIds.size() != 1) {

        Long first = testCaseIds.remove(0);
        List<Milestone> toCompare = testCaseDao.findById(first).getProject().getMilestones();

        for (Long testCaseId : testCaseIds) {
            List<Milestone> mil = testCaseDao.findById(testCaseId).getProject().getMilestones();

            if (mil.size() != toCompare.size() || !mil.containsAll(toCompare)) {
                return false;
            }/*from w w w.ja  va2s. c om*/
        }
    }

    return true;
}

From source file:hsa.awp.user.facade.DBUserFacadeTest.java

/**
 * Creates some {@link SingleUser}s and checks if all were found by the {@link UserFacade#getAllUsers()} method.
 */// ww w. ja  v a2 s .com
@Test
public void testGetAllUsers() {

    List<SingleUser> created = new ArrayList<SingleUser>();

    // create some Users
    for (int i = 0; i < 32; i++) {
        created.add(facade.saveSingleUser(SingleUser.getInstance("UserFacadeTest" + i)));
    }

    // find all Participants
    List<User> found = facade.getAllUsers();

    // check data
    assertEquals(created.size(), found.size());
    assertTrue(found.containsAll(created));
}

From source file:hsa.awp.user.facade.DBUserFacadeTest.java

/**
 * Creates and persists some {@link Group}s and checks if all {@link Group}s are found correctly.
 *//*from  w  w w .ja  va2  s  .  c o m*/
@Test
public void testGetAllGroups() {

    List<Group> created = new ArrayList<Group>();

    // create some UserGroups
    for (int i = 0; i < 9; i++) {
        created.add(facade.saveGroup(Group.getInstance()));
    }

    // find all created UserGroups
    List<Group> found = facade.getAllGroups();

    // check data
    assertEquals(created.size(), found.size());
    assertTrue(found.containsAll(created));
}

From source file:com.cloud.network.nicira.NiciraNvpApiTest.java

@Test
public void testFindSecurityProfileByUuid() throws NiciraNvpApiException, IOException {
    // Prepare//from w w  w .j  a va  2 s .  c  om
    method = mock(GetMethod.class);
    when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
    when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
    final NameValuePair[] queryString = new NameValuePair[] { new NameValuePair("uuid", UUID),
            new NameValuePair("fields", "*") };
    final List<NameValuePair> queryStringNvps = new ArrayList<>();
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            final NameValuePair[] arguments = (NameValuePair[]) invocation.getArguments()[0];
            queryStringNvps.addAll(Arrays.asList(arguments));
            return null;
        }
    }).when(method).setQueryString(any(NameValuePair[].class));

    // Execute
    final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);

    // Assert
    verify(method, times(1)).releaseConnection();
    assertTrue(queryStringNvps.containsAll(Arrays.asList(queryString)));
    assertEquals(queryString.length, queryStringNvps.size());
    assertEquals("Wrong Uuid in the newly created SecurityProfile", UUID,
            actualProfiles.getResults().get(0).getUuid());
    assertEquals("Wrong Uuid in the newly created SecurityProfile", HREF,
            actualProfiles.getResults().get(0).getHref());
    assertEquals("Wrong Schema in the newly created SecurityProfile", SCHEMA,
            actualProfiles.getResults().get(0).getSchema());
    assertEquals("Wrong Uuid in the newly created SecurityProfile", UUID2,
            actualProfiles.getResults().get(1).getUuid());
    assertEquals("Wrong Uuid in the newly created SecurityProfile", HREF2,
            actualProfiles.getResults().get(1).getHref());
    assertEquals("Wrong Schema in the newly created SecurityProfile", SCHEMA2,
            actualProfiles.getResults().get(1).getSchema());
    assertEquals("Wrong Schema in the newly created SecurityProfile", 2, actualProfiles.getResultCount());
    assertEquals("Wrong URI for SecurityProfile creation REST service", NiciraNvpApi.SEC_PROFILE_URI_PREFIX,
            uri);
    assertEquals("Wrong HTTP method for SecurityProfile creation REST service", NiciraNvpApi.GET_METHOD_TYPE,
            type);
}

From source file:hsa.awp.user.facade.DBUserFacadeTest.java

/**
 * Creates some {@link SingleUser}s and checks if all were found by the {@link UserFacade#getAllSingleUsers()} works correctly.
 *//*  www .  j  a  va2 s  .  c  om*/
@Test
public void testGetAllSingleUsers() {

    List<SingleUser> created = new ArrayList<SingleUser>();

    // create some Users
    for (int i = 0; i < 34; i++) {
        created.add(facade.saveSingleUser(SingleUser.getInstance("UserFacadeTest" + i)));
    }

    // find all Users
    List<SingleUser> found = facade.getAllSingleUsers();

    // check data
    assertEquals(created.size(), found.size());
    assertTrue(found.containsAll(created));
}