Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd8daf0

Browse files
committed
Add missing unit test for the "read" method of JsonItemReader
1 parent 5281d6d commit bd8daf0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
import org.junit.rules.ExpectedException;
2525
import org.junit.runner.RunWith;
2626
import org.mockito.Mock;
27+
import org.mockito.Mockito;
2728
import org.mockito.junit.MockitoJUnitRunner;
2829

2930
import org.springframework.batch.item.ExecutionContext;
3031
import org.springframework.batch.item.ItemStreamException;
3132
import org.springframework.core.io.AbstractResource;
3233
import org.springframework.core.io.ByteArrayResource;
34+
import org.springframework.core.io.Resource;
3335

3436
import static org.junit.Assert.assertEquals;
3537
import static org.junit.Assert.fail;
@@ -95,6 +97,19 @@ public void testNonReadableResource() {
9597
// expected exception
9698
}
9799

100+
@Test
101+
public void testReadItem() throws Exception {
102+
// given
103+
Resource resource = new ByteArrayResource("[]".getBytes());
104+
itemReader = new JsonItemReader<>(resource, this.jsonObjectReader);
105+
106+
// when
107+
itemReader.read();
108+
109+
// then
110+
Mockito.verify(this.jsonObjectReader).read();
111+
}
112+
98113
private static class NonExistentResource extends AbstractResource {
99114

100115
NonExistentResource() {

0 commit comments

Comments
 (0)