@Test
void should_create_location_and_generate_id() {

    // arrange
    LocationEntity newEntity = locationEntity(testLocation);
    when(crudRepository.save(locationEntityCaptor.capture())).thenReturn(newEntity);
    Coordinates savedCoordinates = Coordinates.valueOf(0.00213, 32.777);
    String savedDescription = "new location";
    // act
    Location newLocation = repository.createLocation(savedCoordinates, savedDescription);
    // assert
    // -- the correct values were used to save the entity
    LocationEntity savedLocation = locationEntityCaptor.getValue();
    assertThat(savedLocation.getLatitude()).isEqualTo(savedCoordinates.latitude());
    assertThat(savedLocation.getLongitude()).isEqualTo(savedCoordinates.longitude());
    assertThat(savedLocation.getDescription()).isEqualTo(savedDescription);
    // -- created domain location is equal to the entity returned by repository.save()
    // This may be confusing but that's the contract of Spring Repository API.
    // The entity instance that is being saved is meant to be discarded. The returned instance should be used
    // for further operations as the save() operation may update it (for example generate the ID).
    assertThat(newLocation.id()).isEqualTo(newEntity.getId());
    assertThat(newLocation.coordinates())
            .isEqualTo(new Coordinates(newEntity.getLatitude(), newEntity.getLongitude()));
    assertThat(newLocation.description()).isEqualTo(newEntity.getDescription());
}