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.nextdoor.bender.operation.conditional.ConditionalOperationTest.java

@Test
public void testTwoConditions() {
    List<Pair<FilterOperation, List<OperationProcessor>>> conditions = new ArrayList<Pair<FilterOperation, List<OperationProcessor>>>();
    /*/*  w w  w  . j a  v  a2  s . c om*/
     * Case 1
     */
    List<OperationProcessor> case1Ops = new ArrayList<OperationProcessor>();

    DummyAppendOperationFactory pos = new DummyAppendOperationFactory();
    DummyAppendOperationConfig posConf = new DummyAppendOperationConfig();
    posConf.setAppendStr("+");
    pos.setConf(posConf);
    case1Ops.add(new OperationProcessor(pos));
    FilterOperation case1Filter = new BasicFilterOperation(false);
    conditions.add(new ImmutablePair<FilterOperation, List<OperationProcessor>>(case1Filter, case1Ops));

    /*
     * Case 2
     */
    List<OperationProcessor> case2Ops = new ArrayList<OperationProcessor>();

    DummyAppendOperationFactory neg = new DummyAppendOperationFactory();
    DummyAppendOperationConfig negConf = new DummyAppendOperationConfig();
    negConf.setAppendStr("-");
    neg.setConf(negConf);
    case2Ops.add(new OperationProcessor(neg));
    FilterOperation case2Filter = new BasicFilterOperation(true);
    conditions.add(new ImmutablePair<FilterOperation, List<OperationProcessor>>(case2Filter, case2Ops));

    ConditionalOperation op = new ConditionalOperation(conditions, false);

    /*
     * Create thread that supplies input events
     */
    Queue<InternalEvent> inputQueue = new Queue<InternalEvent>();
    supply(2, inputQueue);

    /*
     * Process
     */
    Stream<InternalEvent> input = inputQueue.stream();
    Stream<InternalEvent> output = op.getOutputStream(input);

    List<String> actual = output.map(m -> {
        return m.getEventObj().getPayload().toString();
    }).collect(Collectors.toList());
    List<String> expected = Arrays.asList("0-", "1-");

    assertEquals(2, actual.size());
    assertTrue(expected.containsAll(actual));
}

From source file:cz.swi2.mendeluis.service.PortletServiceTest.java

@org.testng.annotations.Test
public void testGetAll() {
    Portlet portlet, portlet2;/*from w  w w.  j  a va 2 s  .co m*/
    try {
        // Create portlet
        portlet = this.portletService.createNewPortlet("name ABC2", "description", "/bin/script.sh");
        portlet2 = this.portletService.createNewPortlet("name ABC3", "description2", "/bin/script2.sh");

        // Find portlet
        List<Portlet> results = this.portletService.getAllPortlets();

        // assert equal
        List<Portlet> portlets = new ArrayList();
        portlets.add(portlet);
        portlets.add(portlet2);

        // We do not use a different db for testing. Thefore we must test only matching items, not all. 
        assertTrue(results.containsAll(portlets));

    } catch (UniqueViolationException ex) {
        Logger.getLogger(PortletServiceTest.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
}

From source file:cz.swi2.mendeluis.service.FavouriteItemServiceTest.java

/**
 * Get all test//from www.jav  a2  s  .c om
 */
@org.testng.annotations.Test
public void testGetAll() {
    FavouriteItem fav1, fav2;
    try {
        // Create FavouriteItem
        fav1 = this.favService.createNewFavouriteItem("TestA");
        fav2 = this.favService.createNewFavouriteItem("TestB");

        // Find FavouriteItem
        List<FavouriteItem> results = this.favService.getAllFavouriteItems();

        // assert equal
        List<FavouriteItem> favis = new ArrayList();
        favis.add(fav1);
        favis.add(fav2);

        // We do not use a different db for testing. Thefore we must test only matching items, not all. 
        assertTrue(results.containsAll(favis));

    } catch (UniqueViolationException ex) {
        Logger.getLogger(FavouriteItemServiceTest.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
}

From source file:edu.usc.goffish.gofs.itest.KryoSerializerIntegrationTest.java

protected void comparePartitionTemplates(IPartition expected, IPartition actual) {
    assertEquals(expected.getId(), actual.getId());
    assertEquals(expected.isDirected(), actual.isDirected());
    assertEquals(expected.size(), actual.size());

    for (ISubgraph expectedSubgraph : expected) {
        ISubgraph actualSubgraph = actual.getSubgraph(expectedSubgraph.getId());
        assertNotNull(actualSubgraph);/*from ww w  .ja  v a  2  s. c  o  m*/

        List<ITemplateVertex> expectedRemoteVertices = IterableUtils.toList(expectedSubgraph.remoteVertices());
        List<ITemplateVertex> actualRemoteVertices = IterableUtils.toList(actualSubgraph.remoteVertices());
        assertTrue(expectedRemoteVertices.containsAll(actualRemoteVertices));
        assertEquals(expectedRemoteVertices.size(), actualRemoteVertices.size());

        for (Property expectedProperty : expectedSubgraph.getVertexProperties()) {
            Property actualProperty = actualSubgraph.getVertexProperties()
                    .getProperty(expectedProperty.getName());
            assertNotNull(actualProperty);
            assertEquals(expectedProperty.isStatic(), actualProperty.isStatic());
            assertEquals(expectedProperty.getType(), actualProperty.getType());
            assertEquals(expectedProperty.getDefaults().size(), actualProperty.getDefaults().size());
            for (long id : expectedProperty.getDefaults().keySet()) {
                assertTrue(actualProperty.getDefaults().containsKey(id));
                assertEquals(expectedProperty.getDefaults().get(id), actualProperty.getDefaults().get(id));
            }
        }
        for (Property expectedProperty : expectedSubgraph.getEdgeProperties()) {
            Property actualProperty = actualSubgraph.getEdgeProperties()
                    .getProperty(expectedProperty.getName());
            assertNotNull(actualProperty);
            assertEquals(expectedProperty.isStatic(), actualProperty.isStatic());
            assertEquals(expectedProperty.getType(), actualProperty.getType());
            assertEquals(expectedProperty.getDefaults().size(), actualProperty.getDefaults().size());
            for (long id : expectedProperty.getDefaults().keySet()) {
                assertTrue(actualProperty.getDefaults().containsKey(id));
                assertEquals(expectedProperty.getDefaults().get(id), actualProperty.getDefaults().get(id));
            }
        }

        ISubgraphTemplate<? extends ITemplateVertex, ? extends ITemplateEdge> expectedTemplate = expectedSubgraph
                .getTemplate();
        ISubgraphTemplate<? extends ITemplateVertex, ? extends ITemplateEdge> actualTemplate = actualSubgraph
                .getTemplate();
        assertEquals(expectedTemplate.numVertices(), actualTemplate.numVertices());
        assertEquals(expectedTemplate.numEdges(), actualTemplate.numEdges());
        assertEquals(expectedTemplate.isDirected(), actualTemplate.isDirected());

        for (ITemplateVertex vertex : expectedTemplate.vertices()) {
            assertTrue(actualTemplate.containsVertex(vertex.getId()));
            assertEquals(expected.getSubgraphForVertex(vertex.getId()).getId(),
                    actual.getSubgraphForVertex(vertex.getId()).getId());
        }
        for (ITemplateEdge expectedEdge : expectedTemplate.edges()) {
            ITemplateVertex actualSource = actualTemplate.getVertex(expectedEdge.getSource().getId());
            ITemplateVertex actualSink = actualTemplate.getVertex(expectedEdge.getSink().getId());
            assertTrue(actualTemplate.containsEdge(expectedEdge.getId(), actualSource.getId(),
                    actualSink.getId()));
        }
    }
}

From source file:org.janusgraph.example.JanusGraphAppTest.java

@Test
public void createSchema() throws ConfigurationException {
    final JanusGraphApp app = new JanusGraphApp(CONF_FILE);
    final GraphTraversalSource g = app.openGraph();
    app.createSchema();//from  ww w . j av  a  2 s . co m
    final JanusGraph janusGraph = (JanusGraph) g.getGraph();
    final JanusGraphManagement management = janusGraph.openManagement();

    final List<String> vertexLabels = StreamSupport.stream(management.getVertexLabels().spliterator(), false)
            .map(Namifiable::name).collect(Collectors.toList());
    final List<String> expectedVertexLabels = Stream
            .of("titan", "location", "god", "demigod", "human", "monster").collect(Collectors.toList());
    assertTrue(vertexLabels.containsAll(expectedVertexLabels));

    final List<String> edgeLabels = StreamSupport
            .stream(management.getRelationTypes(EdgeLabel.class).spliterator(), false).map(Namifiable::name)
            .collect(Collectors.toList());
    final List<String> expectedEdgeLabels = Stream.of("father", "mother", "brother", "pet", "lives", "battled")
            .collect(Collectors.toList());
    assertTrue(edgeLabels.containsAll(expectedEdgeLabels));

    final EdgeLabel father = management.getEdgeLabel("father");
    assertTrue(father.isDirected());
    assertFalse(father.isUnidirected());
    assertEquals(Multiplicity.MANY2ONE, father.multiplicity());

    final List<String> propertyKeys = StreamSupport
            .stream(management.getRelationTypes(PropertyKey.class).spliterator(), false).map(Namifiable::name)
            .collect(Collectors.toList());
    final List<String> expectedPropertyKeys = Stream.of("name", "age", "time", "place", "reason")
            .collect(Collectors.toList());
    assertTrue(propertyKeys.containsAll(expectedPropertyKeys));

    final PropertyKey place = management.getPropertyKey("place");
    assertEquals(Cardinality.SINGLE, place.cardinality());
    assertEquals(Geoshape.class, place.dataType());

    final JanusGraphIndex nameIndex = management.getGraphIndex("nameIndex");
    assertTrue(nameIndex.isCompositeIndex());
    assertTrue(nameIndex.getIndexedElement().equals(JanusGraphVertex.class));
    final PropertyKey[] nameIndexKeys = nameIndex.getFieldKeys();
    assertEquals(1, nameIndexKeys.length);
    assertEquals("name", nameIndexKeys[0].name());
}

From source file:cz.swi2.mendeluis.dataaccesslayer.domain.PortletTest.java

@org.testng.annotations.Test
public void testGetAll() {
    // Create portlets
    Portlet portlet = new Portlet("Food menu xx");
    Portlet portlet2 = new Portlet("Food menu xx 2");

    // Insert portlet
    this.portletRepository.insert(portlet);
    this.portletRepository.insert(portlet2);

    // Fetch all portlets
    List<Portlet> results = this.portletRepository.getAll();

    // Prepare a list to be compared
    List<Portlet> portlets = new ArrayList();
    portlets.add(portlet);//from w w w.ja  va  2 s.c  om
    portlets.add(portlet2);

    // We do not use a different db for testing. Thefore we must test only matching items, not all. 
    assertTrue(results.containsAll(portlets));
}

From source file:cz.swi2.mendeluis.service.UserServiceTest.java

@org.testng.annotations.Test
public void testGetAll() {
    User user, user2;//from  w  w  w .j av a2 s.co m
    try {
        // Create users
        user = this.userService.createNewUser("aaa", "aaa", "aaa");
        user2 = this.userService.createNewUser("aaa2", "aaa2", "aaa");

        // Find users
        List<User> results = this.userService.getAllUsers();

        // assert equal
        List<User> users = new ArrayList();
        users.add(user);
        users.add(user2);

        // We do not use a different db for testing. Thefore we must test only matching items, not all. 
        assertTrue(results.containsAll(users));

    } catch (UniqueViolationException ex) {
        Logger.getLogger(PortletServiceTest.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
}

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

@Test
@SuppressWarnings("unchecked")
public void subRegionRepositoryInteractions() {
    //assertEquals(PROGRAMMER_DATA.get("JamesGosling"), programmersRepo.findOne("JamesGosling"));

    List<Programmer> javaProgrammers = programmersRepo.findDistinctByProgrammingLanguageOrderByNameAsc("Java");

    assertNotNull(javaProgrammers);// w ww .  j  av  a2  s  .co  m
    assertFalse(javaProgrammers.isEmpty());
    assertEquals(2, javaProgrammers.size());
    assertTrue(javaProgrammers.containsAll(getProgrammers("JamesGosling", "JoshuaBloch")));

    List<Programmer> groovyProgrammers = programmersRepo
            .findDistinctByProgrammingLanguageLikeOrderByNameAsc("Groovy");

    assertNotNull(groovyProgrammers);
    assertFalse(groovyProgrammers.isEmpty());
    assertEquals(1, groovyProgrammers.size());
    assertTrue(groovyProgrammers.containsAll(getProgrammers("JamesStrachan")));

    programmersRepo.save(new Wrapper(createProgrammer("RodJohnson", "Java"), "RodJohnson"));
    programmersRepo.save(new Wrapper(createProgrammer("GuillaumeLaforge", "Groovy"), "GuillaumeLaforge"));
    programmersRepo.save(new Wrapper(createProgrammer("GraemeRocher", "Groovy"), "GraemeRocher"));

    javaProgrammers = programmersRepo.findDistinctByProgrammingLanguageOrderByNameAsc("Java");

    assertNotNull(javaProgrammers);
    assertFalse(javaProgrammers.isEmpty());
    assertEquals(3, javaProgrammers.size());
    assertTrue(javaProgrammers.containsAll(getProgrammers("JamesGosling", "JoshuaBloch", "RodJohnson")));

    groovyProgrammers = programmersRepo.findDistinctByProgrammingLanguageLikeOrderByNameAsc("Groovy");

    assertNotNull(groovyProgrammers);
    assertFalse(groovyProgrammers.isEmpty());
    assertEquals(3, groovyProgrammers.size());
    assertTrue(
            groovyProgrammers.containsAll(getProgrammers("GraemeRocher", "GuillaumeLaforge", "JamesStrachan")));

    List<Programmer> javaLikeProgrammers = programmersRepo
            .findDistinctByProgrammingLanguageLikeOrderByNameAsc("Java%");

    assertNotNull(javaLikeProgrammers);
    assertFalse(javaLikeProgrammers.isEmpty());
    assertEquals(4, javaLikeProgrammers.size());
    assertTrue(javaLikeProgrammers
            .containsAll(getProgrammers("BrendanEich", "JamesGosling", "JoshuaBloch", "RodJohnson")));

    List<Programmer> pseudoCodeProgrammers = programmersRepo
            .findDistinctByProgrammingLanguageLikeOrderByNameAsc("PseudoCode");

    assertNotNull(pseudoCodeProgrammers);
    assertTrue(pseudoCodeProgrammers.isEmpty());
}

From source file:org.intermine.webservice.server.widget.EnrichmentWidgetResultService.java

private boolean verifyPopulationContainsBag(InterMineBag bag, InterMineBag populationBag) {
    //verify the population Bag contains all elements of imBag
    List<Integer> populationBagContentdIds = new ArrayList<Integer>(populationBag.getContentsAsIds());
    List<Integer> bagContentdIds = new ArrayList<Integer>(bag.getContentsAsIds());
    if (populationBagContentdIds.containsAll(bagContentdIds)) {
        return true;
    }//ww  w .ja  v  a  2 s  .  c  o  m
    return false;
}

From source file:eu.freme.eservices.epublishing.webservice.EPUBCreationTest.java

@Ignore
@Test/*from  w w  w  .j  av  a2s .  com*/
public void testWithoutAuthor() throws FileNotFoundException, InvalidZipException, EPubCreationException,
        IOException, MissingMetadataException {
    Metadata metadata = getSimpleMetadataForZip();
    //metadata.setAuthors(new ArrayList<String>());

    byte[] epub = getePublishingService().createEPUB(metadata, new FileInputStream(getZipFile()));

    // write it to a (temporary) file
    File ePubFile = File.createTempFile("alice", ".epub");
    System.out.println("Writing result to " + ePubFile);
    IOUtils.copy(new ByteArrayInputStream(epub), new FileOutputStream(ePubFile));

    //read file and perform checks
    EpubReader r = new EpubReader();
    Book b = r.readEpub(new FileInputStream(ePubFile));
    List<CreatorContributor> bookAuthors = b.getMetadata().getAuthors();
    List<String> bookAuthorsNames = new ArrayList<>();

    for (CreatorContributor a : bookAuthors) {
        bookAuthorsNames.add(a.getFirstname() + " " + a.getLastname());
    }

    System.out.println(bookAuthorsNames);
    Assert.assertTrue("All authors are in the EPUB.", bookAuthorsNames.containsAll(metadata.getAuthors()));
    Assert.assertTrue("All EPUB authors are in the given authors.",
            metadata.getAuthors().containsAll(bookAuthorsNames));
}