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:gov.nih.nci.caarray.plugins.genepix.GalDesignHandler.java

private boolean isDataHeaderLine(List<String> values) {
    return values.containsAll(REQUIRED_DATA_COLUMN_HEADERS);
}

From source file:com.chiorichan.http.ssl.SniNegotiator.java

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    if (!handshaken && in.readableBytes() >= 5) {
        String hostname = sniHostNameFromHandshakeInfo(in);
        if (hostname != null)
            hostname = IDN.toASCII(hostname, IDN.ALLOW_UNASSIGNED).toLowerCase(Locale.US);
        this.hostname = hostname;

        selectedContext = SslManager.instance().map(hostname);

        if (handshaken) {
            SSLEngine engine = selectedContext.newEngine(ctx.alloc());

            List<String> supportedCipherSuites = Arrays.asList(engine.getSupportedCipherSuites());

            if (!supportedCipherSuites.containsAll(enabledCipherSuites))
                for (String cipher : enabledCipherSuites)
                    if (!supportedCipherSuites.contains(cipher)) {
                        NetworkManager.getLogger()
                                .severe(String.format(
                                        "The SSL/TLS cipher suite '%s' is not supported by SSL Provider %s",
                                        cipher, SslContext.defaultServerProvider().name()));
                        enabledCipherSuites.remove(cipher);
                    }/*from w  w w . java2  s  . c o m*/

            engine.setUseClientMode(false);
            engine.setEnabledCipherSuites(enabledCipherSuites.toArray(new String[0]));

            ctx.pipeline().replace(this, ctx.name(), new SslExceptionHandler(engine));
        }
    }
}

From source file:edu.uci.ics.asterix.optimizer.rules.ExtractFunctionsFromJoinConditionRule.java

private boolean assignFunctionExpressions(AbstractLogicalOperator joinOp, ILogicalExpression expr,
        IOptimizationContext context) throws AlgebricksException {
    if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }/*from   w w  w . j  ava  2s. c  om*/
    AbstractFunctionCallExpression fexp = (AbstractFunctionCallExpression) expr;
    FunctionIdentifier fi = fexp.getFunctionIdentifier();

    boolean modified = false;
    if (fi.equals(AlgebricksBuiltinFunctions.AND) || fi.equals(AlgebricksBuiltinFunctions.OR)
            || fi.equals(AsterixBuiltinFunctions.GET_ITEM)) {
        for (Mutable<ILogicalExpression> a : fexp.getArguments()) {
            if (assignFunctionExpressions(joinOp, a.getValue(), context)) {
                modified = true;
            }
        }
        return modified;
    } else if (AlgebricksBuiltinFunctions.isComparisonFunction(fi)
            || AsterixBuiltinFunctions.isSimilarityFunction(fi)) {
        for (Mutable<ILogicalExpression> exprRef : fexp.getArguments()) {
            if (exprRef.getValue().getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
                LogicalVariable newVar = context.newVar();
                AssignOperator newAssign = new AssignOperator(newVar,
                        new MutableObject<ILogicalExpression>(exprRef.getValue().cloneExpression()));
                newAssign.setExecutionMode(joinOp.getExecutionMode());

                // Place assign below joinOp.
                List<LogicalVariable> used = new ArrayList<LogicalVariable>();
                VariableUtilities.getUsedVariables(newAssign, used);

                Mutable<ILogicalOperator> leftBranchRef = joinOp.getInputs().get(0);
                ILogicalOperator leftBranch = leftBranchRef.getValue();
                List<LogicalVariable> leftBranchVariables = new ArrayList<LogicalVariable>();
                VariableUtilities.getLiveVariables(leftBranch, leftBranchVariables);
                if (leftBranchVariables.containsAll(used)) {
                    // place assign on left branch
                    newAssign.getInputs().add(new MutableObject<ILogicalOperator>(leftBranch));
                    leftBranchRef.setValue(newAssign);
                    modified = true;
                } else {
                    Mutable<ILogicalOperator> rightBranchRef = joinOp.getInputs().get(1);
                    ILogicalOperator rightBranch = rightBranchRef.getValue();
                    List<LogicalVariable> rightBranchVariables = new ArrayList<LogicalVariable>();
                    VariableUtilities.getLiveVariables(rightBranch, rightBranchVariables);
                    if (rightBranchVariables.containsAll(used)) {
                        // place assign on right branch
                        newAssign.getInputs().add(new MutableObject<ILogicalOperator>(rightBranch));
                        rightBranchRef.setValue(newAssign);
                        modified = true;
                    }
                }

                if (modified) {
                    // Replace original expr with variable reference.
                    exprRef.setValue(new VariableReferenceExpression(newVar));
                    context.computeAndSetTypeEnvironmentForOperator(newAssign);
                    context.computeAndSetTypeEnvironmentForOperator(joinOp);
                }
            }
        }
        return modified;
    } else {
        return false;
    }
}

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

/**
 * Test of getDatasetsList method, of class DatasetService.
 */// www. j  a va  2 s  . c o  m
@Test
public void testGetDatasetsList() {
    System.out.println("getDatasetsList");
    DatasetService instance = INSTANCE.getDatasetService();
    List<Dataset> expResult = new ArrayList<>();
    expResult.add(data1);
    expResult.add(data2);
    List<Dataset> result = instance.getDatasetsList();
    assertTrue(expResult.containsAll(result) && result.containsAll(expResult));
}

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

/**
 * Test of getDepartmentsList method, of class DepartmentService.
 *
 * @throws com.fasterxml.jackson.core.JsonProcessingException
 *///w  ww  .  j a  v a  2  s.  c  om
@Test
public void testGetDepartmentsList() throws JsonProcessingException {
    System.out.println("getDepartmentsList");
    DepartmentService instance = INSTANCE.getDepartmentService();
    compId = INSTANCE.getCompanyService().createCompany(comp);
    dep1.setCompany(compId);
    depId1 = instance.createDepartment(dep1);
    dep2.setCompany(compId);
    depId2 = instance.createDepartment(dep2);

    List<Department> expResult = new ArrayList<>();
    expResult.add(dep1);
    expResult.add(dep2);
    List<Department> result = instance.getDepartmentsList();
    assertTrue(expResult.containsAll(result) && result.containsAll(expResult));

    INSTANCE.getCompanyService().deleteCompany(compId);
    instance.deleteDepartment(depId1);
    instance.deleteDepartment(depId2);
}

From source file:de.blizzy.documentr.web.FunctionsTest.java

@Test
public void listRoles() throws IOException {
    List<String> roles = Lists.newArrayList("role1", "role2", "role3"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    when(userStore.listRoles()).thenReturn(roles);

    List<String> result = Functions.listRoles();
    assertTrue(result.containsAll(roles));
}

From source file:org.apache.hyracks.algebricks.rewriter.rules.ExtractFunctionsFromJoinConditionRule.java

private boolean assignFunctionExpressions(AbstractLogicalOperator joinOp, ILogicalExpression expr,
        IOptimizationContext context) throws AlgebricksException {
    if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }/* www  .ja v a 2 s .  c o m*/
    AbstractFunctionCallExpression fexp = (AbstractFunctionCallExpression) expr;
    FunctionIdentifier fi = fexp.getFunctionIdentifier();

    boolean modified = false;
    if (fi.equals(AlgebricksBuiltinFunctions.AND) || fi.equals(AlgebricksBuiltinFunctions.OR)
            || processArgumentsToFunction(fi)) {
        for (Mutable<ILogicalExpression> a : fexp.getArguments()) {
            if (assignFunctionExpressions(joinOp, a.getValue(), context)) {
                modified = true;
            }
        }
        return modified;
    } else if (AlgebricksBuiltinFunctions.isComparisonFunction(fi) || isComparisonFunction(fi)) {
        for (Mutable<ILogicalExpression> exprRef : fexp.getArguments()) {
            if (exprRef.getValue().getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
                LogicalVariable newVar = context.newVar();
                AssignOperator newAssign = new AssignOperator(newVar,
                        new MutableObject<ILogicalExpression>(exprRef.getValue().cloneExpression()));
                newAssign.setExecutionMode(joinOp.getExecutionMode());

                // Place assign below joinOp.
                List<LogicalVariable> used = new ArrayList<LogicalVariable>();
                VariableUtilities.getUsedVariables(newAssign, used);

                Mutable<ILogicalOperator> leftBranchRef = joinOp.getInputs().get(0);
                ILogicalOperator leftBranch = leftBranchRef.getValue();
                List<LogicalVariable> leftBranchVariables = new ArrayList<LogicalVariable>();
                VariableUtilities.getLiveVariables(leftBranch, leftBranchVariables);
                if (leftBranchVariables.containsAll(used)) {
                    // place assign on left branch
                    newAssign.getInputs().add(new MutableObject<ILogicalOperator>(leftBranch));
                    leftBranchRef.setValue(newAssign);
                    modified = true;
                } else {
                    Mutable<ILogicalOperator> rightBranchRef = joinOp.getInputs().get(1);
                    ILogicalOperator rightBranch = rightBranchRef.getValue();
                    List<LogicalVariable> rightBranchVariables = new ArrayList<LogicalVariable>();
                    VariableUtilities.getLiveVariables(rightBranch, rightBranchVariables);
                    if (rightBranchVariables.containsAll(used)) {
                        // place assign on right branch
                        newAssign.getInputs().add(new MutableObject<ILogicalOperator>(rightBranch));
                        rightBranchRef.setValue(newAssign);
                        modified = true;
                    }
                }

                if (modified) {
                    // Replace original expr with variable reference.
                    exprRef.setValue(new VariableReferenceExpression(newVar));
                    context.computeAndSetTypeEnvironmentForOperator(newAssign);
                    context.computeAndSetTypeEnvironmentForOperator(joinOp);
                }
            }
        }
        return modified;
    } else {
        return false;
    }
}

From source file:com.alibaba.dubbo.util.KetamaNodeLocatorTest.java

@Test
public void testResetNodeList() {
    final int oldSize = 10;
    final List<String> oldNodes = generateRandomStrings(oldSize);
    final long start1 = System.currentTimeMillis();
    final KetamaNodeLocator locator = new KetamaNodeLocator(oldNodes);

    // Make sure the initialization doesn't take too long.
    assertTrue((System.currentTimeMillis() - start1) < 100);

    final List<String> keys = generateRandomStrings(5 + RandomUtils.nextInt(5));

    for (final String key : keys) {
        final List<String> superlist = locator.getPriorityList(key, oldSize);
        assertTrue(superlist.containsAll(oldNodes));
    }// w  w w .  j  a v  a 2  s  .  co  m

    final List<String> newNodes = new ArrayList<String>();
    newNodes.add(oldNodes.get(2) + "-modified-");
    newNodes.add(oldNodes.get(6) + "-modified-");
    newNodes.add(oldNodes.get(9) + "-modified-");
    locator.updateLocator(newNodes);

    for (final String key : keys) {
        final List<String> superlist = locator.getPriorityList(key, oldSize);
        assertTrue(superlist.containsAll(newNodes));
        assertTrue(newNodes.containsAll(superlist));
    }
}

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

/**
 * Test of getAlgorithmsList method, of class AlgorithmService.
 *///ww w  . j av  a 2s.c o m
@Test
public void testGetAlgorithmsList() {
    System.out.println("getAlgorithmsList");
    AlgorithmService instance = new AlgorithmService();
    List<Algorithm> expResult = new ArrayList<>();
    expResult.add(algo1);
    expResult.add(algo2);
    List<Algorithm> result = instance.getAlgorithmsList();
    assertTrue(expResult.containsAll(result) && result.containsAll(expResult));
}

From source file:com.ibm.watson.apis.conversation_with_discovery.rest.ProxyResourceTest.java

/**
 * Test send message./* w w  w  .  java2  s.  c om*/
 *
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws InterruptedException the 4interrupted exception
 */
@Test
public void testSendMessage() throws IOException, InterruptedException {

    String text = "I'd like to get a quote to replace my windows";

    MessageResponse mockResponse = loadFixture(FIXTURE, MessageResponse.class);
    ProxyResource proxy = new ProxyResource();

    proxy.setCredentials("dummy", "dummy", StringUtils.chop(server.url("/").toString()));

    server.enqueue(jsonResponse(mockResponse));

    MessageRequest request = new MessageRequest.Builder().inputText(text).build();
    String payload = GsonSingleton.getGsonWithoutPrettyPrinting().toJson(request, MessageRequest.class);

    InputStream inputStream = new ByteArrayInputStream(payload.getBytes("UTF-8"));

    Response jaxResponse = proxy.postMessage(WORKSPACE_ID, inputStream);
    MessageResponse serviceResponse = GsonSingleton.getGsonWithoutPrettyPrinting()
            .fromJson(jaxResponse.getEntity().toString(), MessageResponse.class);

    RecordedRequest mockRequest = server.takeRequest();
    List<String> serviceText = serviceResponse.getText();
    List<String> mockText = serviceResponse.getText();
    assertNotNull(serviceText);
    assertNotNull(mockText);
    assertTrue(serviceText.containsAll(mockText) && mockText.containsAll(serviceText));
    assertEquals(serviceResponse, mockResponse);
    assertEquals(serviceResponse.getTextConcatenated(" "), mockResponse.getTextConcatenated(" "));

    assertEquals(mockRequest.getMethod(), "POST");
    assertNotNull(mockRequest.getHeader(HttpHeaders.AUTHORIZATION));
}