/** * Suppress specific fields. This works on both instance methods and static * methods. Note that replay and verify are not needed as this is not part * of a mock behavior. */ public static synchronized void suppressField(Field... fields) { for (Field field : fields) { MockRepository.addFieldToSuppress(field); } }
/** * Suppress specific fields. This works on both instance methods and static * methods. Note that replay and verify are not needed as this is not part * of a mock behavior. */ public static synchronized void suppressField(Field... fields) { for (Field field : fields) { MockRepository.addFieldToSuppress(field); } }
/** * Suppress multiple methods for a class. * * @param classes * The class whose methods will be suppressed. * @param fieldNames * The names of the methods that'll be suppressed. If field names * are empty, <i>all</i> fields in the supplied class will be * suppressed. */ public static synchronized void suppressField(Class<?> clazz, String... fieldNames) { if (fieldNames == null || fieldNames.length == 0) { suppressField(new Class<?>[] { clazz }); } else { for (Field field : Whitebox.getFields(clazz, fieldNames)) { MockRepository.addFieldToSuppress(field); } } }
/** * Suppress multiple methods for a class. * * @param clazz * The class whose methods will be suppressed. * @param fieldNames * The names of the methods that'll be suppressed. If field names * are empty, <i>all</i> fields in the supplied class will be * suppressed. */ public static synchronized void suppressField(Class<?> clazz, String... fieldNames) { if (fieldNames == null || fieldNames.length == 0) { suppressField(new Class<?>[] { clazz }); } else { for (Field field : Whitebox.getFields(clazz, fieldNames)) { MockRepository.addFieldToSuppress(field); } } }
@SuppressWarnings("unused") private void initializeInterceptionSettings() { MockPolicyInterceptionSettings interceptionSettings = getInterceptionSettings(); for (Method method : interceptionSettings.getMethodsToSuppress()) { MockRepository.addMethodToSuppress(method); } for (Entry<Method, InvocationHandler> entry : interceptionSettings.getProxiedMethods().entrySet()) { MockRepository.putMethodProxy(entry.getKey(), entry.getValue()); } for (Entry<Method, Object> entry : interceptionSettings.getStubbedMethods().entrySet()) { final Method method = entry.getKey(); final Object className = entry.getValue(); MockRepository.putMethodToStub(method, className); } for (Field field : interceptionSettings.getFieldsToSuppress()) { MockRepository.addFieldToSuppress(field); } for (String type : interceptionSettings.getFieldTypesToSuppress()) { MockRepository.addFieldTypeToSuppress(type); } }