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.finra.dm.dao.DmDaoTest.java

@Test
public void testGetFileTypes() throws Exception {
    // Create and persist file type entities.
    for (FileTypeKey key : getTestFileTypeKeys()) {
        createFileTypeEntity(key.getFileTypeCode());
    }/*ww  w  .j a v a 2s  . c o  m*/

    // Retrieve a list of file type keys.
    List<FileTypeKey> resultFileTypeKeys = dmDao.getFileTypes();

    // Validate the returned object.
    assertNotNull(resultFileTypeKeys);
    assertTrue(resultFileTypeKeys.containsAll(getTestFileTypeKeys()));
}

From source file:com.square.tarificateur.noyau.util.comparaison.famille.ComparaisonFamilleUtil.java

/**
 * Compare les champs des 2 familles passes en paramtres.
 * @param personnePrincipaleDto le DTO de la personne principale
 * @param personnePrincipale le modle de la personne principale
 * @return true si les familles sont identiques, false sinon
 *///from w ww . j a  v a  2  s. c o m
public boolean isFamillesIdentiques(PersonneTarificateurDto personnePrincipaleDto,
        Personne personnePrincipale) {
    // Rinitialisation des converters pour BeanUtils
    resetConverter();

    // Comparaison de la personne principale
    if (!isPersonnesIdentiques(personnePrincipaleDto, personnePrincipale)) {
        return false;
    }

    // Rcupration des bnficiaires (cl : eidPersonne, valeur : bnficiaire)
    final Map<Long, BeneficiaireTarificateurDto> mapBeneficiairesDto = new HashMap<Long, BeneficiaireTarificateurDto>();
    final Map<Long, Beneficiaire> mapBeneficiaires = new HashMap<Long, Beneficiaire>();
    final List<Long> listeEidBeneficiairesDto = new ArrayList<Long>();
    final List<Long> listeEidBeneficiaires = new ArrayList<Long>();
    // Parcours de la liste des bnficiaires pour remplissage des maps
    if (personnePrincipaleDto.getListeBeneficiaires() != null
            && !personnePrincipaleDto.getListeBeneficiaires().isEmpty()) {
        for (BeneficiaireTarificateurDto beneficiaireDto : personnePrincipaleDto.getListeBeneficiaires()) {
            if (beneficiaireDto.getEidPersonne() == null) {
                throw new BusinessException(
                        messageSourceUtil.get(MessageKeyUtil.ERROR_EID_PERSONNE_BENEFICIAIRE_NON_RENSEIGNE));
            }
            mapBeneficiairesDto.put(beneficiaireDto.getEidPersonne(), beneficiaireDto);
            listeEidBeneficiairesDto.add(beneficiaireDto.getEidPersonne());
        }
    }
    if (personnePrincipale.getListeBeneficiaires() != null
            && !personnePrincipale.getListeBeneficiaires().isEmpty()) {
        for (Beneficiaire beneficiaire : personnePrincipale.getListeBeneficiaires()) {
            if (beneficiaire.getPersonneCible().getEidPersonne() == null) {
                throw new BusinessException(
                        messageSourceUtil.get(MessageKeyUtil.ERROR_EID_PERSONNE_BENEFICIAIRE_NON_RENSEIGNE));
            }
            mapBeneficiaires.put(beneficiaire.getPersonneCible().getEidPersonne(), beneficiaire);
            listeEidBeneficiaires.add(beneficiaire.getPersonneCible().getEidPersonne());
        }
    }

    // Comparaison du nombre et des eid des bnficiaires
    if (!(listeEidBeneficiairesDto.containsAll(listeEidBeneficiaires)
            && listeEidBeneficiaires.containsAll(listeEidBeneficiairesDto))) {
        logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_LISTE_BENEFICIAIRE_DIFFERE_DTO_MODEL,
                new String[] { listeEidBeneficiairesDto.toString(), listeEidBeneficiaires.toString() }));
        return false;
    }

    // Comparaison des champs de chacun des bnficiaires
    for (Long eidBeneficiaire : listeEidBeneficiairesDto) {
        final BeneficiaireTarificateurDto beneficiaireDto = mapBeneficiairesDto.get(eidBeneficiaire);
        final Beneficiaire beneficiaire = mapBeneficiaires.get(eidBeneficiaire);
        // Comparaison des liens familiaux
        if (!beneficiaire.getLienFamilial().getId().equals(beneficiaireDto.getIdLienFamilial())) {
            logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_LIEN_FAMILIAL_INCOHERENT));
            return false;
        }
        // Comparaison des champs des bnficiaires
        if (!isObjetsIdentiques(beneficiaireDto, beneficiaire.getPersonneCible(),
                listeProprietesPersonneAComparer)) {
            return false;
        }
    }

    // Tout est identique
    return true;
}

From source file:org.finra.dm.dao.DmDaoTest.java

@Test
public void testGetNamespaces() {
    // Create and persist namespace entities.
    for (NamespaceKey key : getTestNamespaceKeys()) {
        createNamespaceEntity(key.getNamespaceCode());
    }// w w w . j  a  va2 s.  c  o m

    // Retrieve a list of namespace keys.
    List<NamespaceKey> resultNamespaceKeys = dmDao.getNamespaces();

    // Validate the returned object.
    assertNotNull(resultNamespaceKeys);
    assertTrue(resultNamespaceKeys.containsAll(getTestNamespaceKeys()));
}

From source file:ubic.gemma.core.analysis.expression.diff.LinearModelAnalyzer.java

/**
 * Remove all configurations that have to do with factors that aren't in the selected factors.
 *
 * @param factors the factors that will be included
 * @return an updated config; the baselines are cleared; subset is cleared; interactions are only kept if they only
 * involve the given factors.//from  www . j ava  2 s.  c  o m
 */
private DifferentialExpressionAnalysisConfig fixConfigForSubset(List<ExperimentalFactor> factors,
        DifferentialExpressionAnalysisConfig config, FactorValue subsetFactorValue) {

    DifferentialExpressionAnalysisConfig newConfig = new DifferentialExpressionAnalysisConfig();

    newConfig.setBaseLineFactorValues(null);

    if (!config.getInteractionsToInclude().isEmpty()) {
        Collection<Collection<ExperimentalFactor>> newInteractionsToInclude = new HashSet<>();
        for (Collection<ExperimentalFactor> interactors : config.getInteractionsToInclude()) {
            if (factors.containsAll(interactors)) {
                newInteractionsToInclude.add(interactors);
            }
        }

        newConfig.setInteractionsToInclude(newInteractionsToInclude);
    }

    newConfig.setSubsetFactor(null);
    newConfig.setSubsetFactorValue(subsetFactorValue);
    newConfig.setFactorsToInclude(factors);

    return newConfig;

}

From source file:org.finra.dm.dao.DmDaoTest.java

@Test
public void testGetBusinessObjectDefinitionsLegacy() throws Exception {
    // Create and persist business object definition entities.
    for (BusinessObjectDefinitionKey key : getTestBusinessObjectDefinitionKeys()) {
        createBusinessObjectDefinitionEntity(key.getNamespace(), key.getBusinessObjectDefinitionName(),
                DATA_PROVIDER_NAME, BOD_DESCRIPTION, null);
    }/*from   www .  j a  v  a2s  .  co m*/

    // Retrieve a list of business object definition keys stored in the system by calling a legacy endpoint.
    List<BusinessObjectDefinitionKey> resultKeys = dmDao.getBusinessObjectDefinitions();

    // Validate the returned object.
    assertNotNull(resultKeys);
    assertTrue(resultKeys.containsAll(getTestBusinessObjectDefinitionKeys()));
}

From source file:org.finra.dm.dao.DmDaoTest.java

@Test
public void testGetPartitionKeyGroups() {
    // Create and persist two partition key group entities.
    for (PartitionKeyGroupKey partitionKeyGroupKey : getTestPartitionKeyGroupKeys()) {
        createPartitionKeyGroupEntity(partitionKeyGroupKey.getPartitionKeyGroupName());
    }//from   w  w  w .j  a  v  a 2 s .  c om

    // Get the list of partition key groups.
    List<PartitionKeyGroupKey> resultPartitionKeyGroupKeys = dmDao.getPartitionKeyGroups();

    // Validate the results.
    assertNotNull(resultPartitionKeyGroupKeys);
    assertTrue(resultPartitionKeyGroupKeys.containsAll(getTestPartitionKeyGroupKeys()));
}

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

/**
 * Test method for {@link BaseComponentDef#getControllerDefDescriptors()}.
 *//*from w ww . ja v a 2 s  . c  o  m*/
public void testGetControllerDefDescriptors() throws QuickFixException {
    @SuppressWarnings("unchecked")
    DefDescriptor<T> ddParent = (DefDescriptor<T>) define(baseTag,
            "extensible='true' controller='java://org.auraframework.impl.java.controller.TestController2'", "")
                    .getDescriptor();
    List<DefDescriptor<ControllerDef>> dds = define(baseTag,
            "controller='java://org.auraframework.component.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.component.test.java.controller.TestController",
                    "java://org.auraframework.impl.java.controller.TestController2")));
}

From source file:com.linkedin.d2.balancer.simple.SimpleLoadBalancerTest.java

/**
 * This tests the getPartitionInfo() when given a collection of keys (actually a test for KeyMapper.mapKeysV3()).
 *///from  w  w w.j  a  va 2  s.  c om
@Test
public void testGetPartitionInfoOrdering() throws Exception {
    String serviceName = "articles";
    String clusterName = "cluster";
    String path = "path";
    String strategyName = "degrader";

    // setup 3 partitions. Partition 1 and Partition 2 both have server1 - server3. Partition 3 only has server1.
    Map<URI, Map<Integer, PartitionData>> partitionDescriptions = new HashMap<URI, Map<Integer, PartitionData>>();

    final URI server1 = new URI("http://foo1.com");
    Map<Integer, PartitionData> server1Data = new HashMap<Integer, PartitionData>();
    server1Data.put(1, new PartitionData(1.0));
    server1Data.put(2, new PartitionData(1.0));
    server1Data.put(3, new PartitionData(1.0));
    partitionDescriptions.put(server1, server1Data);

    final URI server2 = new URI("http://foo2.com");
    Map<Integer, PartitionData> server2Data = new HashMap<Integer, PartitionData>();
    server2Data.put(1, new PartitionData(1.0));
    server2Data.put(2, new PartitionData(1.0));
    partitionDescriptions.put(server2, server2Data);

    final URI server3 = new URI("http://foo3.com");
    Map<Integer, PartitionData> server3Data = new HashMap<Integer, PartitionData>();
    server3Data.put(1, new PartitionData(1.0));
    server3Data.put(2, new PartitionData(1.0));
    partitionDescriptions.put(server3, server3Data);

    //setup strategy which involves tweaking the hash ring to get partitionId -> URI host
    List<LoadBalancerState.SchemeStrategyPair> orderedStrategies = new ArrayList<LoadBalancerState.SchemeStrategyPair>();
    LoadBalancerStrategy strategy = new TestLoadBalancerStrategy(partitionDescriptions);

    orderedStrategies.add(new LoadBalancerState.SchemeStrategyPair("http", strategy));

    //setup the partition accessor which can only map keys from 1 - 3.
    PartitionAccessor accessor = new TestPartitionAccessor();

    URI serviceURI = new URI("d2://" + serviceName);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(new PartitionedLoadBalancerTestState(clusterName,
            serviceName, path, strategyName, partitionDescriptions, orderedStrategies, accessor));

    List<Integer> keys = new ArrayList<Integer>();
    keys.add(1);
    keys.add(2);
    keys.add(3);
    keys.add(123);

    HostToKeyMapper<Integer> result = balancer.getPartitionInformation(serviceURI, keys, 3, 123);

    Assert.assertEquals(result.getLimitHostPerPartition(), 3);

    Assert.assertEquals(1, result.getUnmappedKeys().size());
    Assert.assertEquals(123, (int) result.getUnmappedKeys().iterator().next().getKey());

    //partition 0 should be null
    Assert.assertNull(result.getPartitionInfoMap().get(0));
    // results for partition 1 should contain server1, server2 and server3
    KeysAndHosts<Integer> keysAndHosts1 = result.getPartitionInfoMap().get(1);
    Assert.assertTrue(keysAndHosts1.getKeys().size() == 1);
    Assert.assertTrue(keysAndHosts1.getKeys().iterator().next() == 1);
    List<URI> ordering1 = keysAndHosts1.getHosts();
    // results for partition 2 should be the same as partition1.
    KeysAndHosts<Integer> keysAndHosts2 = result.getPartitionInfoMap().get(2);
    Assert.assertTrue(keysAndHosts2.getKeys().size() == 1);
    Assert.assertTrue(keysAndHosts2.getKeys().iterator().next() == 2);
    List<URI> ordering2 = keysAndHosts2.getHosts();
    //for partition 3
    KeysAndHosts<Integer> keysAndHosts3 = result.getPartitionInfoMap().get(3);
    Assert.assertTrue(keysAndHosts3.getKeys().size() == 1);
    Assert.assertTrue(keysAndHosts3.getKeys().iterator().next() == 3);
    List<URI> ordering3 = keysAndHosts3.getHosts();

    // Just compare the size and contents of the list, not the ordering.
    Assert.assertTrue(ordering1.size() == 3);
    List<URI> allServers = new ArrayList<>();
    allServers.add(server1);
    allServers.add(server2);
    allServers.add(server3);
    Assert.assertTrue(ordering1.containsAll(allServers));
    Assert.assertTrue(ordering2.containsAll(allServers));
    Assert.assertEquals(ordering1, ordering2);
    Assert.assertEquals(ordering3.get(0), server1);

    Assert.assertTrue(result.getPartitionsWithoutEnoughHosts().containsKey(3));
    Assert.assertEquals((int) result.getPartitionsWithoutEnoughHosts().get(3), 2);
}

From source file:org.apache.metron.maas.service.MaasIntegrationTest.java

private int verifyContainerLog(int containerNum, List<String> expectedContent, boolean count,
        String expectedWord) {/* w  w w.j  av  a 2 s  . com*/
    File logFolder = new File(yarnComponent.getYARNCluster().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(description = "Getting document info list for an API")
public void testGetDocumentInfoList() throws Exception {
    ApiDAO apiDAO = DAOFactory.getApiDAO();
    testAddGetEndpoint();/*from   w w w  .j av  a 2  s .c om*/
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    apiDAO.addAPI(api);
    DocumentInfo documentInfo1 = SampleTestObjectCreator.createDefaultDocumentationInfo();
    apiDAO.addDocumentInfo(api.getId(), documentInfo1);
    DocumentInfo documentInfo2 = SampleTestObjectCreator.createDefaultDocumentationInfo();
    apiDAO.addDocumentInfo(api.getId(), documentInfo2);
    List<DocumentInfo> documentInfoList = new ArrayList<>();
    documentInfoList.add(documentInfo1);
    documentInfoList.add(documentInfo2);
    List<DocumentInfo> documentInfoListFromDB = apiDAO.getDocumentsInfoList(api.getId());
    Assert.assertTrue(documentInfoListFromDB.containsAll(documentInfoList));
    Assert.assertTrue(documentInfoList.size() == documentInfoListFromDB.size());
}