本文整理了Java中java.util.List.containsAll()
方法的一些代码示例,展示了List.containsAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.containsAll()
方法的具体详情如下:
包路径:java.util.List
类名称:List
方法名:containsAll
[英]Tests whether this List contains all objects contained in the specified collection.
[中]测试此列表是否包含指定集合中包含的所有对象。
代码示例来源:origin: jenkinsci/jenkins
/**
* @deprecated apparently unused
*/
@Deprecated
public boolean hasSame(AbstractProject owner, Collection<? extends AbstractProject> projects) {
List<AbstractProject> children = getChildProjects(owner);
return children.size()==projects.size() && children.containsAll(projects);
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* compares the dirty fields of an entity with a set of expected values
*/
public static void checkDirtyTracking(Object entityInstance, String... dirtyFields) {
SelfDirtinessTracker selfDirtinessTracker = (SelfDirtinessTracker) entityInstance;
assertEquals( dirtyFields.length > 0, selfDirtinessTracker.$$_hibernate_hasDirtyAttributes() );
String[] tracked = selfDirtinessTracker.$$_hibernate_getDirtyAttributes();
assertEquals( dirtyFields.length, tracked.length );
assertTrue( Arrays.asList( tracked ).containsAll( Arrays.asList( dirtyFields ) ) );
}
代码示例来源:origin: apache/kylin
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);
}
if (wantedInfo.size() > 0)
result.put(hostCols, wantedInfo);
}
return result;
}
代码示例来源:origin: jtablesaw/tablesaw
@Test
public void innerJoinInstructorStudentOnAge() {
Table table1 = createINSTRUCTOR();
Table table2 = createSTUDENT();
Table joined = table1.join("Age").inner(true, table2);
assert(joined.columnNames().containsAll(Arrays.asList(
"T2.ID", "T2.City", "T2.State", "T2.USID", "T2.GradYear")));
assertEquals(16, joined.columnCount());
assertEquals(14, joined.rowCount());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testValues() {
assertThat(
Arrays.asList(Letter.values()).containsAll(Arrays.asList(Letter.A, Letter.B, Letter.C)));
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@SuppressWarnings("unchecked")
public ListBodySpec<E> contains(E... elements) {
List<E> expected = Arrays.asList(elements);
List<E> actual = getResult().getResponseBody();
String message = "Response body does not contain " + expected;
getResult().assertWithDiagnostics(() ->
AssertionErrors.assertTrue(message, (actual != null && actual.containsAll(expected))));
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testValues() {
Map<JsonObject, Buffer> map = genJsonToBuffer(100);
loadData(map, (vertx, asyncMap) -> {
asyncMap.values(onSuccess(values -> {
assertEquals(map.values().size(), values.size());
assertTrue(map.values().containsAll(values));
assertTrue(values.containsAll(map.values()));
testComplete();
}));
});
await();
}
代码示例来源:origin: apache/hbase
private void assertArchiveFiles(FileSystem fs, List<String> storeFiles, long timeout)
throws IOException {
long end = System.currentTimeMillis() + timeout;
Path archiveDir = HFileArchiveUtil.getArchivePath(UTIL.getConfiguration());
List<String> archivedFiles = new ArrayList<>();
// We have to ensure that the DeleteTableHandler is finished. HBaseAdmin.deleteXXX()
// can return before all files
// are archived. We should fix HBASE-5487 and fix synchronous operations from admin.
while (System.currentTimeMillis() < end) {
archivedFiles = getAllFileNames(fs, archiveDir);
if (archivedFiles.size() >= storeFiles.size()) {
break;
}
}
Collections.sort(storeFiles);
Collections.sort(archivedFiles);
LOG.debug("Store files:");
for (int i = 0; i < storeFiles.size(); i++) {
LOG.debug(i + " - " + storeFiles.get(i));
}
LOG.debug("Archive files:");
for (int i = 0; i < archivedFiles.size(); i++) {
LOG.debug(i + " - " + archivedFiles.get(i));
}
assertTrue("Archived files are missing some of the store files!",
archivedFiles.containsAll(storeFiles));
}
代码示例来源:origin: apache/geode
@Test
public void testFindAll() {
final List<Integer> numbers = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9);
// accept all even numbers
final List<Integer> matches = CollectionUtils.findAll(numbers, number -> (number % 2 == 0));
assertNotNull(matches);
assertFalse(matches.isEmpty());
assertTrue(matches.containsAll(Arrays.asList(0, 2, 4, 6, 8)));
}
代码示例来源:origin: apache/kylin
@Test
public void createDirectChildrenCacheTest() {
Set<Long> cuboidSet = generateCuboidSet();
Map<Long, List<Long>> directChildrenCache = CuboidStatsUtil.createDirectChildrenCache(cuboidSet);
Assert.assertTrue(directChildrenCache.get(255L).containsAll(Lists.newArrayList(239L, 159L, 50L)));
Assert.assertTrue(directChildrenCache.get(159L).contains(6L));
Assert.assertTrue(directChildrenCache.get(50L).contains(2L));
Assert.assertTrue(directChildrenCache.get(239L).contains(199L));
Assert.assertTrue(directChildrenCache.get(199L).contains(6L));
Assert.assertTrue(directChildrenCache.get(6L).containsAll(Lists.newArrayList(4L, 2L)));
}
代码示例来源:origin: languagetool-org/languagetool
private void testOrderingHappened(Language language, String rule_id) throws IOException {
JLanguageTool languageTool = new JLanguageTool(language);
SuggestionsOrderer suggestionsOrderer = new SuggestionsOrderer(language, rule_id);
String word = "wprd";
String sentence = String.join(" ","a", word, "containing", "sentence");
LinkedList<String> suggestions = new LinkedList<>();
suggestions.add("word");
suggestions.add("weird");
int startPos = sentence.indexOf(word);
int wordLength = word.length();
List<String> suggestionsOrdered = suggestionsOrderer.orderSuggestionsUsingModel(
suggestions, word, languageTool.getAnalyzedSentence(sentence), startPos, wordLength);
assertTrue(suggestionsOrdered.containsAll(suggestions));
}
代码示例来源:origin: apache/kafka
@Test
public void testParseAndValidateAddressesWithReverseLookup() {
checkWithoutLookup("127.0.0.1:8000");
checkWithoutLookup("localhost:8080");
checkWithoutLookup("[::1]:8000");
checkWithoutLookup("[2001:db8:85a3:8d3:1319:8a2e:370:7348]:1234", "localhost:10000");
// With lookup of example.com, either one or two addresses are expected depending on
// whether ipv4 and ipv6 are enabled
List<InetSocketAddress> validatedAddresses = checkWithLookup(Arrays.asList("example.com:10000"));
assertTrue("Unexpected addresses " + validatedAddresses, validatedAddresses.size() >= 1);
List<String> validatedHostNames = validatedAddresses.stream().map(InetSocketAddress::getHostName)
.collect(Collectors.toList());
List<String> expectedHostNames = Arrays.asList("93.184.216.34", "2606:2800:220:1:248:1893:25c8:1946");
assertTrue("Unexpected addresses " + validatedHostNames, expectedHostNames.containsAll(validatedHostNames));
validatedAddresses.forEach(address -> assertEquals(10000, address.getPort()));
}
代码示例来源:origin: google/ExoPlayer
score = updateScoreForMatch(score, targetTag, tag, 2);
score = updateScoreForMatch(score, targetVoice, voice, 4);
if (score == -1 || !Arrays.asList(classes).containsAll(targetClasses)) {
return 0;
} else {
score += targetClasses.size() * 4;
代码示例来源:origin: jtablesaw/tablesaw
@Test
public void innerJoinOnPartiallyMismatchedColNames() {
Table table1 = createANIMALHOMES();
Table table2 = createDOUBLEINDEXEDPEOPLENameDwellingYearsMoveInDate();
Table joined = table1.join("Name", "Home", "Age")
.inner(table2, true,
"Name", "Dwelling", "Years");
assert(joined.columnNames().containsAll(Arrays.asList("Name", "Home", "Age")));
assertEquals(7, joined.columnCount());
assertEquals(2, joined.rowCount());
}
代码示例来源:origin: weibocom/motan
/**
* 判断两个list中的url是否一致。 如果任意一个list为空,则返回false; 此方法并未做严格互相判等
*
* @param urls1
* @param urls2
* @return
*/
public static boolean isSame(List<URL> urls1, List<URL> urls2) {
if (urls1 == null || urls2 == null) {
return false;
}
if (urls1.size() != urls2.size()) {
return false;
}
return urls1.containsAll(urls2);
}
代码示例来源:origin: gocd/gocd
@Test
public void testModificationsSince() throws Exception {
List<Modification> modifications = new ArrayList<>();
modifications.add(new Modification(user, "comment latest", "email", new Date(), "10"));
modifications.add(new Modification(user, "comment latest", "email", new Date(), "9"));
modifications.add(new Modification(user, "comment latest", "email", new Date(), "8"));
when(tfsCommand.history(null, 1)).thenReturn(Arrays.asList(modifications.get(0)));
when(tfsCommand.history("10", 3)).thenReturn(modifications);
List<Modification> actual = tfsCommand.modificationsSince(workDir, new StringRevision("7"));
assertThat(actual.containsAll(modifications), is(true));
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@SuppressWarnings("unchecked")
public ListBodySpec<E> doesNotContain(E... elements) {
List<E> expected = Arrays.asList(elements);
List<E> actual = getResult().getResponseBody();
String message = "Response body should not have contained " + expected;
getResult().assertWithDiagnostics(() ->
AssertionErrors.assertTrue(message, (actual == null || !actual.containsAll(expected))));
return this;
}
代码示例来源:origin: azkaban/azkaban
@Test
public void testEnqueueAll() throws IOException, ExecutorManagerException {
final QueuedExecutions queue = new QueuedExecutions(5);
final List<Pair<ExecutionReference, ExecutableFlow>> dataList = getDummyData();
queue.enqueueAll(dataList);
Assert.assertTrue(queue.getAllEntries().containsAll(dataList));
Assert.assertTrue(dataList.containsAll(queue.getAllEntries()));
}
代码示例来源:origin: apache/hive
private static void verifyPartitionsPublished(HiveMetaStoreClient client,
String dbName, String tblName, List<String> partialSpec,
List<Partition> expectedPartitions) throws TException {
// Test partition listing with a partial spec
List<Partition> mpartial = client.listPartitions(dbName, tblName, partialSpec,
(short) -1);
assertEquals("Should have returned "+expectedPartitions.size()+
" partitions, returned " + mpartial.size(),
expectedPartitions.size(), mpartial.size());
assertTrue("Not all parts returned", mpartial.containsAll(expectedPartitions));
}
代码示例来源:origin: ReactiveX/RxNetty
public void assertMethodsCalled(ClientEvent... events) {
if (methodsCalled.size() != events.length) {
throw new AssertionError("Unexpected methods called count. Methods called: " + methodsCalled.size()
+ ". Expected: " + events.length);
}
if (!methodsCalled.containsAll(Arrays.asList(events))) {
throw new AssertionError("Unexpected methods called count. Methods called: " + methodsCalled
+ ". Expected: " + Arrays.toString(events));
}
}
内容来源于网络,如有侵权,请联系作者删除!