public static Customer customer(final CustomerDTO customer) { return Customer.of(Customer.Id.of(customer.id), name(customer.name)); }
public static Customer of(final Id id, final Name name) { return new Customer(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()); }
private Customer customer(final CustomerEntity customer) { return Customer.of(id(customer), name(customer.getName())); }
@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()); }
@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(customerAdapter.customers()).willReturn(customersDTO()); final Object document = parseJson(mvc, API_CUSTOMERS_PATH); final JSONArray rels = JsonPath.read(document, "$.links..rel"); assertThat(rels).containsExactlyInAnyOrder(REL_SELF, REL_HOME, REL_CREATE, REL_CUSTOMER_PREFIX + customer().getId().getId()); }
public static Customer customer() { return Customer.of(Customer.Id.of(123L), name()); }
@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 Customer customer() { return Customer.of(Customer.Id.of(123L), 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()); } }
public static Customer customer() { return Customer.of(Customer.Id.of(123L), name()); }