本文整理了Java中org.assertj.core.api.AbstractIterableAssert
类的一些代码示例,展示了AbstractIterableAssert
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractIterableAssert
类的具体详情如下:
包路径:org.assertj.core.api.AbstractIterableAssert
类名称:AbstractIterableAssert
[英]Base class for implementations of ObjectEnumerableAssert
whose actual value type is Collection
.
[中]ObjectEnumerableAssert
实现的基类,其实际值类型为Collection
。
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void loadFactories() throws Exception {
Collection<FakeFactory> factories = ServiceHelper.loadFactories(FakeFactory.class);
assertThat(factories)
.isNotNull()
.hasSize(2);
Collection<NotImplementedSPI> impl = ServiceHelper.loadFactories(NotImplementedSPI.class);
assertThat(impl)
.isNotNull()
.hasSize(0);
}
代码示例来源:origin: lingochamp/okdownload
@Test
public void inspectForConflict_sameTask_isFinishing() {
final DownloadTask task = mock(DownloadTask.class);
final DownloadCall call = mock(DownloadCall.class);
when(call.equalsTask(task)).thenReturn(true);
when(call.isFinishing()).thenReturn(true);
final Collection<DownloadCall> calls = new ArrayList<>();
final Collection<DownloadTask> sameTaskList = new ArrayList<>();
final Collection<DownloadTask> fileBusyList = new ArrayList<>();
calls.add(call);
assertThat(dispatcher.inspectForConflict(task, calls, sameTaskList, fileBusyList))
.isFalse();
assertThat(fileBusyList).isEmpty();
assertThat(sameTaskList).isEmpty();
assertThat(finishingCalls).hasSize(1);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testThatALauncherCanAddACommand() {
Launcher myLauncher = new Launcher() {
@Override
protected void load() {
super.load();
register(FooCommand.class);
}
};
myLauncher.dispatch(new String[]{"foo"});
assertThat(myLauncher.getCommandNames()).contains("foo");
assertWaitUntil(spy::get);
}
代码示例来源:origin: org.assertj/assertj-core
isNotEmpty();
return toAssert(lastElement(), navigationDescription("check last element"));
代码示例来源:origin: facebook/litho
public LithoViewAssert containsTestKey(String testKey, OccurrenceCount count) {
final Deque<TestItem> testItems = LithoViewTestHelper.findTestItems(actual, testKey);
Java6Assertions.assertThat(testItems)
.hasSize(count.times)
.overridingErrorMessage(
"Expected to find test key <%s> in LithoView <%s> %s, but %s.",
testKey,
actual,
count,
testItems.isEmpty() ?
"couldn't find it" :
String.format(Locale.ROOT, "saw it %d times instead", testItems.size()))
.isNotNull();
return this;
}
代码示例来源:origin: org.assertj/assertj-core
isNotEmpty();
return toAssert(actual.iterator().next(), navigationDescription("check first element"));
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@SuppressWarnings("UnusedParameters")
@Test(groups = "short", dataProvider = "serverSideErrors")
public void should_retry_on_server_error_if_statement_idempotent(
Result error, Class<? extends DriverException> exception) {
simulateError(1, error);
simulateError(2, error);
simulateError(3, error);
try {
session.execute(new SimpleStatement("mock query").setIdempotent(true));
fail("expected a NoHostAvailableException");
} catch (NoHostAvailableException e) {
assertThat(e.getErrors().keySet())
.hasSize(3)
.containsOnly(
host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress());
assertThat(e.getErrors().values()).hasOnlyElementsOfType(exception);
}
assertOnRequestErrorWasCalled(3, exception);
assertThat(errors.getOthers().getCount()).isEqualTo(3);
assertThat(errors.getRetries().getCount()).isEqualTo(3);
assertThat(errors.getRetriesOnOtherErrors().getCount()).isEqualTo(3);
assertQueried(1, 1);
assertQueried(2, 1);
assertQueried(3, 1);
}
代码示例来源:origin: f2prateek/rx-preferences
@Test public void getWithStoredValue() {
preferences.edit().putBoolean("foo1", false).commit();
assertThat(rxPreferences.getBoolean("foo1").get()).isEqualTo(false);
preferences.edit().putString("foo2", "ROCK").commit();
assertThat(rxPreferences.getEnum("foo2", PAPER, Roshambo.class).get()).isEqualTo(ROCK);
preferences.edit().putFloat("foo3", 1f).commit();
assertThat(rxPreferences.getFloat("foo3").get()).isEqualTo(1f);
preferences.edit().putInt("foo4", 1).commit();
assertThat(rxPreferences.getInteger("foo4").get()).isEqualTo(1);
preferences.edit().putLong("foo5", 1L).commit();
assertThat(rxPreferences.getLong("foo5").get()).isEqualTo(1L);
preferences.edit().putString("foo6", "bar").commit();
assertThat(rxPreferences.getString("foo6").get()).isEqualTo("bar");
preferences.edit().putStringSet("foo7", singleton("bar")).commit();
assertThat(rxPreferences.getStringSet("foo7").get()).isEqualTo(singleton("bar"));
preferences.edit().putString("foo8", "1,2").commit();
assertThat(rxPreferences.getObject("foo8", new Point(2, 3), pointConverter).get())
.isEqualTo(new Point(1, 2));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testStartingApplicationInRedeployModeWithFileConf2() throws IOException {
cli.dispatch(new Launcher(), new String[]{"run",
HttpTestVerticle.class.getName(), "--redeploy=**" + File.separator + "*.txt",
"--launcher-class=" + Launcher.class.getName(),
"--conf=" + new File("src/test/resources/conf.json").getAbsolutePath()
});
assertWaitUntil(() -> {
try {
return RunCommandTest.getHttpCode() == 200;
} catch (IOException e) {
return false;
}
});
JsonObject conf = RunCommandTest.getContent().getJsonObject("conf");
assertThat(conf).isNotNull().isNotEmpty();
assertThat(conf.getString("name")).isEqualTo("vertx");
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
value = "3.6",
description = "Requires CASSANDRA-7423 introduced in Cassandra 3.6")
@Test(groups = "short")
public void should_support_setting_and_retrieving_udt_fields() {
.execute(
createType(udt).addColumn("first", DataType.text()).addColumn("last", DataType.text()));
UserType userType = cluster().getMetadata().getKeyspace(keyspace).getUserType(udt);
assertThat(userType).isNotNull();
.one();
assertThat(r.getString("u.first")).isEqualTo("Rick");
assertThat(r.getString("u.last")).isEqualTo("Jones");
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_not_create_pool_with_wrong_credentials() {
PlainTextAuthProvider authProvider = new PlainTextAuthProvider("cassandra", "cassandra");
Cluster cluster =
register(
Cluster.builder()
.addContactPoints(getContactPoints())
.withPort(ccm().getBinaryPort())
.withAuthProvider(authProvider)
.build());
cluster.init();
authProvider.setPassword("wrong");
Level previous = TestUtils.setLogLevel(Session.class, Level.WARN);
Session session;
try {
session = cluster.connect();
} finally {
TestUtils.setLogLevel(Session.class, previous);
logs.disableFor(Session.class);
assertThat(session.getState().getConnectedHosts()).isEmpty();
InetSocketAddress host = ccm().addressOfNode(1);
assertThat(logs.get())
.contains(
"Error creating pool to " + host,
"Authentication error on host " + host,
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_warn_if_contact_points_have_different_dcs_when_not_explicitly_specified() {
cluster.init();
assertThat(initHostsCaptor.getValue()).containsOnly(host1, host3);
assertThat(logs.get()).contains("Some contact points don't match local data center");
} finally {
cluster.close();
sCluster.stop();
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_allow_getting_and_setting_by_type_if_codec_registered() {
String insertStmt =
new TupleType(
newArrayList(DataType.cint(), DataType.cint()),
cluster().getConfiguration().getProtocolOptions().getProtocolVersion(),
registry);
assertThat(getValue(row, "v", mapping.outerType, registry)).isEqualTo(mapping.value);
assertThat(row.getList("l", mapping.codec.getJavaType())).isEqualTo(list);
assertThat(row.getMap("m", mapping.codec.getJavaType(), mapping.codec.getJavaType()))
.isEqualTo(map);
.isEqualTo(mapping.value);
assertThat(row.getSet("s", TypeTokens.listOf(mapping.javaType))).isEqualTo(set);
assertThat(getValue(row, 0, mapping.outerType, registry)).isEqualTo(mapping.value);
assertThat(row.getList(1, mapping.codec.getJavaType())).isEqualTo(list);
assertThat(row.getMap(2, mapping.codec.getJavaType(), mapping.codec.getJavaType()))
.isEqualTo(map);
.isEqualTo(mapping.value);
assertThat(row.getSet(4, TypeTokens.listOf(mapping.javaType))).isEqualTo(set);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "unit")
public void should_filter_init_hosts_with_predicate() {
Predicate<Host> predicate = Predicates.in(Lists.newArrayList(host1, host2));
HostFilterPolicy policy = new HostFilterPolicy(wrappedPolicy, predicate);
policy.init(cluster, Lists.newArrayList(host1, host2, host3));
verify(wrappedPolicy).init(eq(cluster), hostsCaptor.capture());
assertThat(hostsCaptor.getValue()).containsOnly(host1, host2);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "unit")
public void should_return_query_plan_of_wrapped_policy() {
when(wrappedPolicy.newQueryPlan(any(String.class), any(Statement.class)))
.thenReturn(Iterators.forArray(host1, host2, host3));
HostFilterPolicy policy = new HostFilterPolicy(wrappedPolicy, null);
assertThat(policy.newQueryPlan("keyspace", mock(Statement.class)))
.containsExactly(host1, host2, host3);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "isolated")
public void should_throw_exception_when_frame_exceeds_configured_max() {
try {
assertThat(hosts).hasSize(2).extractingResultOf("isUp").containsOnly(true);
ResultSet result =
session().execute(select().from(tableName).where(eq("k", 0)).and(eq("c", 0)));
assertThat(result.getAvailableWithoutFetching()).isEqualTo(1);
代码示例来源:origin: eclipse-vertx/vert.x
assertThat(command.persons).hasSize(3);
assertThat(command.persons2).hasSize(3);
assertThat(command.persons3).hasSize(3);
assertThat(command.states).hasSize(3).containsExactly(Thread.State.NEW, Thread.State.BLOCKED,
Thread.State.RUNNABLE);
assertThat(command.ints).hasSize(3).containsExactly(1, 2, 3);
assertThat(command.strings).hasSize(1).containsExactly("a");
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testMissingRequiredOption() throws Exception {
String[] args = new String[]{"-a"};
TypedOption<String> b = new TypedOption<String>().setShortName("b").setLongName("bfile")
.setSingleValued(true)
.setDescription("set the value of [b]").setType(String.class).setRequired(true);
cli.removeOption("b").addOption(b);
try {
cli.parse(Arrays.asList(args));
fail("exception expected");
} catch (MissingOptionException e) {
assertThat(e.getExpected()).hasSize(1);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_use_local_dc_from_contact_points_when_not_explicitly_specified() {
cluster.init();
assertThat(initHostsCaptor.getValue()).containsExactly(host1);
assertThat(policy.localDc).isEqualTo(host1.getDatacenter());
assertThat(logs.get()).doesNotContain("Some contact points don't match local datacenter");
} finally {
cluster.close();
sCluster.stop();
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_use_provided_local_dc_and_not_warn_if_contact_points_match() {
cluster.init();
assertThat(initHostsCaptor.getValue()).containsOnly(host1);
assertThat(policy.localDc).isEqualTo(host1.getDatacenter());
assertThat(logs.get()).doesNotContain("Some contact points don't match local data center");
} finally {
cluster.close();
sCluster.stop();
内容来源于网络,如有侵权,请联系作者删除!