public static void updateErrorMessageForMethodInvocation(AssertionError errorToUpdate) { /* * We failed to verify the new substitution mock. This happens when, for * example, the user has done something like * whenNew(MyClass.class).thenReturn(myMock).times(3) when in fact an * instance of MyClass has been created less or more times than 3. */ Whitebox.setInternalState(errorToUpdate, "detailMessage", "\n" + changeMessageContent(errorToUpdate.getMessage())); }
public static void updateErrorMessageForMethodInvocation(AssertionError errorToUpdate) { /* * We failed to verify the new substitution mock. This happens when, for * example, the user has done something like * whenNew(MyClass.class).thenReturn(myMock).times(3) when in fact an * instance of MyClass has been created less or more times than 3. */ Whitebox.setInternalState(errorToUpdate, "\n" + changeMessageContent(errorToUpdate.getMessage())); }
public static void throwAssertionErrorForNewSubstitutionFailure(AssertionError oldError, Class<?> type) { /* * We failed to verify the new substitution mock. This happens when, for * example, the user has done something like * whenNew(MyClass.class).thenReturn(myMock).times(3) when in fact an * instance of MyClass has been created less or more times than 3. */ final String newSubsitutionClassName = InvocationSubstitute.class.getSimpleName(); final String newSubsitutionClassNameInMockito = newSubsitutionClassName.substring(0, 1).toLowerCase() + newSubsitutionClassName.substring(1); String message = oldError.getMessage(); final String newSubsitutionMethodName = InvocationSubstitute.class.getDeclaredMethods()[0].getName(); message = message.replaceAll(newSubsitutionClassNameInMockito + "." + newSubsitutionMethodName, Matcher .quoteReplacement(type.getName())); message = message.replaceAll("method", "constructor"); throw new AssertionError(changeMessageContent(message)); }
public static void throwAssertionErrorForNewSubstitutionFailure(AssertionError oldError, Class<?> type) { /* * We failed to verify the new substitution mock. This happens when, for * example, the user has done something like * whenNew(MyClass.class).thenReturn(myMock).times(3) when in fact an * instance of MyClass has been created less or more times than 3. */ final String newSubsitutionClassName = InvocationSubstitute.class.getSimpleName(); final String newSubsitutionClassNameInMockito = newSubsitutionClassName.substring(0, 1).toLowerCase() + newSubsitutionClassName.substring(1); String message = oldError.getMessage(); final String newSubsitutionMethodName = InvocationSubstitute.class.getDeclaredMethods()[0].getName(); message = message.replaceAll(newSubsitutionClassNameInMockito + "." + newSubsitutionMethodName, Matcher .quoteReplacement(type.getName())); message = message.replaceAll("method", "constructor"); throw new AssertionError(changeMessageContent(message)); }