Add missing unit test for the "read" method of JsonItemReader

This commit is contained in:
Mahmoud Ben Hassine
2018-06-05 09:30:04 +02:00
parent 5281d6d2aa
commit bd8daf0caf

View File

@@ -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() {