public static CustomerDTO customer(final Customer customer) { return new CustomerDTO(customer.getId().getId(), name(customer.getName())); }
private CustomerEntity customerEntity(final Customer customer) { final long id = customer.getId().getId(); final Name name = name(customer.getName()); return new CustomerEntity(id, name); }
@Test public void shouldGetCustomers() throws Exception { given(customerRepository.customers()).willReturn(ImmutableList.of(customer())); final List<Customer> customers = customerDetailsUseCase.customers(); assertThat(customers).isNotEmpty(); assertThat(customers).hasSize(1); final Name name = customers.get(0).getName(); assertThat(name.firstName()).isEqualTo(customer().getName().firstName()); assertThat(name.lastName()).isEqualTo(customer().getName().lastName()); }
@Test public void shouldGetCustomers() throws Exception { given(customerService.customers()).willReturn(ImmutableList.of(customer())); final CustomersDTO customersDTO = customerAdapter.customers(); assertThat(customersDTO.customers).hasSize(1); final CustomerDTO customerDTO = customersDTO.customers.get(0); assertThat(customerDTO.name.firstName).isEqualTo(customer().getName().firstName().value()); assertThat(customerDTO.name.lastName).isEqualTo(customer().getName().lastName().value()); }
@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()); } }
@Test public void shouldGetCustomer() throws Exception { given(customerService.customer(any(Customer.Id.class))).willReturn(customer()); final CustomerDTO customerDTO = customerAdapter.customer(123L); assertThat(customerDTO.name.firstName).isEqualTo(customer().getName().firstName().value()); assertThat(customerDTO.name.lastName).isEqualTo(customer().getName().lastName().value()); }
@Test public void shouldGetCustomers() throws Exception { given(customerJpaRepository.findAll()).willReturn(ImmutableList.of(customerEntity())); final List<Customer> customers = customerDetailsRepository.customers(); assertThat(customers).isNotEmpty(); assertThat(customers).hasSize(1); final Name name = customers.get(0).getName(); assertThat(name.firstName().value()).isEqualTo(customerEntity().getName().getFirstName()); assertThat(name.lastName().value()).isEqualTo(customerEntity().getName().getLastName()); }
public static CustomerEntity customerEntity(final Customer customer) { final long id = customer.getId().getId(); final Name name = name(customer.getName()); return new CustomerEntity(id, name); }
@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()); } }