ReserveServiceImpl implements ReserveService { @Override public List<Reserve> findAllByCustomerCode(String customerCode) { Customer customer = new Customer(customerCode); List<Reserve> reserves = reserveRepository.findAllByCustomer(customer); return reserves; }  @Override Reserve findOne(String reserveNo); @Override List<Reserve> findAllByCustomerCode(String customerCode); @Override ReserveTourOutput reserve(
            ReserveTourInput input); @Override void cancel(String reserveNo); @Override ReservationUpdateOutput update(
            ReservationUpdateInput input);  }
@Test public void testFindByCustomerCode01() { TourInfo tour1 = new TourInfo("01"); TourInfo tour2 = new TourInfo("02"); Reserve reserve1 = new Reserve("001"); Reserve reserve2 = new Reserve("002"); reserve1.setTourInfo(tour1); reserve2.setTourInfo(tour2); tour1.setTourDays(2); tour2.setTourDays(4); List<Reserve> reserves = Arrays.asList(reserve1, reserve2); Customer c = new Customer("xxxx"); when(reserveRepository.findAllByCustomer(c)).thenReturn(reserves); when(tourInfoSharedService.isOverPaymentLimit(tour1)).thenReturn(false); when(tourInfoSharedService.isOverPaymentLimit(tour2)).thenReturn(true); List<Reserve> result = reserveService.findAllByCustomerCode("xxxx"); assertThat(result, is(notNullValue())); assertThat(result.size(), is(2)); assertThat(result.get(0), is(reserve1)); assertThat(result.get(1), is(reserve2)); }
@Test public void testFindByCustomerCode03() { Customer c = new Customer("xxxx"); when(reserveRepository.findAllByCustomer(c)).thenReturn( new ArrayList<Reserve>()); List<Reserve> result = reserveService.findAllByCustomerCode("xxxx"); assertThat(result, is(notNullValue())); assertThat(result.size(), is(0)); }