@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 shouldDeleteCustomer() throws Exception { customerOperationsRepository.delete(customer().getId()); verify(customerJpaRepository, times(1)).deleteById(customer().getId().getId()); } }
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() { 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 Id of(final long id) { return new Id(id); }
private Customer.Id id(final CustomerEntity customer) { return Customer.Id.of(customer.getId()); }
public CustomerDTO customer(final long customerId) { final Customer customer = customerService.customer(Customer.Id.of(customerId)); return CustomerDTOFactory.customer(customer); }
@Override public void delete(final Customer.Id customerId) { customerJpaRepository.deleteById(customerId.getId()); }
public static Customer customer() { return Customer.of(Customer.Id.of(123L), name()); }
public void delete(final long customerId) { customerEditService.delete(Customer.Id.of(customerId)); } }
public static CustomerDTO customer(final Customer customer) { return new CustomerDTO(customer.getId().getId(), 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()); } }
private CustomerEntity customerEntity(final Customer customer) { final long id = customer.getId().getId(); final Name name = name(customer.getName()); return new CustomerEntity(id, name); }
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 shouldDeleteCustomer() throws Exception { customerAdapter.delete(customer().getId().getId()); verify(customerEditService, times(1)).delete(customer().getId()); } }
@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 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()); }