@Test public void testUpdate01() { PriceCalculateOutput priceCalculateOutput = new PriceCalculateOutput(); priceCalculateOutput.setSumPrice(100000); priceCalculateOutput.setAdultCount(1); priceCalculateOutput.setChildCount(2); when(priceCalculateSerivce.calculatePrice(10000, 1, 2)).thenReturn( priceCalculateOutput); ReservationUpdateInput input = new ReservationUpdateInput(); input.setReserveNo("foo"); input.setAdultCount(1); input.setChildCount(2); Reserve reserve = new Reserve(); TourInfo tour = new TourInfo("aaa"); tour.setArrival(new Arrival()); tour.setDeparture(new Departure()); tour.setBasePrice(10000); reserve.setTourInfo(tour); when(reserveRepository.findById("foo")).thenReturn(Optional.of( reserve)); when(reserveRepository.findOneForUpdate("foo")).thenReturn(reserve); when(reserveRepository.save(reserve)).thenReturn(reserve); ReservationUpdateOutput output = reserveService.update(input); assertThat(output, is(output)); }
@Override public ReservationUpdateOutput update( ReservationUpdateInput input) throws BusinessException { Reserve reserve = findOne(input.getReserveNo()); beanMapper.map(input, reserve, "reserve_map_nonnull"); TourInfo info = reserve.getTourInfo(); PriceCalculateOutput price = priceCalculateService.calculatePrice(info .getBasePrice(), input.getAdultCount(), input.getChildCount()); reserve.setSumPrice(price.getSumPrice()); reserveRepository.save(reserve); ReservationUpdateOutput output = new ReservationUpdateOutput(); output.setReserve(reserve); output.setPriceCalculateOutput(price); output.setPaymentTimeLimit(info.getPaymentLimit().toDate()); info.getDeparture().getDepName(); info.getArrival().getArrName(); return output; }
ReserveServiceImpl implements ReserveService { @Override public ReservationUpdateOutput update( ReservationUpdateInput input) throws BusinessException { Reserve reserve = findOne(input.getReserveNo()); beanMapper.map(input, reserve, "reserve_map_nonnull"); TourInfo info = reserve.getTourInfo(); PriceCalculateOutput price = priceCalculateService.calculatePrice(info .getBasePrice(), input.getAdultCount(), input.getChildCount()); reserve.setSumPrice(price.getSumPrice()); reserveRepository.save(reserve); ReservationUpdateOutput output = new ReservationUpdateOutput(); output.setReserve(reserve); output.setPriceCalculateOutput(price); output.setPaymentTimeLimit(info.getPaymentLimit().toDate()); info.getDeparture().getDepName(); info.getArrival().getArrName(); return output; } }
ReserveServiceImpl implements ReserveService { @Override public ReservationUpdateOutput update( ReservationUpdateInput input) throws BusinessException { Reserve reserve = findOne(input.getReserveNo()); beanMapper.map(input, reserve, "reserve_map_nonnull"); TourInfo info = reserve.getTourInfo(); PriceCalculateOutput price = priceCalculateService.calculatePrice(info .getBasePrice(), input.getAdultCount(), input.getChildCount()); reserve.setSumPrice(price.getSumPrice()); reserveRepository.save(reserve); ReservationUpdateOutput output = new ReservationUpdateOutput(); output.setReserve(reserve); output.setPriceCalculateOutput(price); output.setPaymentTimeLimit(info.getPaymentLimit().toDate()); info.getDeparture().getDepName(); info.getArrival().getArrName(); return output; }  }
ReserveServiceImpl implements ReserveService { @Override public ReservationUpdateOutput update( ReservationUpdateInput input) throws BusinessException { Reserve reserve = findOne(input.getReserveNo()); beanMapper.map(input, reserve, "reserve_map_nonnull"); TourInfo info = reserve.getTourInfo(); PriceCalculateOutput price = priceCalculateService.calculatePrice(info .getBasePrice(), input.getAdultCount(), input.getChildCount()); reserve.setSumPrice(price.getSumPrice()); reserveRepository.save(reserve); ReservationUpdateOutput output = new ReservationUpdateOutput(); output.setReserve(reserve); output.setPriceCalculateOutput(price); output.setPaymentTimeLimit(info.getPaymentLimit().toDate()); info.getDeparture().getDepName(); info.getArrival().getArrName(); return output; }  @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); }
ReserveServiceImpl implements ReserveService { @Override public ReservationUpdateOutput update( ReservationUpdateInput input) throws BusinessException { Reserve reserve = findOne(input.getReserveNo()); beanMapper.map(input, reserve, "reserve_map_nonnull"); TourInfo info = reserve.getTourInfo(); PriceCalculateOutput price = priceCalculateService.calculatePrice(info .getBasePrice(), input.getAdultCount(), input.getChildCount()); reserve.setSumPrice(price.getSumPrice()); reserveRepository.save(reserve); ReservationUpdateOutput output = new ReservationUpdateOutput(); output.setReserve(reserve); output.setPriceCalculateOutput(price); output.setPaymentTimeLimit(info.getPaymentLimit().toDate()); info.getDeparture().getDepName(); info.getArrival().getArrName(); return output; }  @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);  }