BLogicResolverImpl implements BLogicResolver { @Override public BLogic resolveBLogic(ApplicationContext ctx, String jobAppCd) { BLogic blogic = null; String blogicBeanName = getBLogicBeanName(jobAppCd); if (ctx.containsBean(blogicBeanName)) { return ctx.getBean(blogicBeanName, BLogic.class); } String decapitalizedName = Introspector.decapitalize(blogicBeanName); try { blogic = ctx.getBean(decapitalizedName, BLogic.class); } catch (BeansException e) { LOGGER.error(LogId.EAL025009, decapitalizedName); throw e; } return blogic; }  @Override BLogic resolveBLogic(ApplicationContext ctx, String jobAppCd);  }
@Test public void testResolveBLogic01() { ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "beansDef/B000003.xml"); BLogic blogic = blogicResolverImpl.resolveBLogic(applicationContext, "B000003"); assertTrue(blogic instanceof BLogic); }
@Test public void testResolveBLogic02() { ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "beansDef/B000003.xml"); try { blogicResolverImpl.resolveBLogic(applicationContext, "DEFINE_NOT_EXIST"); fail(); } catch (Exception e) { assertTrue(e instanceof NoSuchBeanDefinitionException); } assertThat(logger.getLoggingEvents(), is(asList(error( "[EAL025009] BLogic bean not found. beanName:DEFINE_NOT_EXISTBLogic")))); }
@Test public void testResolveBLogic03() { ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "beansDef/B000003.xml"); ApplicationContext mockContext = spy(applicationContext); BLogic mockBLogic = mock(BLogic.class); doReturn(false).when(mockContext).containsBean("B000003BLogic"); doReturn(mockBLogic).when(mockContext).getBean("b000003BLogic", BLogic.class); BLogic blogic = blogicResolverImpl.resolveBLogic(mockContext, "B000003"); assertTrue(blogic instanceof BLogic); }