protected boolean isMatch(Method method, String beanKey) { if (this.methodMappings != null) { Set<String> methodNames = this.methodMappings.get(beanKey); if (methodNames != null) { return methodNames.contains(method.getName()); } } return (this.managedMethods != null && this.managedMethods.contains(method.getName())); }
@Override public String toString() { return String.format("%s.%s() %s", method.getDeclaringClass().getName(), method.getName(), arguments); } }
static RuntimeException methodError(Method method, @Nullable Throwable cause, String message, Object... args) { message = String.format(message, args); return new IllegalArgumentException(message + "\n for method " + method.getDeclaringClass().getSimpleName() + "." + method.getName(), cause); }
@Override @Nullable protected Object getRawAttributeValue(Method attributeMethod) { return getRawAttributeValue(attributeMethod.getName()); }
/** * Identifies just enterIfXxx methods (a subset of {@link #isAnyEnter}), which are mostly like the * enterXxx methods but behave like tryEnterXxx in some scenarios. */ private static boolean isEnterIf(Method method) { return method.getName().startsWith("enterIf"); }
private static String nameFor( Method method, Scenario scenario, boolean fair, Timeout timeout, Outcome expectedOutcome) { return String.format( Locale.ROOT, "%s%s(%s)/%s->%s", method.getName(), fair ? "(fair)" : "(nonfair)", (timeout == null) ? "untimed" : timeout, scenario, expectedOutcome); }
@Override public boolean matches(Method m, @Nullable Class<?> targetClass) { return "haveBirthday".equals(m.getName()); } };
@Override public boolean matches(Method m, @Nullable Class<?> targetClass, Object... args) { boolean run = m.getName().contains(pattern); if (run) ++count; return run; } });
SourceSinkTester(F factory, T data, String suiteName, String caseDesc, Method method) { super(method.getName()); this.factory = checkNotNull(factory); this.data = checkNotNull(data); this.expected = checkNotNull(factory.getExpected(data)); this.suiteName = checkNotNull(suiteName); this.caseDesc = checkNotNull(caseDesc); }
private static void doTestMocking(RateLimiter mock) throws Exception { for (Method method : RateLimiter.class.getMethods()) { if (!isStatic(method.getModifiers()) && !NOT_WORKING_ON_MOCKS.contains(method.getName()) && !method.getDeclaringClass().equals(Object.class)) { method.invoke(mock, arbitraryParameters(method)); } } }
@GwtIncompatible // reflection public void testAsMapBridgeMethods() { for (Method m : TreeMultimap.class.getMethods()) { if (m.getName().equals("asMap") && m.getReturnType().equals(SortedMap.class)) { return; } } }
@GwtIncompatible // reflection public void testKeySetBridgeMethods() { for (Method m : TreeMultimap.class.getMethods()) { if (m.getName().equals("keySet") && m.getReturnType().equals(SortedSet.class)) { return; } } fail("No bridge method found"); }
@GwtIncompatible // reflection public void testGetBridgeMethods() { for (Method m : TreeMultimap.class.getMethods()) { if (m.getName().equals("get") && m.getReturnType().equals(SortedSet.class)) { return; } } fail("No bridge method found"); } }
@Override public Object handleInvocation(Object proxy, Method method, Object[] args) { // Crude, but acceptable until we can use Java 8. Other // methods have default implementations, and it is hard to // distinguish. if (method.getName().equals(JUF_METHODS.get(typeName))) { return getDefaultValue(type.method(method).getReturnType()); } throw new IllegalStateException("Unexpected " + method + " invoked on " + proxy); } });
MethodSignature(Method method) { name = method.getName(); parameterTypes = Arrays.asList(method.getParameterTypes()); typeSignature = new TypeSignature(method.getTypeParameters()); }
@GwtIncompatible // reflection @AndroidIncompatible // Reflection bug, or actual binary compatibility problem? public void testElementSetBridgeMethods() { for (Method m : TreeMultiset.class.getMethods()) { if (m.getName().equals("elementSet") && m.getReturnType().equals(SortedSet.class)) { return; } } fail("No bridge method found"); } }
public void verifyBarPass(Method method, TwoArg bar) { try { new NullPointerTester().testMethod(bar, method); } catch (AssertionFailedError incorrectError) { String errorMessage = rootLocaleFormat("Should not have flagged method %s for %s", method.getName(), bar); assertNull(errorMessage, incorrectError); } }
public void verifyBarFail(Method method, TwoArg bar) { try { new NullPointerTester().testMethod(bar, method); } catch (AssertionFailedError expected) { return; // good...we wanted a failure } String errorMessage = rootLocaleFormat("Should have flagged method %s for %s", method.getName(), bar); fail(errorMessage); }