List<DiscountPolicy>는 DiscountPolicy 타입으로 조회한 모든 스프링 빈을 담아준다.
만약 해당 타입의 스프링 빈이 없다면 빈 컬렉션을 주입한다.
publicclassAllBeanTest { @TestvoidfindAllBean() {ApplicationContext ac =newAnnotationConfigApplicationContext(AutoAppConfig.class,DiscountService.class);DiscountService discountService =ac.getBean(DiscountService.class);Member member =newMember(1L,"userA",Grade.VIP);int discountPrice =discountService.discount(member,10000,"fixDiscountPolicy");assertThat(discountService).isInstanceOf(DiscountService.class);assertThat(discountPrice).isEqualTo(1000);int rateDiscountPrice =discountService.discount(member,20000,"rateDiscountPolicy");assertThat(rateDiscountPrice).isEqualTo(2000); }staticclassDiscountService {...// 넘겨준 정책이 discountCode가 되어 해당 정책을 찾아 계산한 뒤 리턴한다.publicintdiscount(Member member,int price,String discountCode) {DiscountPolicy discountPolicy =policyMap.get(discountCode);returndiscountPolicy.discount(member, price); } }}