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.wso2.carbon.apimgt.core.dao.impl.ApiDAOImplIT.java

@Test(description = "Getting document content for an API")
public void testGetDocumentContent() throws Exception {
    ApiDAO apiDAO = DAOFactory.getApiDAO();
    testAddGetEndpoint();//w  ww. ja  v  a  2 s.  c om
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    apiDAO.addAPI(api);
    DocumentInfo documentInfo1 = SampleTestObjectCreator.createDefaultDocumentationInfo();
    apiDAO.addDocumentInfo(api.getId(), documentInfo1);
    List<DocumentInfo> documentInfoList = new ArrayList<>();
    documentInfoList.add(documentInfo1);
    List<DocumentInfo> documentInfoListFromDB = apiDAO.getDocumentsInfoList(api.getId());
    Assert.assertTrue(documentInfoListFromDB.containsAll(documentInfoList));

    DocumentInfo documentInfo = SampleTestObjectCreator.createFileDocumentationInfo();
    apiDAO.addDocumentInfo(api.getId(), documentInfo);
    byte[] contentBytes = SampleTestObjectCreator.createDefaultFileDocumentationContent();

    apiDAO.addDocumentFileContent(documentInfo.getId(), new ByteArrayInputStream(contentBytes),
            "application/pdf", ADMIN);
    byte[] retrievedContentFromDB = IOUtils.toByteArray(apiDAO.getDocumentFileContent(documentInfo.getId()));
    Assert.assertEquals(contentBytes.length, retrievedContentFromDB.length);
}

From source file:org.apache.hadoop.hive.metastore.TestHiveMetaStore.java

private static void verifyPartitionsPublished(HiveMetaStoreClient client, String dbName, String tblName,
        List<String> partialSpec, List<Partition> expectedPartitions)
        throws NoSuchObjectException, MetaException, TException {
    // Test partition listing with a partial spec

    List<Partition> mpartial = client.listPartitions(dbName, tblName, partialSpec, (short) -1);
    assertEquals(// w w  w.  jav  a  2s. c o  m
            "Should have returned " + expectedPartitions.size() + " partitions, returned " + mpartial.size(),
            expectedPartitions.size(), mpartial.size());
    assertTrue("Not all parts returned", mpartial.containsAll(expectedPartitions));
}

From source file:org.auraframework.impl.root.component.BaseComponentDefTest.java

/**
 * Test method for {@link BaseComponentDef#getControllerDefDescriptors()}.
 *//*from  w w  w  .j  a v  a  2  s .c  om*/
@Test
public void testGetControllerDefDescriptors() throws QuickFixException {
    @SuppressWarnings("unchecked")
    DefDescriptor<T> ddParent = (DefDescriptor<T>) define(baseTag,
            "extensible='true' controller='java://org.auraframework.components.test.java.controller.JavaTestController'",
            "").getDescriptor();
    List<DefDescriptor<ControllerDef>> dds = define(baseTag,
            "controller='java://org.auraframework.components.test.java.controller.TestController' extends='"
                    + ddParent.getNamespace() + ":" + ddParent.getName() + "'",
            "").getControllerDefDescriptors();
    assertNotNull(dds);
    assertEquals(2, dds.size());
    List<String> names = Lists.transform(dds, new Function<DefDescriptor<?>, String>() {
        @Override
        public String apply(DefDescriptor<?> input) {
            return input.getQualifiedName();
        }
    });
    assertTrue(names.containsAll(
            ImmutableSet.of("java://org.auraframework.components.test.java.controller.TestController",
                    "java://org.auraframework.components.test.java.controller.JavaTestController")));
}

From source file:com.linkedin.pinot.controller.helix.core.realtime.PinotLLCRealtimeSegmentManagerTest.java

private Map<String, PartitionAssignment> validatePartitionAssignment(
        FakePinotLLCRealtimeSegmentManager segmentManager, Map<String, Integer> nKafkaPartitions, int nReplicas,
        List<String> instances) {
    Map<String, PartitionAssignment> partitionAssignments;
    Map<String, List<String>> partitionToServerListMap;
    partitionAssignments = segmentManager.getAllPartitionAssignments();
    for (Map.Entry<String, PartitionAssignment> entry : partitionAssignments.entrySet()) {
        String tableName = entry.getKey();
        partitionToServerListMap = entry.getValue().getPartitionToInstances();
        Assert.assertEquals(partitionToServerListMap.size(), nKafkaPartitions.get(tableName).intValue());
        for (List<String> serverList : partitionToServerListMap.values()) {
            Assert.assertEquals(serverList.size(), nReplicas);
            Assert.assertTrue(instances.containsAll(serverList));
        }/*from w  w w .j a va 2  s  . com*/
    }
    return partitionAssignments;
}

From source file:org.auraframework.def.BaseComponentDefTest.java

/**
 * Test method for {@link BaseComponentDef#getModelDefDescriptors()}.
 *///from w ww .  j a  va 2 s.c  o  m
public void testGetModelDefDescriptors() throws QuickFixException {
    DefDescriptor<T> grandParentDesc = addSourceAutoCleanup(getDefClass(),
            String.format(baseTag, "extensible='true'", ""));
    DefDescriptor<ModelDef> grandParentModelDesc = DefDescriptorImpl.getAssociateDescriptor(grandParentDesc,
            ModelDef.class, DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(grandParentModelDesc, "{obj:{}}");

    DefDescriptor<T> parentDesc = addSourceAutoCleanup(getDefClass(),
            String.format(baseTag, String.format("extends='%s' extensible='true' model='js://test.jsModel'",
                    grandParentDesc.getDescriptorName()), ""));

    DefDescriptor<T> compDesc = addSourceAutoCleanup(getDefClass(),
            String.format(baseTag,
                    String.format("extends='%s' model='java://org.auraframework.impl.java.model.TestModel'",
                            parentDesc.getDescriptorName()),
                    ""));

    List<DefDescriptor<ModelDef>> dds = compDesc.getDef().getModelDefDescriptors();
    assertNotNull(dds);

    assertEquals(3, dds.size());
    List<String> names = Lists.transform(dds, new Function<DefDescriptor<?>, String>() {
        @Override
        public String apply(DefDescriptor<?> input) {
            return input.getQualifiedName();
        }
    });
    Set<String> expected = ImmutableSet.of("java://org.auraframework.impl.java.model.TestModel",
            "js://test.jsModel", grandParentModelDesc.getQualifiedName());
    if (!names.containsAll(expected)) {
        fail("Missing expected models. Expected: " + expected + ", Actual: " + names);
    }
    if (!expected.containsAll(names)) {
        fail("Unexpected models. Expected: " + expected + ", Actual: " + names);
    }
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

public void listTextSelectionShouldBe(String locator, List<String> items) {
    List<String> texts = getSelectedListLabels(locator);
    boolean containsText = items.containsAll(texts);

    if (containsText) {
        LOG.createAppender().appendBold("List Selection Should Be: (text)").appendCss(locator)
                .appendProperty("Expected", items).appendProperty("Actual", texts).log();

        return;//from   w ww .  j  a v a2s  .  co  m
    }

    throw new IllegalArgumentException("Selection text list not found");
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

public void listValueSelectionShouldBe(String locator, List<String> items) {
    List<String> values = getSelectedListValues(locator);

    boolean containsValues = items.containsAll(values);

    if (containsValues) {
        LOG.createAppender().appendBold("List Value Selection Should Be:").appendCss(locator)
                .appendProperty("Expected", items).appendProperty("Actual Values", values).log();

        return;/*from ww w.j av  a2  s . c  o m*/
    }

    throw new IllegalArgumentException("Selection value for list not found");
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

public void listSelectionShouldBe(String locator, List<String> items) {
    List<String> values = getSelectedListValues(locator);

    boolean containsValues = items.containsAll(values);

    if (containsValues) {
        LOG.createAppender().appendBold("List Selection Should Be: (values)").appendCss(locator)
                .appendProperty("Expected", items).appendProperty("Actual Values", values).log();

        return;//from  www .  j  av a 2s. com
    }

    List<String> texts = getSelectedListLabels(locator);
    boolean containsText = items.containsAll(texts);

    if (containsText) {
        LOG.createAppender().appendBold("List Selection Should Be: (text)").appendCss(locator)
                .appendProperty("Expected", items).appendProperty("Actual", texts).log();

        return;
    }

    throw new IllegalArgumentException("Selection list not found");
}

From source file:org.apache.hadoop.yarn.applications.amonly.TestDistributedShell.java

private int verifyContainerLog(int containerNum, List<String> expectedContent, boolean count,
        String expectedWord) {/* w  w w .  j  a va  2 s  . c  o  m*/
    File logFolder = new File(yarnCluster.getNodeManager(0).getConfig().get(YarnConfiguration.NM_LOG_DIRS,
            YarnConfiguration.DEFAULT_NM_LOG_DIRS));

    File[] listOfFiles = logFolder.listFiles();
    int currentContainerLogFileIndex = -1;
    for (int i = listOfFiles.length - 1; i >= 0; i--) {
        if (listOfFiles[i].listFiles().length == containerNum + 1) {
            currentContainerLogFileIndex = i;
            break;
        }
    }
    Assert.assertTrue(currentContainerLogFileIndex != -1);
    File[] containerFiles = listOfFiles[currentContainerLogFileIndex].listFiles();

    int numOfWords = 0;
    for (int i = 0; i < containerFiles.length; i++) {
        for (File output : containerFiles[i].listFiles()) {
            if (output.getName().trim().contains("stdout")) {
                BufferedReader br = null;
                List<String> stdOutContent = new ArrayList<String>();
                try {

                    String sCurrentLine;
                    br = new BufferedReader(new FileReader(output));
                    int numOfline = 0;
                    while ((sCurrentLine = br.readLine()) != null) {
                        if (count) {
                            if (sCurrentLine.contains(expectedWord)) {
                                numOfWords++;
                            }
                        } else if (output.getName().trim().equals("stdout")) {
                            if (!Shell.WINDOWS) {
                                Assert.assertEquals("The current is" + sCurrentLine,
                                        expectedContent.get(numOfline), sCurrentLine.trim());
                                numOfline++;
                            } else {
                                stdOutContent.add(sCurrentLine.trim());
                            }
                        }
                    }
                    /* By executing bat script using cmd /c,
                     * it will output all contents from bat script first
                     * It is hard for us to do check line by line
                     * Simply check whether output from bat file contains
                     * all the expected messages
                     */
                    if (Shell.WINDOWS && !count && output.getName().trim().equals("stdout")) {
                        Assert.assertTrue(stdOutContent.containsAll(expectedContent));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    try {
                        if (br != null)
                            br.close();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
    }
    return numOfWords;
}

From source file:org.wso2.carbon.apimgt.core.dao.impl.ApiDAOImplIT.java

@Test
public void testGetAPIsByStatusStore() throws Exception {

    //Add few APIs with different attributes.
    List<String> apiIDList = createAPIsAndGetIDsOfAddedAPIs();
    Set<String> userRoles = new HashSet<>();
    List<String> statuses = new ArrayList<>();
    statuses.add(APIStatus.PUBLISHED.getStatus());
    statuses.add(APIStatus.PROTOTYPED.getStatus());
    ApiDAO apiDAO = DAOFactory.getApiDAO();
    String[] expectedAPINames;/*from   w w  w.  j a  v a 2  s . co m*/
    List<API> apiResults;

    //Asserting results for different search queries
    //Role based API retrieval for a user with "admin" role
    userRoles.add(ADMIN);
    apiResults = apiDAO.getAPIsByStatus(userRoles, statuses);
    List<String> resultAPINameList = new ArrayList<>();
    for (API api : apiResults) {
        resultAPINameList.add(api.getName());
    }
    expectedAPINames = new String[] { "PublicAPI", "AdminManagerAPI" };
    Assert.assertTrue(resultAPINameList.containsAll(Arrays.asList(expectedAPINames))
            && Arrays.asList(expectedAPINames).containsAll(resultAPINameList));
    userRoles.clear();
    apiResults.clear();
    resultAPINameList.clear();

    //Role based API retrieval for a user with "manager" role
    userRoles.add(MANAGER_ROLE);
    apiResults = apiDAO.getAPIsByStatus(userRoles, statuses);
    for (API api : apiResults) {
        resultAPINameList.add(api.getName());
    }
    expectedAPINames = new String[] { "PublicAPI", "ManagerOnlyAPI", "AdminManagerAPI", "NonAdminAPI" };
    Assert.assertTrue(resultAPINameList.containsAll(Arrays.asList(expectedAPINames))
            && Arrays.asList(expectedAPINames).containsAll(resultAPINameList));
    userRoles.clear();
    apiResults.clear();
    resultAPINameList.clear();

    //Role based API retrieval for a user with "manager", "employee" and "customer" roles
    userRoles.add(MANAGER_ROLE);
    userRoles.add(EMPLOYEE_ROLE);
    userRoles.add(CUSTOMER_ROLE);
    apiResults = apiDAO.getAPIsByStatus(userRoles, statuses);

    for (API api : apiResults) {
        resultAPINameList.add(api.getName());
    }
    expectedAPINames = new String[] { "PublicAPI", "ManagerOnlyAPI", "AdminManagerAPI", "EmployeeAPI",
            "NonAdminAPI" };
    Assert.assertTrue(resultAPINameList.containsAll(Arrays.asList(expectedAPINames))
            && Arrays.asList(expectedAPINames).containsAll(resultAPINameList));

}