i have code like below
ScheExeService.ScheduleId scheduleID = ScheExeService.getOneTimeScheduleId(nl.getCompany(), workItem.getId());
ScheExeService.Schedule schedule = ScheExeService.loadSchedule(nl, scheduleID.getId());
Calendar cal = Calendar.getInstance(java.util.TimeZone.getTimeZone(nl.getTimeZone()));
cal.setTime(schedule.attributes.startDate.toDate());
AND i am trying to mock "schedule.attributes.startDate.toDate()"
and ScheExeService look like below
public class ScheExeService implements blah
{
public final static class Schedule {
public final ScheduleId id;
public final ScheduleAttributes attributes;
public final String callableClassName;
public final long itemId;
public Schedule(ScheduleId id, ScheduleAttributes attributes, String callableClassName, long itemId)
{
this.id = id;
this.attributes = attributes;
this.callableClassName = callableClassName;
this.itemId = itemId;
}
}
public final static class ScheduleAttributes {
public final @Nullable LocalDate startDate;
public final @Nullable LocalTime startTime;
public final @Nullable LocalDate endDate;
public final @Nullable LocalTime endTime;
Method code
}
}
and i tried
doNothing().doThrow(new RuntimeException()).when(mockedCalenderObject).setTime(null);
but i am keep getting NPE.
how i can avoid schedule.attributes.startDate.todate() call..?