本文整理了Java中org.hamcrest.core.IsNull.nullValue()
方法的一些代码示例,展示了IsNull.nullValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IsNull.nullValue()
方法的具体详情如下:
包路径:org.hamcrest.core.IsNull
类名称:IsNull
方法名:nullValue
[英]Creates a matcher that matches if examined object is null
.
For example:
assertThat(cheese, is(nullValue())
[中]创建一个匹配器,该匹配器在检查对象为null
时匹配。
例如:
assertThat(cheese, is(nullValue())
代码示例来源:origin: neo4j/neo4j
protected static Map<String, Object> deserializeMap( final String body ) throws JsonParseException
{
Map<String, Object> result = JsonHelper.jsonToMap( body );
assertThat( result, CoreMatchers.is( not( nullValue() ) ) );
return result;
}
代码示例来源:origin: apache/kafka
@Test
public void allSerdesShouldSupportNull() {
for (Class<?> cls : testData.keySet()) {
try (Serde<?> serde = Serdes.serdeFrom(cls)) {
assertThat("Should support null in " + cls.getSimpleName() + " serialization",
serde.serializer().serialize(topic, null), nullValue());
assertThat("Should support null in " + cls.getSimpleName() + " deserialization",
serde.deserializer().deserialize(topic, null), nullValue());
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testThatGetSecondLevelCacheStatisticsWhenSecondLevelCacheIsNotEnabledReturnsNull() {
final SecondLevelCacheStatistics secondLevelCacheStatistics = statistics
.getSecondLevelCacheStatistics( StringHelper.qualify( REGION_PREFIX, TRIVIAL_REGION_NAME ) );
assertThat( secondLevelCacheStatistics, is( nullValue() ) );
}
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldGetNullArrayIfNullValue() throws Exception {
JsonNode value = mapper.valueToTree(null);
Claim claim = claimFromNode(value);
assertThat(claim.asArray(String.class), is(nullValue()));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void shouldResolveCommentByTaskId() {
// given
testRule.deploy(CALLING_PROCESS);
testRule.deploy(CALLED_PROCESS);
ClockUtil.setCurrentTime(START_DATE);
runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY);
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.createComment(taskId, null, "aMessage");
Comment comment = taskService.getTaskComments(taskId).get(0);
// assume
assertThat(comment.getRemovalTime(), nullValue());
ClockUtil.setCurrentTime(END_DATE);
// when
taskService.complete(taskId);
comment = taskService.getTaskComments(taskId).get(0);
Date removalTime = addDays(END_DATE, 5);
// then
assertThat(comment.getRemovalTime(), is(removalTime));
}
代码示例来源:origin: neo4j/neo4j
@SuppressWarnings( "unchecked" )
private <T extends PropertyContainer> void makeSureAdditionsCanBeRead(
Index<T> index, EntityCreator<T> entityCreator )
{
String key = "name";
String value = "Mattias";
assertThat( index.get( key, value ).getSingle(), is( nullValue() ) );
assertThat( index.get( key, value ), emptyIterable() );
assertThat( index.query( key, "*" ), emptyIterable() );
T entity1 = entityCreator.create();
T entity2 = entityCreator.create();
index.add( entity1, key, value );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.get( key, value ), Contains.contains( entity1 ) );
assertThat( index.query( key, "*" ), Contains.contains( entity1 ) );
assertThat( index.get( key, value ), Contains.contains( entity1 ) );
restartTx();
}
index.add( entity2, key, value );
assertThat( index.get( key, value ), Contains.contains( entity1, entity2 ) );
restartTx();
assertThat( index.get( key, value ), Contains.contains( entity1, entity2 ) );
index.delete();
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testRecording() {
TestListener listener = new TestListener();
LogInspectionHelper.registerListener( listener, LOG );
LOG.debug( "Hey coffee is ready!" );
assertThat( listener.isCAlled, is( true ) );
assertThat( listener.level, is( Level.DEBUG ) );
assertThat( (String) listener.renderedMessage, is( "Hey coffee is ready!" ) );
assertThat( listener.thrown, nullValue() );
LogInspectionHelper.clearAllListeners( LOG );
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldGetNullListIfNonArrayValue() throws Exception {
JsonNode value = mapper.valueToTree(1);
Claim claim = claimFromNode(value);
assertThat(claim.asList(String.class), is(nullValue()));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void shouldResolveCommentByTaskIdAndWrongProcessInstanceId() {
// given
testRule.deploy(CALLING_PROCESS);
testRule.deploy(CALLED_PROCESS);
ClockUtil.setCurrentTime(START_DATE);
runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY);
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.createComment(taskId, "aNonExistentProcessInstanceId", "aMessage");
Comment comment = taskService.getTaskComments(taskId).get(0);
// assume
assertThat(comment.getRemovalTime(), nullValue());
ClockUtil.setCurrentTime(END_DATE);
// when
taskService.complete(taskId);
comment = taskService.getTaskComments(taskId).get(0);
Date removalTime = addDays(END_DATE, 5);
// then
assertThat(comment.getRemovalTime(), is(removalTime));
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldHandleColumnAsWithNull()
{
assertThat( db.execute( "RETURN toLower(null) AS lower" ).<String>columnAs( "lower" ).next(), nullValue() );
}
代码示例来源:origin: PaNaVTEC/Clean-Contacts
private void assertThatResponseHasResult(InteractorResponse<List<Contact>> response) {
assertThat(response.getError(), is(nullValue()));
assertThat(response.getResult(), is(CONTACTS));
}
代码示例来源:origin: neo4j/neo4j
private static List<Map<String, Object>> deserializeList( final String body ) throws JsonParseException
{
List<Map<String, Object>> result = JsonHelper.jsonToList( body );
assertThat( result, CoreMatchers.is( not( nullValue() ) ) );
return result;
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldSerializeMapWithSimpleTypes() throws Exception
{
MapRepresentation rep = new MapRepresentation( map( "nulls", null, "strings", "a string", "numbers", 42,
"booleans", true ) );
OutputFormat format = new OutputFormat( new JsonFormat(), new URI( "http://localhost/" ), null );
String serializedMap = format.assemble( rep );
Map<String, Object> map = JsonHelper.jsonToMap( serializedMap );
assertThat( map.get( "nulls" ), is( nullValue() ) );
assertThat( map.get( "strings" ), is( "a string" ) );
assertThat( map.get( "numbers" ), is( 42 ) );
assertThat( map.get( "booleans" ), is( true ) );
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldGetNullStringIfNotStringValue() throws Exception {
JsonNode objectValue = mapper.valueToTree(new Object());
assertThat(claimFromNode(objectValue).asString(), is(nullValue()));
JsonNode intValue = mapper.valueToTree(12345);
assertThat(claimFromNode(intValue).asString(), is(nullValue()));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void shouldResolveByteArray_CreateAttachmentByTask() {
// given
testRule.deploy(CALLING_PROCESS);
testRule.deploy(CALLED_PROCESS);
ClockUtil.setCurrentTime(START_DATE);
runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY);
String taskId = taskService.createTaskQuery().singleResult().getId();
AttachmentEntity attachment = (AttachmentEntity) taskService.createAttachment(null, taskId, null, null, null, new ByteArrayInputStream("hello world".getBytes()));
ByteArrayEntity byteArray = findByteArrayById(attachment.getContentId());
// assume
assertThat(byteArray.getRemovalTime(), nullValue());
ClockUtil.setCurrentTime(END_DATE);
// when
taskService.complete(taskId);
byteArray = findByteArrayById(attachment.getContentId());
Date removalTime = addDays(END_DATE, 5);
// then
assertThat(byteArray.getRemovalTime(), is(removalTime));
}
代码示例来源:origin: hamcrest/JavaHamcrest
@Test public void
supportsStaticTyping() {
requiresStringMatcher(nullValue(String.class));
requiresStringMatcher(notNullValue(String.class));
}
代码示例来源:origin: PaNaVTEC/Clean-Contacts
private void assertThatResponseHasError(InteractorResponse<List<Contact>> result) {
assertThat(result.getError(), is(notNullValue()));
assertThat(result.getResult(), is(nullValue()));
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void nullNewValue() {
GlobalPropertyChangeHandler.PropertyChange change = GlobalPropertyChangeHandler.PropertyChange.create("favourite.java.version", null);
assertThat(change.getNewValue(), nullValue());
assertThat(change.toString(), is("[key=favourite.java.version, newValue=null]"));
}
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldGetNullMapIfNullValue() throws Exception {
JsonNode value = mapper.valueToTree(null);
Claim claim = claimFromNode(value);
assertThat(claim.asMap(), is(nullValue()));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void shouldResolveHistoricDetailByFormProperty() {
// given
DeploymentWithDefinitions deployment = testRule.deploy(CALLING_PROCESS);
testRule.deploy(CALLED_PROCESS);
String processDefinitionId = deployment.getDeployedProcessDefinitions().get(0).getId();
Map<String, Object> properties = new HashMap<>();
properties.put("aFormProperty", "aFormPropertyValue");
ClockUtil.setCurrentTime(START_DATE);
formService.submitStartForm(processDefinitionId, properties);
HistoricDetail historicDetail = historyService.createHistoricDetailQuery().formFields().singleResult();
// assume
assertThat(historicDetail.getRemovalTime(), nullValue());
ClockUtil.setCurrentTime(END_DATE);
String taskId = historyService.createHistoricTaskInstanceQuery().singleResult().getId();
// when
taskService.complete(taskId);
historicDetail = historyService.createHistoricDetailQuery().formFields().singleResult();
Date removalTime = addDays(END_DATE, 5);
// then
assertThat(historicDetail.getRemovalTime(), is(removalTime));
}
内容来源于网络,如有侵权,请联系作者删除!