Refine search
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; }
@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()); } } }
@Test public void testThatGetSecondLevelCacheStatisticsWhenSecondLevelCacheIsNotEnabledReturnsNull() { final SecondLevelCacheStatistics secondLevelCacheStatistics = statistics .getSecondLevelCacheStatistics( StringHelper.qualify( REGION_PREFIX, TRIVIAL_REGION_NAME ) ); assertThat( secondLevelCacheStatistics, is( nullValue() ) ); } }
@Test public void shouldGetNullArrayIfNullValue() throws Exception { JsonNode value = mapper.valueToTree(null); Claim claim = claimFromNode(value); assertThat(claim.asArray(String.class), is(nullValue())); }
@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)); }
@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(); }
@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 ); }
@Test public void shouldGetNullListIfNonArrayValue() throws Exception { JsonNode value = mapper.valueToTree(1); Claim claim = claimFromNode(value); assertThat(claim.asList(String.class), is(nullValue())); }
@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)); }
private void assertThatResponseHasResult(InteractorResponse<List<Contact>> response) { assertThat(response.getError(), is(nullValue())); assertThat(response.getResult(), is(CONTACTS)); }
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; }
@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 ) ); }
@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())); }
@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)); }
private void assertThatResponseHasError(InteractorResponse<List<Contact>> result) { assertThat(result.getError(), is(notNullValue())); assertThat(result.getResult(), is(nullValue())); } }
@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]")); } }
@Test public void shouldGetNullMapIfNullValue() throws Exception { JsonNode value = mapper.valueToTree(null); Claim claim = claimFromNode(value); assertThat(claim.asMap(), is(nullValue())); }
@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)); }