Hi
Ich habe folgenden Code
Leider funktioniert das any nicht.Es gibt immer null zurück. Kann man nicht Methoden mit beliebigen Objekten in Mockito mocken oder mache ich etwas falsch ?
Ich habe folgenden Code
Java:
public static GoogleCalendarUtility getStub(){
GoogleCalendarUtility googleCalendarUtility = mock(GoogleCalendarUtility.class);
CalendarService anyCalendarService = any(CalendarService.class);
CalendarEventEntry anyCalendareventEntry = any(CalendarEventEntry.class);
String anyString = anyString();
when(googleCalendarUtility.getCalendarUser(anyCalendarService,anyString())).thenReturn("Hallo Gast");
try {
when(googleCalendarUtility.getCalendarService(anyString(),anyString(),anyString())).thenReturn(anyCalendarService);
} catch (AuthenticationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
when(googleCalendarUtility.getNextEventAllCalendars(anyCalendarService,anyString())).thenReturn(anyCalendareventEntry);
when(googleCalendarUtility.getNextEventString(anyCalendareventEntry)).thenReturn("Schöner Tag");
when(googleCalendarUtility.getNextEventTimeString(anyCalendareventEntry)).thenReturn("24 Stunden");
return googleCalendarUtility;
}
Leider funktioniert das any nicht.Es gibt immer null zurück. Kann man nicht Methoden mit beliebigen Objekten in Mockito mocken oder mache ich etwas falsch ?