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:eu.freme.eservices.epublishing.webservice.EPUBCreationTest.java

@Ignore
@Test/*  ww  w  .  j av a 2  s  .co m*/
public void testWithoutTitle() throws FileNotFoundException, InvalidZipException, EPubCreationException,
        IOException, MissingMetadataException {
    Metadata metadata = getSimpleMetadataForZip();
    metadata.setTitles(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<String> bookTitles = b.getMetadata().getTitles();

    Assert.assertTrue("All titles are in the EPUB.", bookTitles.containsAll(metadata.getTitles()));
    Assert.assertTrue("All EPUB titles are in the given titles.", metadata.getTitles().containsAll(bookTitles));
}

From source file:org.pivotal.sqlfire.CommonTransactionalBatchInsertsTest.java

@Test
public void testBatchInserts() {
    assertEquals(0, getUserService().getNumberOfUsers());

    List<User> userList = Arrays.asList(USERS);

    assertNotNull(userList);/*from   w w  w .ja  va2s. com*/
    assertEquals(USERS.length, userList.size());
    assertTrue(userList.containsAll(Arrays.asList(USERS)));

    List<User> userBatchOne = userList.subList(0, userList.size() / 2);
    List<User> userBatchTwo = userList.subList(userList.size() / 2, userList.size());

    assertNotNull(userBatchOne);
    assertNotNull(userBatchTwo);
    assertEquals(userList.size(), userBatchOne.size() + userBatchTwo.size());
    assertTrue(userBatchOne.contains(createUser("jondoe")));
    assertFalse(userBatchOne.contains(createUser("imapigg")));
    assertTrue(userBatchTwo.contains(createUser("jondoe")));
    assertFalse(userBatchTwo.contains(createUser("piedoe")));

    getUserService().addAll(userBatchOne);

    assertEquals(userBatchOne.size(), getUserService().getNumberOfUsers());

    try {
        getUserService().addAll(userBatchTwo);
    }
    // TODO refactor!
    // NOTE the following assertions are very fragile and naive but used temporarily only for testing
    // and experimentation purposes
    catch (ConstraintViolationException expected) {
        assertTrue(expected.getCause() instanceof SQLException);
        System.err.printf("%1$s%n", expected.getCause().getMessage());
    } catch (DataIntegrityViolationException expected) {
        System.err.printf("%1$s%n", expected);
    } catch (DataAccessException expected) {
        assertTrue(expected.getCause() instanceof PersistenceException);
        assertTrue(expected.getCause().getCause() instanceof SQLIntegrityConstraintViolationException
                || expected.getCause() instanceof SQLException);
        System.err.printf("%1$s%n", expected.getCause().getMessage());
    } catch (PersistenceException expected) {
        assertTrue(expected.getCause() instanceof ConstraintViolationException);
        assertTrue(expected.getCause().getCause() instanceof SQLException);
        System.err.printf("%1$s%n", expected.getCause().getCause().getMessage());
        //assertTrue(expected.getCause().getCause().getMessage().contains(
        //  "duplicate value(s) for column(s) USERNAME in statement"));
    }

    assertEquals(userBatchOne.size(), getUserService().getNumberOfUsers());

    List<User> users = getUserService().list();

    System.out.printf("%1$s%n", users);
    System.out.printf("%1$s%n", toString(users.get(0)));
}

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

@Ignore
@Test/*  w w w  .jav a 2  s .  c om*/
public void testTitles()
        throws IOException, InvalidZipException, EPubCreationException, MissingMetadataException {
    String anotherTitle = "Alice in Europe";

    Metadata metadata = getSimpleMetadataForZip();
    metadata.addTitle(anotherTitle);

    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<String> bookTitles = b.getMetadata().getTitles();

    Assert.assertTrue("All titles are in the EPUB.", bookTitles.containsAll(metadata.getTitles()));
    Assert.assertTrue("All EPUB titles are in the given titles.", metadata.getTitles().containsAll(bookTitles));
}

From source file:org.commonjava.indy.ftest.core.content.GroupMembershipChangeUpdateMetadataTest.java

protected void checkGroupMembership(StoreKey... keys) throws Exception {
    List<StoreKey> members = getGroupMembers();
    assertThat(members.containsAll(Arrays.asList(keys)), equalTo(true));
}

From source file:de.tudarmstadt.ukp.csniper.webapp.statistics.SortableAggregatedEvaluationResultDataProvider.java

public void setFilters(List<ResultFilter> aFilters) {
    if (!(aFilters.containsAll(filters) && filters.containsAll(aFilters))) {
        filters = aFilters;//w w w.  j av  a  2 s  .  com
        filterChanged = true;
    }
}

From source file:com.fns.grivet.service.NamedQueryServiceSprocTest.java

@Test
public void testSuccessfulNamedQueryExecution() throws IOException {
    Resource r = resolver.getResource("classpath:TestSprocQuery.json");
    String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset());
    NamedQuery namedQuery = objectMapper.readValue(json, NamedQuery.class);
    namedQueryService.create(namedQuery);

    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    Timestamp tomorrow = Timestamp.valueOf(LocalDateTime.now().plusDays(1));
    params.add("createdTime", tomorrow);
    String result = namedQueryService.get("sproc.getAttributesCreatedBefore", params);
    String[] expected = { "bigint", "varchar", "decimal", "datetime", "int", "text", "json", "boolean" };
    List<String> actual = JsonPath.given(result).getList("NAME");
    Assertions.assertTrue(actual.size() == 8, "Result should contain 8 attributes");
    Assertions.assertTrue(actual.containsAll(Arrays.asList(expected)));
}

From source file:org.nuxeo.webengine.sites.listeners.TestWikiProcessing.java

@Test
public void testProcessing() throws Exception {
    InputStream is = new FileInputStream(FileUtils.getResourceFileFromContext("test-data/page1.wiki"));
    String wikiInput = FileUtils.read(is);
    SitesWikiListener listener = new SitesWikiListener();

    WikiProcessingResult result = listener.processWikiContent(wikiInput, "/nuxeo/site/sites",
            "/nuxeo/site/sites/mypage");
    List<String> relations = result.getRelationLinks();

    List<String> expected = Lists.newArrayList("/nuxeo/site/sites/mypage/WikiPage1",
            "/nuxeo/site/sites/mypage/WikiPage2", "/nuxeo/site/sites/mypage/Page");
    assertTrue(relations.containsAll(expected));

    String content = result.getWikiContent().trim();
    WikiProcessingResult result2 = listener.processWikiContent(content, "/nuxeo/site/sites",
            "/nuxeo/site/sites/mypage");
    String content2 = result2.getWikiContent().trim();
    assertEquals(content, content2);/*w w w .  j  av  a  2 s  .c o m*/
}

From source file:com.googlecode.jgenhtml.plugin.JGenHtmlExecuterTest.java

public void testAddTracefileWithMultipleStringArrs() {
    System.out.println("testAddTracefileWithMultipleStringArrs");
    String[] tracefiles1 = { "/foo/bar/test.info", "/bar/foo/test.info" };
    String[] tracefiles2 = { "/foo/bar/test1.info", "/bar/foo/test1.info" };
    JGenHtmlExecuter instance = new JGenHtmlExecuter();
    instance.addTracefile(tracefiles1);/*from w ww  .  j a v  a  2s.  c  om*/
    instance.addTracefile(tracefiles2);
    String[] tracefilesActual = getTracefiles(instance.buildArgs());
    assertEquals(4, tracefilesActual.length);
    List<String> actualAsList = Arrays.asList(tracefilesActual);
    assertTrue(actualAsList.containsAll(Arrays.asList(tracefiles1)));
    assertTrue(actualAsList.containsAll(Arrays.asList(tracefiles2)));
}

From source file:com.tilab.fiware.metaware.service.TemplateServiceTest.java

/**
 * Test of getTemplatesList method, of class TemplateService.
 *//*from  w w w . j av a 2  s  . c  o  m*/
@Test
public void testGetTemplatesList() {
    System.out.println("getTemplatesList");
    TemplateService instance = new TemplateService();
    List<Template> expResult = new ArrayList<>();
    expResult.add(temp1);
    expResult.add(temp2);
    List<Template> result = instance.getTemplatesList();
    assertTrue(expResult.containsAll(result) && result.containsAll(expResult));
}

From source file:com.tilab.fiware.metaware.service.DiscoverObjServiceTest.java

/**
 * Test of discoverOwned method, of class DiscoverObjService.
 *//*from  www  .ja  v a 2 s .c om*/
@Test
public void testDiscoverOwned() {
    System.out.println("discoverOwned");
    String id = userId1;
    DiscoverObjService instance = new DiscoverObjService();
    List expResult = new ArrayList();
    expResult.add(algo2);
    expResult.add(data2);
    List result = instance.discoverOwned(id);
    assertTrue(expResult.containsAll(result) && result.containsAll(expResult));
}