@Test @Parameters(method = "values") public void test_creation(final Class<? extends Exception> expectedException, final long id, final Name name) { Class<? extends Exception> actualException = NoException.class; try { Customer.of(Customer.Id.of(id), name); } catch (Exception ex) { actualException = ex.getClass(); } assertThat(actualException).isEqualTo(expectedException); }
@Test public void shouldGetCustomer() throws Exception { given(customerJpaRepository.findById(any(Long.class))).willReturn(Optional.of(customerEntity())); final Customer customer = customerDetailsRepository.customer(Customer.Id.of(123L)); final Name name = customer.getName(); assertThat(name.firstName().value()).isEqualTo(customerEntity().getName().getFirstName()); assertThat(name.lastName().value()).isEqualTo(customerEntity().getName().getLastName()); } }
@Test public void shouldGetCustomer() throws Exception { given(customerRepository.customer(any())).willReturn(customer()); final Customer customer = customerDetailsUseCase.customer(Customer.Id.of(123L)); final Name name = customer.getName(); assertThat(name.firstName()).isEqualTo(customer().getName().firstName()); assertThat(name.lastName()).isEqualTo(customer().getName().lastName()); } }
public static Customer customer() { return Customer.of(Customer.Id.of(123L), name()); }
public static Customer customer() { return Customer.of(Customer.Id.of(123L), name()); }
public static Customer customer(final CustomerDTO customer) { return Customer.of(Customer.Id.of(customer.id), name(customer.name)); }
public static Customer customer() { return Customer.of(Customer.Id.of(123L), name()); }
public CustomerDTO customer(final long customerId) { final Customer customer = customerService.customer(Customer.Id.of(customerId)); return CustomerDTOFactory.customer(customer); }
public static Customer customer() { return Customer.of(Customer.Id.of(123L), name()); }
private Customer.Id id(final CustomerEntity customer) { return Customer.Id.of(customer.getId()); }
public void delete(final long customerId) { customerEditService.delete(Customer.Id.of(customerId)); } }