org.assertj.core.api.AbstractMapAssert.isNull()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.assertj.core.api.AbstractMapAssert.isNull()方法的一些代码示例,展示了AbstractMapAssert.isNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractMapAssert.isNull()方法的具体详情如下:
包路径:org.assertj.core.api.AbstractMapAssert
类名称:AbstractMapAssert
方法名:isNull

AbstractMapAssert.isNull介绍

[英]Verifies that the Map is null or empty.

Example:

// assertions will pass 
Map<Integer, String> map = null; 
assertThat(map).isNullOrEmpty(); 
assertThat(new HashMap()).isNullOrEmpty(); 
// assertion will fail 
Map<String, String> keyToValue = new HashMap(); 
keyToValue.put("key", "value"); 
assertThat(keyToValue).isNullOrEmpty()

[中]验证映射是否为null或空。
例子:

// assertions will pass 
Map<Integer, String> map = null; 
assertThat(map).isNullOrEmpty(); 
assertThat(new HashMap()).isNullOrEmpty(); 
// assertion will fail 
Map<String, String> keyToValue = new HashMap(); 
keyToValue.put("key", "value"); 
assertThat(keyToValue).isNullOrEmpty()

代码示例

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Ensures that payloads can still be set individually on bound statements if the prepared
 * statement does not have a default payload.
 */
@Test(groups = "short")
public void should_not_set_any_payload_on_bound_statement() throws Exception {
 RegularStatement statement = new SimpleStatement("SELECT c2 as col3 FROM t1 where c1 = ?");
 PreparedStatement ps = session().prepare(statement);
 assertThat(ps.getOutgoingPayload()).isNull();
 assertThat(ps.getIncomingPayload()).isNull();
 // bound statement should not have outgoing payload
 BoundStatement bs = ps.bind(1);
 assertThat(bs.getOutgoingPayload()).isNull();
 // explicitly set a payload for this boudn statement only
 bs.setOutgoingPayload(payload1);
 ResultSet rows = session().execute(bs);
 Map<String, ByteBuffer> actual = rows.getExecutionInfo().getIncomingPayload();
 assertThat(actual).isEqualTo(payload1);
 // a second bound statement should not have any payload
 bs = ps.bind();
 assertThat(bs.getOutgoingPayload()).isNull();
 bs.setInt(0, 1);
 rows = session().execute(bs);
 actual = rows.getExecutionInfo().getIncomingPayload();
 assertThat(actual).isNull();
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void getValueMapWithClass() {
 valueMap.put("foo", "not a map");
 assertThat(valueMap.getValueMap("foo", Traits.class)).isNull();
}

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

/**
 * Ensures that payloads can still be set individually on bound statements if the prepared
 * statement does not have a default payload.
 */
@Test(groups = "short")
public void should_not_set_any_payload_on_bound_statement() throws Exception {
 RegularStatement statement = new SimpleStatement("SELECT c2 as col3 FROM t1 where c1 = ?");
 PreparedStatement ps = session().prepare(statement);
 assertThat(ps.getOutgoingPayload()).isNull();
 assertThat(ps.getIncomingPayload()).isNull();
 // bound statement should not have outgoing payload
 BoundStatement bs = ps.bind(1);
 assertThat(bs.getOutgoingPayload()).isNull();
 // explicitly set a payload for this boudn statement only
 bs.setOutgoingPayload(payload1);
 ResultSet rows = session().execute(bs);
 Map<String, ByteBuffer> actual = rows.getExecutionInfo().getIncomingPayload();
 assertThat(actual).isEqualTo(payload1);
 // a second bound statement should not have any payload
 bs = ps.bind();
 assertThat(bs.getOutgoingPayload()).isNull();
 bs.setInt(0, 1);
 rows = session().execute(bs);
 actual = rows.getExecutionInfo().getIncomingPayload();
 assertThat(actual).isNull();
}

相关文章