All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kubek2k.mockito.spring.MockitoSpyBeanPostProcessor Maven / Gradle / Ivy

  package org.kubek2k.mockito.spring;

import org.mockito.Mockito;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class MockitoSpyBeanPostProcessor implements BeanPostProcessor {

    private String beanName;

    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (this.beanName.equals(beanName)) {
            return Mockito.spy(bean);
        } else {
            return bean;
        }
    }
    public void setBeanName(String matchingName) {
        this.beanName = matchingName;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy