@Test public void updateAddress() { final Receiver receiver = buildReceiver("서울"); final Address newAddress = buildAddress("부산"); given(receiverRepository.findOne(anyLong())).willReturn(receiver); final Receiver updateAddress = receiverService.updateAddress(anyLong(), newAddress); System.out.println(updateAddress); }
@Transactional public Receiver updateAddress(long id, Address address) { final Receiver receiver = findById(id); receiver.updateAddress(address); return receiver; }
ReceiverService { @Transactional public Receiver updateAddress(long id, Address address) { final Receiver receiver = findById(id); receiver.updateAddress(address); return receiver; } }
ReceiverService { @Transactional public Receiver updateAddress(long id, Address address) { final Receiver receiver = findById(id); receiver.updateAddress(address); return receiver; } @Builder  ReceiverService(ReceiverRepository receiverRepository); }
ReceiverService { @Transactional public Receiver updateAddress(long id, Address address) { final Receiver receiver = findById(id); receiver.updateAddress(address); return receiver; } @Builder  ReceiverService(ReceiverRepository receiverRepository); @Transactional(readOnly = true) Receiver findById(long id); @Transactional Receiver create(Receiver receiver); @Transactional Receiver updateAddress(long id, Address address); }
ReceiverService { @Transactional public Receiver updateAddress(long id, Address address) { final Receiver receiver = findById(id); receiver.updateAddress(address); return receiver; } @Builder  ReceiverService(ReceiverRepository receiverRepository); @Transactional(readOnly = true) Receiver findById(long id); @Transactional Receiver create(Receiver receiver); @Transactional Receiver updateAddress(long id, Address address);  }