コード例 #1
0
  @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);
  }
コード例 #2
0
  @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);
  }