Skip to content

Commit

Permalink
#218 Fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
loreV committed Jun 7, 2022
1 parent e09e22a commit 184b657
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/java/org/sc/data/repository/TrailDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public List<Trail> updateTrailNamePlaceReference(final String trailId,
new Document(Trail.ID, trailId)
.append(Trail.LOCATIONS + DOT + PlaceRef.PLACE_ID, placeId),
new Document($_SET,
new Document(Trail.LOCATIONS + DOLLAR + PlaceRef.NAME, placeName)));
new Document(Trail.LOCATIONS + DOT + DOLLAR + DOT + PlaceRef.NAME, placeName)));

return getTrailById(trailId, TrailSimplifierLevel.LOW);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
Expand All @@ -40,6 +41,7 @@ public class CrosswayIntegrationTest extends ImportTrailIT {

public static final String LEVEL = TrailSimplifierLevel.FULL.toString();
public static final int TWELVE_SECONDS = 12000;
public static final String EXPECTED_NAME = "Crocevia 100BO, 101BO";

@Autowired
private DataSource dataSource;
Expand Down Expand Up @@ -106,7 +108,7 @@ public void setUp() {
.coordinates(coordinates).build();

TrailImportDto crossingTrail = new TrailImportDto(
EXPECTED_TRAIL_CODE,
"101BO",
"crosswayTrail",
"crossing trail desc",
ANY_OFFICIAL_ETA, placeStartRef,
Expand All @@ -121,17 +123,28 @@ placeFinalRef, asList(placeStartRef, crosswayRefDto, placeFinalRef), emptyList()

crossingImportedTrailResponse = adminTrailController.importTrail(crossingTrail);
crossingImportedTrail = crossingImportedTrailResponse.getContent().stream().findFirst().get();


}

@Test
public void shouldUpdateAutomaticCrossway() {
final TrailResponse byId = trailController.getById(importedTrail.getId(), TrailSimplifierLevel.LOW);
final PlaceResponse placeByIdResponse = placeController.get(createdCrosswayPlace.getId());
final TrailResponse retrievedInitialTrailResp = trailController.getById(importedTrail.getId(), TrailSimplifierLevel.LOW);
final TrailResponse retrievedCrossingTrailResp = trailController.getById(crossingImportedTrail.getId(), TrailSimplifierLevel.LOW);
final TrailDto retrievedTrail = retrievedInitialTrailResp.getContent().stream().findFirst().get();
final TrailDto retrievedCrossingTrail = retrievedCrossingTrailResp.getContent().stream().findFirst().get();

final String placeId = createdCrosswayPlace.getId();
final PlaceResponse placeByIdResponse = placeController.get(placeId);
final PlaceDto placeDto = placeByIdResponse.getContent().get(0);

assertThat(placeDto.getName()).isEqualTo("Crocevia 100BO, 123BO");
assertThat(placeDto.getName()).isEqualTo(EXPECTED_NAME);
assertThat((retrievedTrail)
.getLocations().stream().filter(it-> it.getPlaceId().equals(placeId))
.collect(Collectors.toList()).stream().findFirst().get().getName())
.isEqualTo(EXPECTED_NAME);
assertThat((retrievedCrossingTrail)
.getLocations().stream()
.filter(it-> it.getPlaceId().equals(placeId)).collect(Collectors.toList()).stream().findFirst().get().getName())
.isEqualTo(EXPECTED_NAME);
}

private void createFirstTrailWithAutoCrossway() {
Expand All @@ -143,7 +156,7 @@ private void createFirstTrailWithAutoCrossway() {
Assertions.assertThat(crosswayPlace.getContent()).isNotEmpty();
Assertions.assertThat(lastPlace.getContent()).isNotEmpty();

PlaceDto createdFirstPlace = firstPlace.getContent().get(0);
PlaceDto createdFirstPlace = firstPlace.getContent().stream().findFirst().get();
PlaceRefDto placeStartRef = new PlaceRefDto(createdFirstPlace.getName(),
createdFirstPlace.getCoordinates().get(0), createdFirstPlace.getId(), emptyList(), false);

Expand Down

0 comments on commit 184b657

Please sign in to comment.