Es gibt Testcode die Ausnahme thorws und ich kann nicht verstehen - warum?Mockito Ausnahme
Ausnahme:
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Prüfregeln:
@Test
public void testUpdateBookingFormData() throws Exception {
when(registrantFormService.getRegistrantFormByUUID(any(String.class))).thenReturn(registrantForm);
when(bookingService.getById(any(Long.class))).thenReturn(booking);
when(eventFieldRepository.findByEventIdOrderBySortIndexAsc(any(Long.class))).thenReturn(eventFieldList);
when(registrantAggregateService.getRegistrantDataAggregate(any(RegistrantKey.class))).thenReturn(registrantAggregate);
when(bookingFormStrategiesFactory.chooseStrategy(any(Long.class))).thenReturn(bookingFormStrategy);
when(bookingFormValidatorsFactory.getValidatorForForm(any(Booking.class))).thenReturn(validator);
when(validator.validate(any(BookingFormBean.class))).thenReturn(true);
when(bookingFormStrategy.getFormByKey(any(Booking.class), any(RegistrantKey.class))).thenReturn(bookingFormBean);
BookingFormsCollectionBean bookingFormsCollectionBean = bookingFormsService.updateBookingFormData(eq(booking.getKey().getVisitorId()), anyString(), anyMapOf(String.class, String[].class));
assertThat(bookingFormsCollectionBean, is(IsNull.notNullValue()));
}
Was ich falsch?
UPD: Voll Code http://pastebin.com/rprLG8Nt
UPD2: Diese vollständige Ausnahmemeldung:
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers!
1 matchers expected, 3 recorded:
-> at com.evm.front.service.logic.bookingprocess.BookingFormsServiceTest.testUpdateBookingFormData(BookingFormsServiceTest.java:106)
-> at com.evm.front.service.logic.bookingprocess.BookingFormsServiceTest.testUpdateBookingFormData(BookingFormsServiceTest.java:106)
-> at com.evm.front.service.logic.bookingprocess.BookingFormsServiceTest.testUpdateBookingFormData(BookingFormsServiceTest.java:106)
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));
For more info see javadoc for Matchers class.
at com.evm.front.service.logic.bookingprocess.BookingFormsService.updateBookingFormData(BookingFormsService.java:202)
at com.evm.front.service.logic.bookingprocess.BookingFormsServiceTest.testUpdateBookingFormData(BookingFormsServiceTest.java:106)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
Wie erstellen Sie die Mock-Objekte? –
@BilboBaggins gut, ich bin hinzufügen alle meine Code in diesem http://pastebin.com/rprLG8Nt –
Was die volle Ausnahme ist? I.e. Welche Linie ist die problematische? –