@Test public void startsANewPickupOrder() { Customer customer = new Customer("Finn", "*****@*****.**", "+1(999)999-2187"); Order expectedResult = new Order(OrderType.FOR_PICKUP, customer); when(mockCustomerRepository.findOne(1L)).thenReturn(customer); Order result = orderService.startNewPickupOrder(1L); assertThat(result, is(equalTo(expectedResult))); verify(mockCustomerRepository).findOne(1L); verify(mockOrderRepository).save(expectedResult); }
@Test public void startsANewDeliveryOrder() { Customer customer = new Customer("Finn", "*****@*****.**", "+1(999)999-2187"); customer.setAddress(new Address("2187 Jakku Ave.", "Jakku", "CA", "92187")); Order expectedResult = new Order(OrderType.FOR_DELIVERY, customer); when(mockCustomerRepository.findOne(1L)).thenReturn(customer); Order result = orderService.startNewDeliveryOrder(1L); assertThat(result, is(equalTo(expectedResult))); verify(mockCustomerRepository).findOne(1L); verify(mockOrderRepository).save(expectedResult); }