From bd8daf0cafb294f434bdd543de43a134408d150c Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Tue, 5 Jun 2018 09:30:04 +0200 Subject: [PATCH] Add missing unit test for the "read" method of JsonItemReader --- .../batch/item/json/JsonItemReaderTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java index 12cd58697..4d33a509e 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java @@ -24,12 +24,14 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemStreamException; import org.springframework.core.io.AbstractResource; import org.springframework.core.io.ByteArrayResource; +import org.springframework.core.io.Resource; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -95,6 +97,19 @@ public class JsonItemReaderTests { // expected exception } + @Test + public void testReadItem() throws Exception { + // given + Resource resource = new ByteArrayResource("[]".getBytes()); + itemReader = new JsonItemReader<>(resource, this.jsonObjectReader); + + // when + itemReader.read(); + + // then + Mockito.verify(this.jsonObjectReader).read(); + } + private static class NonExistentResource extends AbstractResource { NonExistentResource() {