本文整理了Java中org.assertj.core.api.IterableAssert.as()
方法的一些代码示例,展示了IterableAssert.as()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IterableAssert.as()
方法的具体详情如下:
包路径:org.assertj.core.api.IterableAssert
类名称:IterableAssert
方法名:as
暂无
代码示例来源:origin: stagemonitor/stagemonitor
private void validateSpanJson(JsonNode spanJson) {
assertThat(spanJson.get("error").booleanValue()).as(spanJson.toString()).isFalse();
assertThat(spanJson.get("foo.bar").asText()).as(spanJson.toString()).isEqualTo("baz");
assertThat(spanJson.get("parameters")).as(spanJson.toString()).isNotNull();
assertThat(spanJson.get("parameters").size()).as(spanJson.toString()).isEqualTo(3);
assertThat(spanJson.get("parameters").get(0).get("key")).as(spanJson.toString()).isNotNull();
assertThat(spanJson.get("parameters").get(0).get("value")).as(spanJson.toString()).isNotNull();
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test
public void reportSpan() throws Exception {
reporter.report(mock(SpanContextInformation.class), getSpan(100));
elasticsearchClient.waitForCompletion();
refresh();
final JsonNode hits = elasticsearchClient.getJson("/stagemonitor-spans*/_search").get("hits");
assertThat(hits.get("total").intValue()).as(hits.toString()).isEqualTo(1);
final JsonNode spanJson = hits.get("hits").elements().next().get("_source");
assertThat(spanJson.get("type").asText()).as(spanJson.toString()).isEqualTo("jdbc");
assertThat(spanJson.get("method").asText()).as(spanJson.toString()).isEqualTo("SELECT");
assertThat(spanJson.get("db.statement")).as(spanJson.toString()).isNotNull();
assertThat(spanJson.get("db.statement").asText()).as(spanJson.toString()).isEqualTo("SELECT * from STAGEMONITOR where 1 < 2");
assertThat(spanJson.get("duration_ms").asInt()).as(spanJson.toString()).isEqualTo(100);
assertThat(spanJson.get("name").asText()).as(spanJson.toString()).isEqualTo("ElasticsearchExternalSpanReporterIntegrationTest#test");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void tuplesOfDifferentLengthAreNotEqual() {
Tuple3<String, Long, Integer> t3 = Tuples.of("string", 1L, 10);
Tuple2<String, Long> t2 = Tuples.of("string", 1L);
assertThat(t3).as("Tuples of different length are not equal.").isNotEqualTo(t2);
assertThat(t2).as("Tuples of different length are not equal.").isNotEqualTo(t3);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void tupleProvidesTupleTypeHierarchy() {
Tuple3<String, Long, Integer> t3 = Tuples.of("string", 1L, 10);
assertThat(t3).as("Tuple3 is also a Tuple2").isInstanceOf(Tuple2.class);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void tupleNotEquals() {
Tuple2<String, String> t2a = Tuples.of("ALPHA", "BRAVO");
Tuple2<String, String> t2b = Tuples.of("ALPHA", "CHARLIE");
assertThat(t2a).as("Tuples of same length and values are not equal.").isNotEqualTo(t2b);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void tupleEquals() {
Tuple3<String, Long, Integer> t3a = Tuples.of("string", 1L, 10);
Tuple3<String, Long, Integer> t3b = Tuples.of("string", 1L, 10);
assertThat(t3a).as("Tuples of same length and values are equal.").isEqualTo(t3b);
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldNotMergeOtherTestResults() throws IOException {
String firstHistoryId = UUID.randomUUID().toString();
String secondHistoryId = UUID.randomUUID().toString();
List<LaunchResults> launchResultsList = createSingleLaunchResults(
createTestResult(FIRST_RESULT, firstHistoryId, 1L, 9L),
createTestResult(SECOND_RESULT, secondHistoryId, 11L, 19L)
);
retryPlugin.aggregate(null, launchResultsList, null);
Set<TestResult> results = launchResultsList.get(0).getAllResults();
assertThat(results).as("test results")
.filteredOn(TestResult::isHidden)
.hasSize(0);
assertThat(results).as("test results with retries block")
.flatExtracting(result -> result.getExtraBlock(RETRY_BLOCK_NAME))
.hasSize(0);
}
代码示例来源:origin: spring-projects/spring-security
assertThat(superAttrs).as("Did not find 1 attribute").hasSize(1);
代码示例来源:origin: reactor/reactor-core
.as("wip pre-padding")
.hasSize(15)
.allSatisfy(fl -> assertThat(fl.name()).startsWith("p"));
代码示例来源:origin: reactor/reactor-core
@Test
public void zeroQueueOperations() {
Queue<Integer> q = Queues.<Integer>empty().get();
List<Integer> vals = Arrays.asList(1, 2, 3);
assertThat(q.add(1)).as("add").isFalse();
assertThat(q.addAll(vals)).as("addAll").isFalse();
assertThat(q.offer(1)).as("offer").isFalse();
assertThat(q.peek()).as("peek").isNull();
assertThat(q.poll()).as("poll").isNull();
assertThat(q.contains(1)).as("contains").isFalse();
assertThat(q.iterator()).as("iterator").isEmpty();
assertThatExceptionOfType(NoSuchElementException.class)
.as("element")
.isThrownBy(q::element);
assertThatExceptionOfType(NoSuchElementException.class)
.as("remove")
.isThrownBy(q::remove);
assertThat(q.remove(1)).as("remove").isFalse();
assertThat(q.containsAll(vals)).as("containsAll").isFalse();
assertThat(q.retainAll(vals)).as("retainAll").isFalse();
assertThat(q.removeAll(vals)).as("removeAll").isFalse();
assertThatCode(q::clear).as("clear").doesNotThrowAnyException();
assertThat(q)
.hasSize(0)
.isEmpty();
assertThat(q.toArray()).as("toArray").isEmpty();
assertThat(q.toArray(new Integer[0])).as("toArray(empty)").isEmpty();
Integer[] array = new Integer[]{-1, -2, -3};
assertThat(q.toArray(array)).as("toArray(pre-filled)").containsExactly(null, -2, -3);
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldMergeRetriesTestResults() throws IOException {
String historyId = UUID.randomUUID().toString();
List<LaunchResults> launchResultsList = createSingleLaunchResults(
createTestResult(FIRST_RESULT, historyId, 1L, 9L),
createTestResult(SECOND_RESULT, historyId, 11L, 19L),
createTestResult(LAST_RESULT, historyId, 21L, 29L)
);
retryPlugin.aggregate(null, launchResultsList, null);
Set<TestResult> results = launchResultsList.get(0).getAllResults();
assertThat(results).as("test retries")
.filteredOn(TestResult::isHidden)
.extracting(TestResult::getName)
.containsExactlyInAnyOrder(FIRST_RESULT, SECOND_RESULT);
TestResult lastResult = results.stream()
.filter(r -> !r.isHidden()).findFirst().orElseGet(null);
assertThat(Collections.singletonList(lastResult))
.as("latest test result")
.extracting(TestResult::getName, TestResult::isHidden, TestResult::isFlaky)
.containsExactlyInAnyOrder(tuple(LAST_RESULT, false, true));
assertThat(results).as("test results with retries block")
.filteredOn(result -> result.hasExtraBlock(RETRY_BLOCK_NAME))
.hasSize(1);
List<RetryItem> retries = lastResult.getExtraBlock(RETRY_BLOCK_NAME);
assertThat(retries).as("test results retries block")
.isNotNull()
.hasSize(2);
}
代码示例来源:origin: reactor/reactor-core
@Test(timeout = 5000)
public void cancelWinsOverDrain() {
Queue<List<Integer>> queue = Queues.<List<Integer>>small().get();
queue.offer(Arrays.asList(1, 2, 3));
AssertSubscriber<List<Integer>> actual = AssertSubscriber.create();
BufferWhenMainSubscriber<Integer, String, Void, List<Integer>> main =
new BufferWhenMainSubscriber<>(actual,
ArrayList::new,
() -> queue,
Mono.just("open"),
i -> Mono.never());
main.onSubscribe(Operators.emptySubscription());
RaceTestUtils.race(main,
m -> {
m.cancel();
m.drain();
return m;
},
m -> m.cancelled,
(m1, m2) -> /* ignored */ true);
assertThat(main.cancelled).as("cancelled").isTrue();
//TODO windows went as far up as 3, verify if that is indeed concurrent cancels
assertThat(main.windows).as("windows").isLessThan(4);
assertThat(queue).as("queue was cleared").isEmpty();
//we also check no values were drained to the actual
assertThat(actual.values())
.as("no buffer should be drained")
.isEmpty();
}
代码示例来源:origin: spring-projects/spring-kafka
/**
* Poll the consumer for records.
* @param consumer the consumer.
* @param timeout max time in milliseconds to wait for records; forwarded to {@link Consumer#poll(long)}.
* @param <K> the key type.
* @param <V> the value type.
* @return the records.
* @since 2.0
*/
public static <K, V> ConsumerRecords<K, V> getRecords(Consumer<K, V> consumer, long timeout) {
logger.debug("Polling...");
ConsumerRecords<K, V> received = consumer.poll(Duration.ofMillis(timeout));
if (logger.isDebugEnabled()) {
logger.debug("Received: " + received.count() + ", "
+ received.partitions().stream()
.flatMap(p -> received.records(p).stream())
// map to same format as send metadata toString()
.map(r -> r.topic() + "-" + r.partition() + "@" + r.offset())
.collect(Collectors.toList()));
}
assertThat(received).as("null received from consumer.poll()").isNotNull();
return received;
}
代码示例来源:origin: spring-projects/spring-kafka
diff.removeAll(new HashSet<>(this.topics));
assertThat(this.topics)
.as("topic(s):'" + diff + "' are not in embedded topic list")
.containsAll(new HashSet<>(Arrays.asList(topics)));
final AtomicBoolean assigned = new AtomicBoolean();
代码示例来源:origin: CorfuDB/CorfuDB
@After
public void cleanupScheduledThreads() {
try {
assertThat(scheduledThreads)
.as("Test ended but there are still threads scheduled!")
.hasSize(0);
} finally {
scheduledThreads.clear();
}
}
代码示例来源:origin: iagocanalejas/retrocache
public void assertNoEvents() {
assertThat(events).as("Unconsumed events found!").isEmpty();
}
代码示例来源:origin: sixhours-team/memcached-spring-boot
@Test
public void whenGetNonExistingCacheThenIncreaseCacheSize() {
Cache cache = cacheManager.getCache(NON_EXISTING_CACHE);
assertThat(cache).isNotNull();
assertThat(cacheManager.getCacheNames())
.as("Cache size should be incremented")
.hasSize(2);
}
代码示例来源:origin: sixhours-team/memcached-spring-boot
@Test
public void whenGetCacheThenReturnExistingCache() {
Cache cache = cacheManager.getCache(EXISTING_CACHE);
assertThat(cacheManager.getCache(EXISTING_CACHE)).isSameAs(cache);
assertThat(cacheManager.getCacheNames())
.as("Cache size should remain the same")
.hasSize(1);
}
代码示例来源:origin: neo4j/neo4j-ogm
@Test
public void shouldQueryForCollectionOfActorsUsingBespokeCypherQuery() {
session.save(new Actor("Jeff"));
session.save(new Actor("John"));
session.save(new Actor("Colin"));
Iterable<Actor> actors = session.query(Actor.class, "MATCH (a:Actor) WHERE a.name=~'J.*' RETURN a",
Collections.<String, Object>emptyMap());
assertThat(actors).as("The entities weren't loaded").isNotNull();
assertThat(actors.iterator().hasNext()).as("The entity wasn't loaded").isTrue();
assertThat(actors).extracting(Actor::getName).containsOnly("John", "Jeff");
}
代码示例来源:origin: hibernate/hibernate-search
@Test
public void passThrough_stringWithoutQuotes() {
TokenFilterDef annotation = annotation(
TokenFilterDef.class,
ElasticsearchTokenFilterFactory.class,
param( "type", "stringWithoutQuotes" ),
param( "param", "stringWithoutQuotes" )
);
TokenFilterDefinition definition = translator.translate( annotation );
assertThat( definition.getType() ).as( "type" ).isEqualTo( "stringWithoutQuotes" );
assertThat( definition.getParameters() ).as( "parameters" )
.containsEntry( "param", new JsonPrimitive( "stringWithoutQuotes" ) );
assertThat( definition.getParameters().keySet() ).as( "parameters" )
.doesNotContain( "type" );
}
内容来源于网络,如有侵权,请联系作者删除!