Java源码示例:org.springframework.batch.item.NonTransientResourceException
示例1
@Test
public void read_twoCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
when(daoManagerMock.chekImportedData()).thenReturn(true);
List<Long> CreatedSapCourcesIds = new ArrayList<Long>();
CreatedSapCourcesIds.add(100L);
CreatedSapCourcesIds.add(200L);
when(daoManagerMock.getAllCreatedSapCourcesIds()).thenReturn(CreatedSapCourcesIds);
CampusCourseImportTO courseMock1 = mock(CampusCourseImportTO.class);
CampusCourseImportTO courseMock2 = mock(CampusCourseImportTO.class);
when(daoManagerMock.getSapCampusCourse(100L)).thenReturn(courseMock1);
when(daoManagerMock.getSapCampusCourse(200L)).thenReturn(courseMock2);
synchronizationReaderTestObject.init();
// The first read delivers the first course
assertNotNull(synchronizationReaderTestObject.read());
// The second read delivers the second course
assertNotNull(synchronizationReaderTestObject.read());
// The third read delivers null
assertNull(synchronizationReaderTestObject.read());
}
示例2
@Test
public void read_twoStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
List<Student> twoStudentsList = new ArrayList<Student>();
Student studentMock1 = mock(Student.class);
Student studentMock2 = mock(Student.class);
twoStudentsList.add(studentMock1);
twoStudentsList.add(studentMock2);
when(daoManagerMock.getAllStudents()).thenReturn(twoStudentsList);
studentMappingReaderTestObject.init();
// The first read delivers the first student
assertNotNull(studentMappingReaderTestObject.read());
// The second read delivers the second student
assertNotNull(studentMappingReaderTestObject.read());
// The third read delivers null
assertNull(studentMappingReaderTestObject.read());
}
示例3
@Test
public void read_twoLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
List<Lecturer> twoLecturersList = new ArrayList<Lecturer>();
Lecturer lecturerMock1 = mock(Lecturer.class);
Lecturer lecturerMock2 = mock(Lecturer.class);
twoLecturersList.add(lecturerMock1);
twoLecturersList.add(lecturerMock2);
when(daoManagerMock.getAllLecturers()).thenReturn(twoLecturersList);
lecturerMappingReaderTestObject.init();
// The first read delivers the first lecturer
assertNotNull(lecturerMappingReaderTestObject.read());
// The second read delivers the second lecturer
assertNotNull(lecturerMappingReaderTestObject.read());
// The third read delivers null
assertNull(lecturerMappingReaderTestObject.read());
}
示例4
@Override
public Item read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
if (readerTransactional) {
businessMetrics.increment(MetricNames.READ_COUNT.getName());
businessMetrics.submit(MetricNames.READ_GAUGE.getName(), 5);
} else {
businessMetrics.incrementNonTransactional(MetricNames.READ_COUNT.getName());
businessMetrics.submitNonTransactional(MetricNames.READ_GAUGE.getName(), 5);
}
Item item = delegate.read();
if (item != null && item.getActions().contains(Action.FAIL_ON_READ)) {
throw new MetricsTestException(Action.FAIL_ON_READ);
}
LOGGER.debug("Read item: {}", item);
return item;
}
示例5
@Override
public Object read() throws Exception, UnexpectedInputException, ParseException,
NonTransientResourceException {
String result = "1";
if (this.failCount < 2) {
this.failCount++;
throw new IllegalStateException("Reader FOOBAR");
}
if (this.finished) {
result = null;
}
this.finished = true;
return result;
}
示例6
/**
* Reads a {@link CampusCourseImportTo} via the {@link DaoManager} with the given course id from the list of the sapCoursesIds. <br>
* It returns null at the end of the list of the sapCoursesIds
*/
public CampusCourseImportTO read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
if (ListUtil.isNotBlank(sapCoursesIds)) {
return daoManager.getSapCampusCourse(sapCoursesIds.remove(0));
}
return null;
}
示例7
@Test
public void read_nullCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
when(daoManagerMock.getAllCreatedSapCources()).thenReturn(null);
synchronizationReaderTestObject.init();
assertNull(synchronizationReaderTestObject.read());
}
示例8
@Test
public void read_emptyCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
when(daoManagerMock.getAllCreatedSapCources()).thenReturn(Collections.emptyList());
synchronizationReaderTestObject.init();
assertNull(synchronizationReaderTestObject.read());
}
示例9
@Test
public void read_nullStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
when(daoManagerMock.getAllStudents()).thenReturn(null);
studentMappingReaderTestObject.init();
assertNull(studentMappingReaderTestObject.read());
}
示例10
@Test
public void read_emptyStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
when(daoManagerMock.getAllStudents()).thenReturn(Collections.emptyList());
studentMappingReaderTestObject.init();
assertNull(studentMappingReaderTestObject.read());
}
示例11
@Test
public void read_nullLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
when(daoManagerMock.getAllLecturers()).thenReturn(null);
lecturerMappingReaderTestObject.init();
assertNull(lecturerMappingReaderTestObject.read());
}
示例12
@Test
public void read_emptyLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
when(daoManagerMock.getAllLecturers()).thenReturn(Collections.emptyList());
lecturerMappingReaderTestObject.init();
assertNull(lecturerMappingReaderTestObject.read());
}
示例13
@Override
public ApplicationAgentsList read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
return queue.poll();
}