Java Code Examples for java.util.List.containsAll()

The following are Jave code examples for showing how to use containsAll() of the java.util.List class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: ProvidesTest.java   View Source Code Vote up 6 votes
@Test
public void testDuplicateImplementations2(Path base) throws Exception {
    Path src = base.resolve("src");
    tb.writeJavaFiles(src,
            "module m { exports p1; provides p1.C1 with p2.C2; provides p1.C1 with p2.C2; }",
            "package p1; public class C1 { }",
            "package p2; public class C2 extends p1.C1 { }");
    Path classes = base.resolve("classes");
    Files.createDirectories(classes);

    List<String> output = new JavacTask(tb)
            .options("-XDrawDiagnostics")
            .outdir(classes)
            .files(findJavaFiles(src))
            .run(Task.Expect.FAIL)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);

    List<String> expected = Arrays.asList(
            "module-info.java:1:62: compiler.err.repeated.provides.for.service: p1.C1",
            "module-info.java:1:73: compiler.err.duplicate.provides: p1.C1, p2.C2",
            "2 errors");
    if (!output.containsAll(expected)) {
        throw new Exception("Expected output not found");
    }
}
 
Example 2
Project: Pogamut3   File: AStarHeap.java   View Source Code Vote up 6 votes
public static boolean mainCheck(AStarHeap heap, Integer[] nums){
	System.out.println("Removing and checking " + mainToStr(nums));
	List heapInts = new ArrayList();
	List desiredInts = new ArrayList();
	for (int i = 0; i < nums.length; ++i){
		desiredInts.add(nums[i]);
		heapInts.add(heap.getMin());
		heap.deleteMin();
	}
	if ( heapInts.containsAll(desiredInts) ){
		System.out.println("OK");
		return true;
	} else {
		System.out.println("KO!");
		System.exit(1);
	}
	return false;
}
 
Example 3
Project: openjdk-jdk10   File: ProvidesTest.java   View Source Code Vote up 6 votes
@Test
public void testNoNoArgConstructor(Path base) throws Exception {
    Path src = base.resolve("src");
    tb.writeJavaFiles(src,
            "module m { uses p1.C1; provides p1.C1 with p2.C2; }",
            "package p1; public class C1 { }",
            "package p2; public class C2 extends p1.C1 { public C2(String str) { } }");

    List<String> output = new JavacTask(tb)
            .options("-XDrawDiagnostics")
            .outdir(Files.createDirectories(base.resolve("classes")))
            .files(findJavaFiles(src))
            .run(Task.Expect.FAIL)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);

    List<String> expected = Arrays.asList(
            "module-info.java:1:46: compiler.err.service.implementation.doesnt.have.a.no.args.constructor: p2.C2");
    if (!output.containsAll(expected)) {
        throw new Exception("Expected output not found");
    }
}
 
Example 4
Project: openjdk-jdk10   File: UsesTest.java   View Source Code Vote up 6 votes
@Test
public void testDuplicateUses(Path base) throws Exception {
    Path src = base.resolve("src");
    tb.writeJavaFiles(src.resolve("m"),
            "module m { uses p.C; uses p.C; }",
            "package p; public class C { }");

    List<String> output = new JavacTask(tb)
            .options("-XDrawDiagnostics")
            .outdir(Files.createDirectories(base.resolve("classes")))
            .files(findJavaFiles(src))
            .run(Task.Expect.FAIL)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);

    if (!output.containsAll(Arrays.asList(
            "module-info.java:1:22: compiler.err.duplicate.uses: p.C"))) {
        throw new Exception("Expected output not found");
    }
}
 
Example 5
Project: openjdk-jdk10   File: ProvidesTest.java   View Source Code Vote up 6 votes
@Test
public void testMissingService(Path base) throws Exception {
    Path src = base.resolve("src");
    tb.writeJavaFiles(src,
            "module m { provides p.Missing with p.C; }",
            "package p; public class C extends p.Missing { }");

    List<String> output = new JavacTask(tb)
            .options("-XDrawDiagnostics")
            .outdir(Files.createDirectories(base.resolve("classes")))
            .files(findJavaFiles(src))
            .run(Task.Expect.FAIL)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);

    List<String> expected = Arrays.asList(
            "C.java:1:36: compiler.err.cant.resolve.location: kindname.class, Missing, , , (compiler.misc.location: kindname.package, p, null)",
            "module-info.java:1:22: compiler.err.cant.resolve.location: kindname.class, Missing, , , (compiler.misc.location: kindname.package, p, null)",
            "2 errors");
    if (!output.containsAll(expected)) {
        throw new Exception("Expected output not found");
    }
}
 
Example 6
Project: boohee_v5.6   File: FragmentTransitionCompat21.java   View Source Code Vote up 6 votes
public static void removeTargets(Object transitionObject, ArrayList<View> views) {
    Transition transition = (Transition) transitionObject;
    int i;
    if (transition instanceof TransitionSet) {
        TransitionSet set = (TransitionSet) transition;
        int numTransitions = set.getTransitionCount();
        for (i = 0; i < numTransitions; i++) {
            removeTargets(set.getTransitionAt(i), views);
        }
    } else if (!hasSimpleTarget(transition)) {
        List<View> targets = transition.getTargets();
        if (targets != null && targets.size() == views.size() && targets.containsAll(views)) {
            for (i = views.size() - 1; i >= 0; i--) {
                transition.removeTarget((View) views.get(i));
            }
        }
    }
}
 
Example 7
Project: Squid   File: SquidSessionModel.java   View Source Code Vote up 5 votes
public boolean updateFields(
        List<SquidSpeciesModel> squidSpeciesSpecsList,
        List<SquidRatiosModel> squidRatiosSpecsList,
        boolean useSBM, boolean userLinFits,
        int indexOfBackgroundSpecies,
        String referenceMaterialNameFilter,
        String concentrationReferenceMaterialNameFilter) {

    boolean retVal = false;

    retVal = !(this.squidSpeciesModelList.containsAll(squidSpeciesSpecsList) && squidSpeciesSpecsList.containsAll(this.squidSpeciesModelList));
    if (!retVal) {
        retVal = !(this.squidRatiosModelList.containsAll(squidRatiosSpecsList) && squidRatiosSpecsList.containsAll(this.squidRatiosModelList));
    }
    if (!retVal) {
        retVal = !(this.useSBM == useSBM);
    }
    if (!retVal) {
        retVal = !(this.userLinFits == userLinFits);
    }
    if (!retVal) {
        retVal = !(this.indexOfBackgroundSpecies == indexOfBackgroundSpecies);
    }
    if (!retVal) {
        retVal = !(this.referenceMaterialNameFilter.compareToIgnoreCase(referenceMaterialNameFilter) == 0);
    }
    if (!retVal) {
        retVal = !(this.concentrationReferenceMaterialNameFilter.compareToIgnoreCase(concentrationReferenceMaterialNameFilter) == 0);
    }

    return retVal;
}
 
Example 8
Project: my-spring-boot-project   File: SysRoleServiceImpl.java   View Source Code Vote up 5 votes
/**
 * 检查权限是否越权
 */
private void checkPrems(SysRoleEntity role) {
    //如果不是超级管理员,则需要判断角色的权限是否超过自己的权限
    if (role.getCreateUserId() == Constant.SUPER_ADMIN) {
        return;
    }

    //查询用户所拥有的菜单列表
    List<Long> menuIdList = sysUserService.queryAllMenuId(role.getCreateUserId());

    //判断是否越权
    if (!menuIdList.containsAll(role.getMenuIdList())) {
        throw new RRException("新增角色的权限,已超出你的权限范围");
    }
}
 
Example 9
Project: jdk8u-jdk   File: LoggingMXBeanTest.java   View Source Code Vote up 5 votes
private static void checkAttributes(LoggingMXBean mxbean1,
                                    PlatformLoggingMXBean mxbean2) {
    // verify logger names
    List<String> loggers1 = mxbean1.getLoggerNames();
    System.out.println("Loggers: " + loggers1);

    // Retrieve the named loggers to prevent them from being
    // spontaneously gc'ed.
    Map<String, Logger> loggersMap = new HashMap<>();
    for (String n : loggers1) {
        loggersMap.put(n, Logger.getLogger(n));
    }

    List<String> loggers2 = mxbean2.getLoggerNames();

    // loggers1 and loggers2 should be identical - no new logger should
    // have been created in between (at least no new logger name)
    //
    if (loggers1.size() != loggers2.size())
        throw new RuntimeException("LoggerNames: unmatched number of entries");
    if (!loggers2.containsAll(loggersMap.keySet()))
        throw new RuntimeException("LoggerNames: unmatched loggers");


    // verify logger's level  and parent
    for (String logger : loggers1) {
        String level1 = mxbean1.getLoggerLevel(logger);
        String level2 = mxbean2.getLoggerLevel(logger);
        if (!java.util.Objects.equals(level1, level2)) {
            throw new RuntimeException(
                    "LoggerLevel: unmatched level for " + logger
                    + ", " + level1 + ", " + level2);
        }

        if (!mxbean1.getParentLoggerName(logger)
                .equals(mxbean2.getParentLoggerName(logger)))
            throw new RuntimeException(
                "ParentLoggerName: unmatched parent logger's name for " + logger);
    }
}
 
Example 10
Project: openjdk-jdk10   File: ElementRepAnnoTester.java   View Source Code Vote up 5 votes
private boolean compareArrVals(Annotation[] actualAnnos, String[] expectedAnnos) {
    // Look if test case was run.
    if (actualAnnos == specialAnnoArray) {
        return false; // no testcase matches
    }
    if (actualAnnos.length != expectedAnnos.length) {
        System.out.println("Length not same. "
                + " actualAnnos length = " + actualAnnos.length
                + " expectedAnnos length = " + expectedAnnos.length);
        printArrContents(actualAnnos);
        printArrContents(expectedAnnos);
        return false;
    } else {
        int i = 0;
        String[] actualArr = new String[actualAnnos.length];
        for (Annotation a : actualAnnos) {
            actualArr[i++] = a.toString();
        }
        List<String> actualList = Arrays.asList(actualArr);
        List<String> expectedList = Arrays.asList(expectedAnnos);

        if (!actualList.containsAll(expectedList)) {
            System.out.println("Array values are not same");
            printArrContents(actualAnnos);
            printArrContents(expectedAnnos);
            return false;
        }
    }
    return true;
}
 
Example 11
Project: neural-algorithms   File: KMeans.java   View Source Code Vote up 5 votes
public void calc(boolean plot, String gptCols, String plotFile) {
	if (plot) {
		FileHandler.writeMatrixWithId(neurons, destDir + neuronsFile, separator);
		FileHandler.appendColumn(srcFilePath, destDir + destFile, separator, winnerIds);
		String cmd = "gnuplot -c " + System.getProperty("user.dir") + "/" + plotFile + " " + gptCols;
		Utils.rumCmd(cmd);
	}

	List<List<Double>> prevDataPoints = new ArrayList<List<Double>>();
	for (int i = 0; i < iterations; i++) {
		prevDataPoints = neurons;
		calcWinnersIds();
		learn(i);

		if (plot) {
			FileHandler.writeMatrixWithId(neurons, destDir + neuronsFile, separator);
			FileHandler.appendColumn(srcFilePath, destDir + destFile, separator, winnerIds);
		}

		if (prevDataPoints.containsAll(neurons) && neurons.containsAll(prevDataPoints)) {
			break;
		}

		System.out.println(i);
	}

	FileHandler.writePointsAsClusters(winnerIds, neurons, destDir + imgcprFile, separator);
}
 
Example 12
Project: openjdk-jdk10   File: ServiceProvidedButNotExportedOrUsedTest.java   View Source Code Vote up 5 votes
@Test
public void testImplementationMustBeInSameModuleAsProvidesDirective(Path base) throws Exception {
    Path src = base.resolve("src");
    tb.writeJavaFiles(src.resolve("m1x"),
            "module m1x { exports p1; }",
            "package p1; public class C1 { }");
    tb.writeJavaFiles(src.resolve("m2x"),
            "module m2x { requires m1x; requires m3x; provides p1.C1 with p2.C2; }");
    tb.writeJavaFiles(src.resolve("m3x"),
            "module m3x { requires m1x; exports p2; }",
            "package p2; public class C2 extends p1.C1 { }");
    Path modules = base.resolve("modules");
    Files.createDirectories(modules);

    List<String> output = new JavacTask(tb)
            .options("-XDrawDiagnostics", "--module-source-path", src.toString())
            .outdir(modules)
            .files(findJavaFiles(src))
            .run(Task.Expect.FAIL)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);
    List<String> expected = Arrays.asList(
            "module-info.java:1:42: compiler.err.service.implementation.not.in.right.module: m3x",
            "1 error");
    if (!output.containsAll(expected)) {
        throw new Exception("Expected output not found");
    }
}
 
Example 13
Project: openjdk-jdk10   File: DefineClass.java   View Source Code Vote up 5 votes
private static void checkPerms(List<Permission> perms,
                               Permission... grantedPerms)
    throws Exception
{
    if (!perms.containsAll(Arrays.asList(grantedPerms))) {
        throw new Exception("Granted permissions not correct");
    }
}
 
Example 14
Project: incubator-netbeans   File: WSIAPValidator.java   View Source Code Vote up 4 votes
public void testAP2941(Binding binding,
            BindingOperation bindingOperation,
            BindingInput bindingInput,
            BindingOutput bindingOutput,
            Input portTypeInput,
            Output portTypeOutput) {


        if (portTypeInput != null && portTypeInput.getMessage() != null) {
            // Getting the list of all the parts bound by wsdl:input's child elements
            List inputParts = getBindingParts_AP2941(
                    bindingOperation.getBindingInput().getExtensibilityElements(),
                    (Message) portTypeInput.getMessage().get());
      
            if (!inputParts.containsAll(getPartNames(((Message) portTypeInput.getMessage().get()).getParts()))) {
                mResults.add(new Validator.ResultItem(mValidator,
                        Validator.ResultType.ERROR,
                        bindingInput,
                        NbBundle.getMessage(WSIAPValidator.class, "AP2941")));
       

            }
        }

        // If the corresponding wsdl:output exists in wsdl:portType
        // and includes the message attribute
        if (portTypeOutput != null && portTypeOutput.getMessage() != null) {
            // Getting the list of all the parts bound by wsdl:output's child elements
            List outputParts = getBindingParts_AP2941(
                    bindingOperation.getBindingOutput().getExtensibilityElements(),
                    (Message) portTypeOutput.getMessage().get());

            if (!outputParts.containsAll(getPartNames(((Message) portTypeOutput.getMessage().get()).getParts()))) {
                mResults.add(new Validator.ResultItem(mValidator,
                        Validator.ResultType.ERROR,
                        bindingOutput,
                        NbBundle.getMessage(WSIAPValidator.class, "AP2941")));
                       
            }
        }

        //this logic doesn't seem right due to the fault names or part names
      
//        if (!((Operation) bindingOperation.getOperation().get()).getFaults().isEmpty()) {
//            // Collecting all the soap:fault names
//            List faultNames = new ArrayList();
//            Collection faults = bindingOperation.getBindingFaults();
//            // Going through all the wsdl:faultS
//            Iterator it = faults.iterator();
//            while (it.hasNext()) {
//                // Getting wsdl:fault's extensibility elements
//                List extElems = ((BindingFault) it.next()).getExtensibilityElements();
//                for (int j = 0; j < extElems.size(); j++) {
//                    if (extElems.get(j) instanceof SOAPFault) {
//                        faultNames.add(((SOAPFault) extElems.get(j)).getName());
//                    }
//                }
//            }
//            //soap:fault + soap:headerfault
//            Collection <ExtensibilityElement> extEles = new ArrayList<ExtensibilityElement>();
//            extEles.addAll(bindingOperation.getBindingInput().getExtensibilityElements());
//            extEles.addAll(bindingOperation.getBindingOutput().getExtensibilityElements());
//            faultNames.addAll(findAllHeaderFaults(extEles));
//
//            // If not true that all the wsdl:faultS are bound,
//            // the assertion failed
//            if (!faultNames.containsAll(getFaultNames(((Operation) bindingOperation.getOperation().get()).getFaults()))) {
//                mResults.add(new Validator.ResultItem(mValidator,
//                        Validator.ResultType.ERROR,
//                        bindingOperation,
//                        //NbBundle.getMessage(WSIAPValidator.class, "AP2901")));
//                        "AP2941"));

//            }
//        }

    }
 
Example 15
Project: incubator-netbeans   File: DBTable.java   View Source Code Vote up 4 votes
@Override
public boolean equals(Object obj) {
    boolean result = false;

    // Check for reflexivity first.
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof DBTable)) {
        return false;
    }

    result = super.equals(obj);

    if (!result) {
        return result;
    }

    // Check for castability (also deals with null obj)
    if (obj instanceof DBTable) {
        DBTable aTable = (DBTable) obj;
        String aTableName = aTable.getName();
        Map<String, DBColumn> aTableColumns = aTable.getColumns();
        DBPrimaryKey aTablePK = aTable.primaryKey;
        List<DBForeignKey> aTableFKs = aTable.getForeignKeys();

        result &= (aTableName != null && name != null && name.equals(aTableName));
        if (columns != null && aTableColumns != null) {
            Set<String> objCols = aTableColumns.keySet();
            Set<String> myCols = columns.keySet();

            // Must be identical (no subsetting), hence the pair of tests.
            result &= myCols.containsAll(objCols) && objCols.containsAll(myCols);
        } else if (!(columns == null && aTableColumns == null)) {
            result = false;
        }

        result &= (primaryKey != null) ? primaryKey.equals(aTablePK) : aTablePK == null;
        if (foreignKeys != null && aTableFKs != null) {
            Collection<DBForeignKey> myFKs = foreignKeys.values();
            // Must be identical (no subsetting), hence the pair of tests.
            result &= myFKs.containsAll(aTableFKs) && aTableFKs.containsAll(myFKs);
        } else if (!(foreignKeys == null && aTableFKs == null)) {
            result = false;
        }
    }
    return result;
}
 
Example 16
Project: smart-testing   File: SmartTestingProviderTest.java   View Source Code Vote up 4 votes
private boolean iterableContains(Iterable<Class> iterable, Set expectedClasses) {
    List<Class> actualCall = StreamSupport.stream(iterable.spliterator(), false).collect(Collectors.toList());
    return actualCall.size() == expectedClasses.size() && actualCall.containsAll(expectedClasses);
}
 
Example 17
Project: JavaGraph   File: Predicate_node_self_edges.java   View Source Code Vote up 4 votes
/**
 * Check if this is a valid list
 */
protected boolean isValidList(List<String> testSet, List<String> curSet) {
    return curSet.containsAll(testSet);
}
 
Example 18
Project: openjdk-jdk10   File: ReflectionTest.java   View Source Code Vote up 4 votes
private static boolean compareAnnotations(Annotation[] actualAnnos,
        String[] expectedAnnos) {
    boolean compOrder = false;

    // Length is different
    if (actualAnnos.length != expectedAnnos.length) {
        error("Length not same, Actual length = " + actualAnnos.length
                + " Expected length = " + expectedAnnos.length);
        printArrContents(actualAnnos);
        printArrContents(expectedAnnos);
        return false;
    } else {
        int i = 0;
        // Length is same and 0
        if (actualAnnos.length == 0) {
            // Expected/actual lengths already checked for
            // equality; no more checks do to
            return true;
        }
        // Expected annotation should be NULL
        if (actualAnnos[0] == null) {
            if (expectedAnnos[0].equals("NULL")) {
                debugPrint("Arr values are NULL as expected");
                return true;
            } else {
                error("Array values are not NULL");
                printArrContents(actualAnnos);
                printArrContents(expectedAnnos);
                return false;
            }
        }
        // Lengths are same, compare array contents
        String[] actualArr = new String[actualAnnos.length];
        for (Annotation a : actualAnnos) {
            if (a.annotationType().getSimpleName().contains("Expected"))
            actualArr[i++] = a.annotationType().getSimpleName();
             else if (a.annotationType().getName().contains(TESTPKG)) {
                String replaced = a.toString().replaceAll(Pattern.quote("testpkg."),"");
                actualArr[i++] = replaced;
            } else
                actualArr[i++] = a.toString();
        }
        List<String> actualList = new ArrayList<String>(Arrays.asList(actualArr));
        List<String> expectedList = new ArrayList<String>(Arrays.asList(expectedAnnos));
        if (!actualList.containsAll(expectedList)) {
            error("Array values are not same");
            printArrContents(actualAnnos);
            printArrContents(expectedAnnos);
            return false;
        } else {
            debugPrint("Arr values are same as expected");
            if (CHECKORDERING) {
                debugPrint("Checking if annotation ordering is as expected..");
                compOrder = compareOrdering(actualList, expectedList);
                if (compOrder)
                    debugPrint("Arr values ordering is as expected");
                else
                    error("Arr values ordering is not as expected! actual values: "
                        + actualList + " expected values: " + expectedList);
            } else
                compOrder = true;
        }
    }
    return compOrder;
}
 
Example 19
Project: amigo-chatbot   File: MessageProcessorJob.java   View Source Code Vote up 4 votes
private static boolean checkMessage(List<String> intent, List<String> userMessage) {
    if (userMessage.containsAll(intent)) {
        return true;
    }
    return false;
}
 
Example 20
Project: rocketmq-rocketmq-all-4.1.0-incubating   File: AllocateMessageQueueConsitentHashTest.java   View Source Code Vote up 4 votes
private boolean verifyAllocateAll(List<String> cidAll,List<MessageQueue> mqAll, List<MessageQueue> allocatedResAll) {
    if (cidAll.isEmpty()){
        return allocatedResAll.isEmpty();
    }
    return mqAll.containsAll(allocatedResAll) && allocatedResAll.containsAll(mqAll);
}