List of usage examples for java.util List containsAll
boolean containsAll(Collection<?> c);
From source file:org.xlcloud.service.transformer.VcDefinitionTransformerTest.java
private void assertTags(List<String> expList, List<String> actList) { assertEquals(expList.size(), actList.size()); assertTrue(expList.containsAll(actList)); }
From source file:org.mitre.oauth2.introspectingfilter.service.impl.TestScopeBasedIntrospectionAuthoritiesGranter.java
/** * Test method for {@link org.mitre.oauth2.introspectingfilter.service.impl.ScopeBasedIntrospectionAuthoritiesGranter#getAuthorities(com.google.gson.JsonObject)}. *//* w w w . ja v a 2s . com*/ @Test public void testGetAuthoritiesJsonObject_withoutScopes() { List<GrantedAuthority> expected = new ArrayList<>(); expected.add(new SimpleGrantedAuthority("ROLE_API")); List<GrantedAuthority> authorities = granter.getAuthorities(introspectionResponse); assertTrue(authorities.containsAll(expected)); assertTrue(expected.containsAll(authorities)); }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.util.JoinUtils.java
private static BroadcastSide getBroadcastJoinSide(ILogicalExpression e, List<LogicalVariable> varsLeft, List<LogicalVariable> varsRight) { if (e.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return null; }//from w w w. j a va2 s. co m AbstractFunctionCallExpression fexp = (AbstractFunctionCallExpression) e; IExpressionAnnotation ann = fexp.getAnnotations() .get(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY); if (ann == null) { return null; } BroadcastSide side = (BroadcastSide) ann.getObject(); if (side == null) { return null; } int i; switch (side) { case LEFT: i = 0; break; case RIGHT: i = 1; break; default: return null; } ArrayList<LogicalVariable> vars = new ArrayList<LogicalVariable>(); fexp.getArguments().get(i).getValue().getUsedVariables(vars); if (varsLeft.containsAll(vars)) { return BroadcastSide.LEFT; } else if (varsRight.containsAll(vars)) { return BroadcastSide.RIGHT; } else { return null; } }
From source file:org.mitre.oauth2.introspectingfilter.service.impl.TestScopeBasedIntrospectionAuthoritiesGranter.java
/** * Test method for {@link org.mitre.oauth2.introspectingfilter.service.impl.ScopeBasedIntrospectionAuthoritiesGranter#getAuthorities(com.google.gson.JsonObject)}. */// w ww . j a va 2s. c om @Test public void testGetAuthoritiesJsonObject_withScopes() { introspectionResponse.addProperty("scope", "foo bar baz batman"); List<GrantedAuthority> expected = new ArrayList<>(); expected.add(new SimpleGrantedAuthority("ROLE_API")); expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_foo")); expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_bar")); expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_baz")); expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_batman")); List<GrantedAuthority> authorities = granter.getAuthorities(introspectionResponse); assertTrue(authorities.containsAll(expected)); assertTrue(expected.containsAll(authorities)); }
From source file:com.fns.grivet.service.NamedQueryServiceSelectTest.java
@Test public void testCreateThenGetHappyPath() throws IOException { Resource r = resolver.getResource("classpath:TestSelectQuery.json"); String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset()); NamedQuery namedQuery = objectMapper.readValue(json, NamedQuery.class); namedQueryService.create(namedQuery); MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); params.add("createdTime", LocalDateTime.now().plusDays(1).toString()); String result = namedQueryService.get("getAttributesCreatedBefore", params); String[] expected = { "bigint", "varchar", "decimal", "datetime", "int", "text", "json", "boolean" }; List<String> actual = JsonPath.given(result).getList("name"); Assertions.assertTrue(actual.containsAll(Arrays.asList(expected))); }
From source file:ezbake.persist.TestFilePersist.java
@Test public void testall() { List<Map<String, String>> expected = new ArrayList<Map<String, String>>(); Map<String, String> expectedRow1 = new TreeMap<String, String>(); expectedRow1.put("test:None:None", "1"); expectedRow1.put("test:colf:None", "2"); expectedRow1.put("test:colf:colq", "3"); Map<String, String> expectedRow2 = new TreeMap<String, String>(); expectedRow2.put("test2:None:None", "1"); expectedRow2.put("test2:colf:None", "2"); expectedRow2.put("test2:colf:colq", "3"); expected.add(expectedRow1);//w w w .j a va 2 s . c o m expected.add(expectedRow2); List<Map<String, String>> vals = persist.all(); Assert.assertTrue(vals.containsAll(expected)); Assert.assertTrue(expected.containsAll(vals)); }
From source file:sh.scrap.scrapper.functions.StringFunctionFactory.java
private Method findMethod(Class<?> targetClass, String methodName, Object mainArgument, Map<String, Object> annotations) { if (mainArgument == null) return MethodUtils.getMatchingAccessibleMethod(targetClass, methodName, String.class); else if (annotations.size() == 0) return MethodUtils.getMatchingAccessibleMethod(targetClass, methodName, String.class, mainArgument.getClass()); Method candidate = null;/*from w w w .ja v a 2 s. c o m*/ for (Method method : targetClass.getMethods()) if (method.getName().equals(methodName)) { candidate = method; String[] names = discoverer.getParameterNames(method); if (names.length > 2) { annotations.put(names[1], mainArgument); List<String> paramNames = Arrays.asList(names); if (paramNames.containsAll(annotations.keySet()) && annotations.keySet().contains(paramNames)) return candidate; } else return candidate; } if (candidate == null) throw new IllegalArgumentException("Unknown function [" + methodName + "]"); return candidate; }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.PushAssignDownThroughProductRule.java
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue(); if (op1.getOperatorTag() != LogicalOperatorTag.ASSIGN) { return false; }//from w w w. ja v a 2s . c o m Mutable<ILogicalOperator> op2Ref = op1.getInputs().get(0); AbstractLogicalOperator op2 = (AbstractLogicalOperator) op2Ref.getValue(); if (op2.getOperatorTag() != LogicalOperatorTag.INNERJOIN) { return false; } AbstractBinaryJoinOperator join = (AbstractBinaryJoinOperator) op2; if (join.getCondition().getValue() != ConstantExpression.TRUE) { return false; } List<LogicalVariable> used = new ArrayList<LogicalVariable>(); VariableUtilities.getUsedVariables(op1, used); Mutable<ILogicalOperator> b0Ref = op2.getInputs().get(0); ILogicalOperator b0 = b0Ref.getValue(); List<LogicalVariable> b0Scm = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(b0, b0Scm); if (b0Scm.containsAll(used)) { // push assign on left branch op2Ref.setValue(b0); b0Ref.setValue(op1); opRef.setValue(op2); return true; } else { Mutable<ILogicalOperator> b1Ref = op2.getInputs().get(1); ILogicalOperator b1 = b1Ref.getValue(); List<LogicalVariable> b1Scm = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(b1, b1Scm); if (b1Scm.containsAll(used)) { // push assign on right branch op2Ref.setValue(b1); b1Ref.setValue(op1); opRef.setValue(op2); return true; } else { return false; } } }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.PushMapOperatorDownThroughProductRule.java
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue(); if (!op1.isMap()) { return false; }//w w w.j a v a 2s.c o m Mutable<ILogicalOperator> op2Ref = op1.getInputs().get(0); AbstractLogicalOperator op2 = (AbstractLogicalOperator) op2Ref.getValue(); if (op2.getOperatorTag() != LogicalOperatorTag.INNERJOIN) { return false; } AbstractBinaryJoinOperator join = (AbstractBinaryJoinOperator) op2; if (!OperatorPropertiesUtil.isAlwaysTrueCond(join.getCondition().getValue())) { return false; } List<LogicalVariable> used = new ArrayList<LogicalVariable>(); VariableUtilities.getUsedVariables(op1, used); Mutable<ILogicalOperator> b0Ref = op2.getInputs().get(0); ILogicalOperator b0 = b0Ref.getValue(); List<LogicalVariable> b0Scm = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(b0, b0Scm); if (b0Scm.containsAll(used)) { // push operator on left branch op2Ref.setValue(b0); b0Ref.setValue(op1); opRef.setValue(op2); return true; } else { Mutable<ILogicalOperator> b1Ref = op2.getInputs().get(1); ILogicalOperator b1 = b1Ref.getValue(); List<LogicalVariable> b1Scm = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(b1, b1Scm); if (b1Scm.containsAll(used)) { // push operator on right branch op2Ref.setValue(b1); b1Ref.setValue(op1); opRef.setValue(op2); return true; } else { return false; } } }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.PushUnnestDownThroughProductRule.java
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue(); if (op1.getOperatorTag() != LogicalOperatorTag.UNNEST) { return false; }// w ww. jav a 2 s . c o m Mutable<ILogicalOperator> op2Ref = op1.getInputs().get(0); AbstractLogicalOperator op2 = (AbstractLogicalOperator) op2Ref.getValue(); if (op2.getOperatorTag() != LogicalOperatorTag.INNERJOIN) { return false; } AbstractBinaryJoinOperator join = (AbstractBinaryJoinOperator) op2; if (join.getCondition().getValue() != ConstantExpression.TRUE) { return false; } List<LogicalVariable> used = new ArrayList<LogicalVariable>(); VariableUtilities.getUsedVariables(op1, used); Mutable<ILogicalOperator> b0Ref = op2.getInputs().get(0); ILogicalOperator b0 = b0Ref.getValue(); List<LogicalVariable> b0Scm = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(b0, b0Scm); if (b0Scm.containsAll(used)) { // push unnest on left branch op2Ref.setValue(b0); b0Ref.setValue(op1); opRef.setValue(op2); return true; } else { Mutable<ILogicalOperator> b1Ref = op2.getInputs().get(1); ILogicalOperator b1 = b1Ref.getValue(); List<LogicalVariable> b1Scm = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(b1, b1Scm); if (b1Scm.containsAll(used)) { // push unnest on right branch op2Ref.setValue(b1); b1Ref.setValue(op1); opRef.setValue(op2); return true; } else { return false; } } }