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.linkedin.pinot.controller.helix.core.rebalance.DefaultRebalanceStrategyTest.java

private void validateIdealStateRealtime(IdealState rebalancedIdealState, int nSegmentsCompleted,
        int nSegmentsConsuming, int targetNumReplicas, List<String> instancesCompleted,
        List<String> instancesConsuming, Configuration rebalanceUserConfig) {
    Assert.assertEquals(rebalancedIdealState.getPartitionSet().size(), nSegmentsCompleted + nSegmentsConsuming);
    for (String segment : rebalancedIdealState.getPartitionSet()) {
        Map<String, String> instanceStateMap = rebalancedIdealState.getInstanceStateMap(segment);
        Assert.assertEquals(instanceStateMap.size(), targetNumReplicas);
        boolean rebalanceConsuming = rebalanceUserConfig
                .getBoolean(RebalanceUserConfigConstants.INCLUDE_CONSUMING);
        if (segment.contains("consuming")) {
            if (rebalanceConsuming) {
                Assert.assertTrue(instancesConsuming.containsAll(instanceStateMap.keySet()));
            }/*from   ww  w . ja  va  2 s.com*/
        } else {
            Assert.assertTrue(instancesCompleted.containsAll(instanceStateMap.keySet()));
        }
    }
}

From source file:org.finra.dm.service.JobServiceTest.java

@Test
public void testCreateJob() throws Exception {
    // Create the namespace entity.
    createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);

    // Create a job definition create request using hard coded test values.
    JobDefinitionCreateRequest jobDefinitionCreateRequest = createJobDefinitionCreateRequest();

    // Create the job definition.
    jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest);

    // Create a job create request using hard coded test values.
    JobCreateRequest jobCreateRequest = createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD,
            TEST_ACTIVITI_JOB_NAME);//w  ww  .j a  v a 2s  .  c om

    // Create the job.
    Job resultJob = jobService.createAndStartJob(jobCreateRequest, true);

    // Validate the results.
    assertNotNull(resultJob);
    assertNotNull(resultJob.getId());
    assertTrue(!resultJob.getId().isEmpty());
    assertEquals(TEST_ACTIVITI_NAMESPACE_CD, resultJob.getNamespace());
    assertEquals(TEST_ACTIVITI_JOB_NAME, resultJob.getJobName());
    assertEquals(jobDefinitionCreateRequest.getParameters().size() + jobCreateRequest.getParameters().size(),
            resultJob.getParameters().size());
    List<String> expectedParameters = new ArrayList<>();
    expectedParameters.addAll(parametersToStringList(jobDefinitionCreateRequest.getParameters()));
    expectedParameters.addAll(parametersToStringList(jobCreateRequest.getParameters()));
    List<String> resultParameters = parametersToStringList(resultJob.getParameters());
    assertTrue(expectedParameters.containsAll(resultParameters));
    assertTrue(resultParameters.containsAll(expectedParameters));
}

From source file:de.dhke.projects.cutil.collections.aspect.AspectMapEntrySetTest.java

/**
* Test of retainAll method, of class AspectMapEntrySet.
*///from w w  w  . j  a v a  2s  .co m
@Test
public void testRetainAll() {
    List<Map.Entry<String, String>> targetList = new ArrayList<>();
    targetList.add(new DefaultMapEntry<>("A", "1"));
    targetList.add(new DefaultMapEntry<>("B", "2"));
    targetList.add(new DefaultMapEntry<>("C", "3"));
    targetList.add(new DefaultMapEntry<>("D", "4"));
    targetList.add(new DefaultMapEntry<>("E", "5"));
    assertFalse(_entrySet.retainAll(targetList));

    targetList = new ArrayList<>();
    targetList.add(new DefaultMapEntry<>("B", "2"));
    targetList.add(new DefaultMapEntry<>("C", "3"));
    targetList.add(new DefaultMapEntry<>("E", "5"));
    assertTrue(_entrySet.retainAll(targetList));

    assertEquals(2, _entrySet.size());
    assertTrue(targetList.containsAll(_entrySet));

    assertEquals(2, _listener.beforeRemoveEvents.size());
    assertEquals(new DefaultMapEntry<>("A", "1"), _listener.beforeRemoveEvents.get(0).getItem());
    ;
    assertEquals(new DefaultMapEntry<>("D", "4"), _listener.beforeRemoveEvents.get(1).getItem());
    ;
    assertEquals(2, _listener.afterRemoveEvents.size());
    assertEquals(new DefaultMapEntry<>("A", "1"), _listener.afterRemoveEvents.get(0).getItem());
    ;
    assertEquals(new DefaultMapEntry<>("D", "4"), _listener.afterRemoveEvents.get(1).getItem());
    ;
}

From source file:org.apache.hadoop.hive.ql.optimizer.AbstractBucketJoinProc.java

private boolean checkBucketColumns(List<String> bucketColumns, List<String> joinKeys, Integer[] joinKeyOrders) {
    if (joinKeys == null || bucketColumns == null || bucketColumns.isEmpty()) {
        return false;
    }//  w w  w  . j  a  v  a 2s . com
    for (int i = 0; i < joinKeys.size(); i++) {
        int index = bucketColumns.indexOf(joinKeys.get(i));
        if (joinKeyOrders[i] != null && joinKeyOrders[i] != index) {
            return false;
        }
        joinKeyOrders[i] = index;
    }

    // Check if the join columns contains all bucket columns.
    // If a table is bucketized on column B, but the join key is A and B,
    // it is easy to see joining on different buckets yield empty results.
    return joinKeys.containsAll(bucketColumns);
}

From source file:org.openbaton.nfvo.core.api.NetworkServiceRecordManagement.java

private void scaleOUT(NetworkServiceRecord networkServiceRecord,
        VirtualNetworkFunctionRecord virtualNetworkFunctionRecord, VirtualDeploymentUnit virtualDeploymentUnit,
        VNFComponent component, String mode) throws BadFormatException, NotFoundException {
    List<String> componentNetworks = new ArrayList<>();

    for (VNFDConnectionPoint connectionPoint : component.getConnection_point()) {
        componentNetworks.add(connectionPoint.getVirtual_link_reference());
    }//from   w ww .j  a  v  a 2s.c  o  m

    List<String> vnfrNetworks = new ArrayList<>();

    for (InternalVirtualLink virtualLink : virtualNetworkFunctionRecord.getVirtual_link()) {
        vnfrNetworks.add(virtualLink.getName());
    }

    if (!vnfrNetworks.containsAll(componentNetworks)) {
        throw new BadFormatException(
                "Not all the network exist in the InternalVirtualLinks. They need to be included in these names: "
                        + vnfrNetworks);
    }

    log.info("Adding VNFComponent to VirtualNetworkFunctionRecord " + virtualNetworkFunctionRecord.getName());

    for (VirtualDeploymentUnit vdu : virtualNetworkFunctionRecord.getVdu()) {
        if (vdu.getId().equals(virtualDeploymentUnit.getId())) {
            vdu.getVnfc().add(component);
        }
    }

    //        virtualDeploymentUnit.getVnfc().add(component);
    vnfcRepository.save(component);
    nsrRepository.save(networkServiceRecord);
    log.debug("new VNFComponent is " + component);

    VNFRecordDependency dependencyTarget = dependencyManagement
            .getDependencyForAVNFRecordTarget(virtualNetworkFunctionRecord);

    log.debug("Found Dependency: " + dependencyTarget);

    vnfmManager.addVnfc(virtualNetworkFunctionRecord, component, dependencyTarget, mode);
}

From source file:com.linkedin.pinot.common.partition.PartitionAssignmentGeneratorTest.java

private void verify(String tableName, PartitionAssignment partitionAssignment, int numPartitions,
        List<String> consumingInstanceList, boolean unchanged,
        PartitionAssignment previousPartitionAssignment) {
    Assert.assertEquals(partitionAssignment.getTableName(), tableName);

    // check num partitions equal
    Assert.assertEquals(partitionAssignment.getNumPartitions(), numPartitions,
            "NumPartitions do not match for table " + tableName);

    List<String> instancesUsed = new ArrayList<>();
    for (int p = 0; p < partitionAssignment.getNumPartitions(); p++) {
        for (String instance : partitionAssignment.getInstancesListForPartition(String.valueOf(p))) {
            if (!instancesUsed.contains(instance)) {
                instancesUsed.add(instance);
            }/*from w  ww . j  a va 2  s. com*/
        }
    }

    // check all instances belong to the super set
    Assert.assertTrue(consumingInstanceList.containsAll(instancesUsed),
            "Instances test failed for table " + tableName);

    // verify strategy is uniform
    int serverId = 0;
    for (int p = 0; p < partitionAssignment.getNumPartitions(); p++) {
        for (String instance : partitionAssignment.getInstancesListForPartition(String.valueOf(p))) {
            Assert.assertTrue(instance.equals(instancesUsed.get(serverId++)),
                    "Uniform strategy test failed for table " + tableName);
            if (serverId == instancesUsed.size()) {
                serverId = 0;
            }
        }
    }

    // if nothing changed, should be same as before
    if (unchanged) {
        Assert.assertEquals(partitionAssignment, previousPartitionAssignment,
                "Partition assignment should have been unchanged for table " + tableName);
    }
}

From source file:org.talend.mdm.repository.utils.RepositoryResourceUtilTest.java

/**
 * Test for: findViewObjects(ERepositoryObjectType type, Item parentItem, IFolder folder, boolean
 * useRepositoryViewObject, boolean withDeleted)
 *//*from   w w w .ja  v a  2s .co m*/
@Test
public void testFindViewObjects5Args() throws Exception {
    boolean withDeleted = false;
    boolean useRepositoryViewObject = true;

    Item mockParentItem = mock(Item.class);
    String path = "mockPath"; //$NON-NLS-1$
    ItemState mockItemState = mock(ItemState.class);
    when(mockParentItem.getState()).thenReturn(mockItemState);
    when(mockItemState.getPath()).thenReturn(path);

    ERepositoryObjectType mockType = mock(ERepositoryObjectType.class);

    IFolder[] mockResources = { mock(IFolder.class), mock(IFolder.class), mock(IFolder.class) };
    for (IFolder folder : mockResources) {
        when(folder.getName()).thenReturn("folder");
    }
    IFolder mockFolder = mock(IFolder.class);
    when(mockFolder.members()).thenReturn(mockResources);
    when(mockFolder.exists()).thenReturn(true);

    PowerMockito.mockStatic(RepositoryResourceUtil.class);
    PowerMockito.doReturn(false).when(RepositoryResourceUtil.class, "isDeletedFolder", mockResources[0]);
    PowerMockito.doReturn(false).when(RepositoryResourceUtil.class, "isDeletedFolder", mockResources[1]);
    PowerMockito.doReturn(false).when(RepositoryResourceUtil.class, "isDeletedFolder", mockResources[2]);
    PowerMockito.doReturn(false).when(RepositoryResourceUtil.class, "isSVNFolder", mockResources[0]);
    PowerMockito.doReturn(false).when(RepositoryResourceUtil.class, "isSVNFolder", mockResources[1]);
    PowerMockito.doReturn(false).when(RepositoryResourceUtil.class, "isSVNFolder", mockResources[2]);
    IRepositoryViewObject mock1ViewObject = mock(IRepositoryViewObject.class);
    when(RepositoryResourceUtil.createFolderViewObject(mockType, "folder", mockParentItem, false))
            .thenReturn(mock1ViewObject);

    PowerMockito.mockStatic(ContainerCacheService.class);
    // to mock ContainerCacheService.get(type, resPath);
    IRepositoryViewObject folderObject = mock(IRepositoryViewObject.class);
    PowerMockito.doReturn(folderObject).when(ContainerCacheService.class, "get", mockType, path); //$NON-NLS-1$

    List<IRepositoryViewObject> mockViewObjects = new ArrayList<IRepositoryViewObject>();
    mockViewObjects.add(mock(IRepositoryViewObject.class));
    mockViewObjects.add(mock(IRepositoryViewObject.class));
    mockViewObjects.add(mock(IRepositoryViewObject.class));
    when(RepositoryResourceUtil.findViewObjectsInFolder(mockType, mockParentItem, useRepositoryViewObject,
            withDeleted)).thenReturn(mockViewObjects);

    PowerMockito.doCallRealMethod().when(RepositoryResourceUtil.class, "findViewObjects", mockType,
            mockParentItem, mockFolder, useRepositoryViewObject, withDeleted);
    List<IRepositoryViewObject> allViewObjects = RepositoryResourceUtil.findViewObjects(mockType,
            mockParentItem, mockFolder, useRepositoryViewObject, withDeleted);

    assertEquals(6, allViewObjects.size());
    assertTrue(allViewObjects.containsAll(mockViewObjects));
    assertTrue(allViewObjects.contains(mock1ViewObject));
}

From source file:com.kylinolap.metadata.model.cube.CubeDesc.java

public Map<Array<TblColRef>, List<DeriveInfo>> getHostToDerivedInfo(List<TblColRef> rowCols,
        Collection<TblColRef> wantedCols) {
    Map<Array<TblColRef>, List<DeriveInfo>> result = new HashMap<Array<TblColRef>, List<DeriveInfo>>();
    for (Entry<Array<TblColRef>, List<DeriveInfo>> entry : hostToDerivedMap.entrySet()) {
        Array<TblColRef> hostCols = entry.getKey();
        boolean hostOnRow = rowCols.containsAll(Arrays.asList(hostCols.data));
        if (!hostOnRow)
            continue;

        List<DeriveInfo> wantedInfo = new ArrayList<DeriveInfo>();
        for (DeriveInfo info : entry.getValue()) {
            if (wantedCols == null || Collections.disjoint(wantedCols, Arrays.asList(info.columns)) == false) // has
                                                                                                              // any
                                                                                                              // wanted
                                                                                                              // columns?
                wantedInfo.add(info);/* ww  w . ja  va  2 s  .co m*/
        }

        if (wantedInfo.size() > 0)
            result.put(hostCols, wantedInfo);
    }
    return result;
}

From source file:com.espertech.esper.regression.resultset.TestOrderBySimple.java

private void assertOnlyProperties(List<String> requiredProperties) {
    EventBean[] events = testListener.getLastNewData();
    if (events == null || events.length == 0) {
        return;/*from   w  ww  .  j av a2s  .c o  m*/
    }
    EventType type = events[0].getEventType();
    List<String> actualProperties = new ArrayList<String>(Arrays.asList(type.getPropertyNames()));
    log.debug(".assertOnlyProperties actualProperties==" + actualProperties);
    assertTrue(actualProperties.containsAll(requiredProperties));
    actualProperties.removeAll(requiredProperties);
    assertTrue(actualProperties.isEmpty());
}

From source file:org.apache.kylin.cube.model.v1_4_0.CubeDesc.java

public Map<Array<TblColRef>, List<DeriveInfo>> getHostToDerivedInfo(List<TblColRef> rowCols,
        Collection<TblColRef> wantedCols) {
    Map<Array<TblColRef>, List<DeriveInfo>> result = new HashMap<Array<TblColRef>, List<DeriveInfo>>();
    for (Entry<Array<TblColRef>, List<DeriveInfo>> entry : hostToDerivedMap.entrySet()) {
        Array<TblColRef> hostCols = entry.getKey();
        boolean hostOnRow = rowCols.containsAll(Arrays.asList(hostCols.data));
        if (!hostOnRow)
            continue;

        List<DeriveInfo> wantedInfo = new ArrayList<DeriveInfo>();
        for (DeriveInfo info : entry.getValue()) {
            if (wantedCols == null || Collections.disjoint(wantedCols, Arrays.asList(info.columns)) == false) // has
                // any
                // wanted
                // columns?
                wantedInfo.add(info);/*  ww  w .j av a  2s .  com*/
        }

        if (wantedInfo.size() > 0)
            result.put(hostCols, wantedInfo);
    }
    return result;
}