### Question:
AWSBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (CommonBeans.BEAN_BASE_CONF.equals(beanName)) { Configuration baseConf = (Configuration) bean; bindS3AFileSystem.bindFileSystem(baseConf); if (baseConf.get(CREDENTIAL_PROVIDER_PATH) != null) { s3CredentialsUtils.setS3Credentials(baseConf); } return baseConf; } return bean; } @Autowired  AWSBeanPostProcessor(BindS3AFileSystem bindS3AFileSystem, S3CredentialsUtils s3CredentialsUtils); @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName);  }### Answer:
@Test public void baseConfBindFileSystem() throws Exception { Configuration conf = new Configuration(); Object result = postProcessor.postProcessAfterInitialization(conf, "baseConf"); Configuration resultConf = (Configuration) result; assertThat(resultConf, is(conf)); verify(bindS3AFileSystem).bindFileSystem(conf); verifyZeroInteractions(s3CredentialsUtils); }
@Test public void baseConfs3Credentials() throws Exception { Configuration conf = new Configuration(); conf.set(CREDENTIAL_PROVIDER_PATH, "path"); Object result = postProcessor.postProcessAfterInitialization(conf, "baseConf"); Configuration resultConf = (Configuration) result; assertThat(resultConf, is(conf)); verify(bindS3AFileSystem).bindFileSystem(conf); verify(s3CredentialsUtils).setS3Credentials(conf); }
@Test public void postProcessAfterInitializationReturnsBean() throws Exception { Object bean = new Object(); Object result = postProcessor.postProcessAfterInitialization(bean, "bean"); assertThat(result, is(bean)); }