diff --git a/pom.xml b/pom.xml
index 91191439..bd7b3b1f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
false
4.4.4
2.34
- 4.0.1
+ 4.0.2
2.11.0
1.17
3.37.0
diff --git a/src/main/java/no/entur/antu/config/NetexDataConfig.java b/src/main/java/no/entur/antu/config/NetexDataConfig.java
index f6a2591b..1935bf75 100644
--- a/src/main/java/no/entur/antu/config/NetexDataConfig.java
+++ b/src/main/java/no/entur/antu/config/NetexDataConfig.java
@@ -11,6 +11,7 @@
import no.entur.antu.netexdata.DefaultNetexDataRepository;
import no.entur.antu.netexdata.NetexDataResource;
import org.entur.netex.validation.validator.jaxb.NetexDataRepository;
+import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -29,6 +30,7 @@ NetexDataResource netexDataResource() {
@Profile("!test")
NetexDataRepository netexDataRepository(
NetexDataResource netexDataResource,
+ RedissonClient redissonClient,
@Qualifier(
SCHEDULED_STOP_POINT_AND_QUAY_ID_CACHE
) Map> scheduledStopPointAndQuayIdCache,
@@ -45,6 +47,7 @@ NetexDataRepository netexDataRepository(
) {
return new DefaultNetexDataRepository(
netexDataResource,
+ redissonClient,
scheduledStopPointAndQuayIdCache,
serviceLinksAndFromToScheduledStopPointIdCache,
lineInfoCache,
diff --git a/src/main/java/no/entur/antu/config/TimetableDataValidatorConfig.java b/src/main/java/no/entur/antu/config/TimetableDataValidatorConfig.java
index 2cf13998..6f4961f5 100644
--- a/src/main/java/no/entur/antu/config/TimetableDataValidatorConfig.java
+++ b/src/main/java/no/entur/antu/config/TimetableDataValidatorConfig.java
@@ -320,14 +320,14 @@ public NetexValidatorsRunner timetableDataValidatorsRunner(
);
List netexTimetableDatasetValidators = List.of(
- duplicateLineNameValidator
- // stopPointsInVehicleJourneyValidator
+ duplicateLineNameValidator,
+ stopPointsInVehicleJourneyValidator
);
List commonDataCollectors = List.of(
lineInfoCollector,
- // serviceJourneyStopsCollector,
- serviceJourneyInterchangeInfoCollector
+ serviceJourneyInterchangeInfoCollector,
+ serviceJourneyStopsCollector
);
return NetexValidatorsRunner
diff --git a/src/main/java/no/entur/antu/netexdata/DefaultNetexDataRepository.java b/src/main/java/no/entur/antu/netexdata/DefaultNetexDataRepository.java
index a5c52a68..9574d98a 100644
--- a/src/main/java/no/entur/antu/netexdata/DefaultNetexDataRepository.java
+++ b/src/main/java/no/entur/antu/netexdata/DefaultNetexDataRepository.java
@@ -2,11 +2,14 @@
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
import no.entur.antu.exception.AntuException;
import org.entur.netex.validation.validator.jaxb.*;
import org.entur.netex.validation.validator.model.*;
+import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -21,6 +24,7 @@ public class DefaultNetexDataRepository implements NetexDataRepository {
);
private final NetexDataResource netexDataResource;
+ private final RedissonClient redissonClient;
private final Map> scheduledStopPointAndQuayIdCache;
private final Map> serviceLinksAndFromToScheduledStopPointIdCache;
private final Map> lineInfoCache;
@@ -29,6 +33,7 @@ public class DefaultNetexDataRepository implements NetexDataRepository {
public DefaultNetexDataRepository(
NetexDataResource netexDataResource,
+ RedissonClient redissonClient,
Map> scheduledStopPointAndQuayIdCache,
Map> serviceLinksAndFromToScheduledStopPointIdCache,
Map> lineInfoCache,
@@ -36,6 +41,7 @@ public DefaultNetexDataRepository(
Map> serviceJourneyInterchangeInfoCache
) {
this.netexDataResource = netexDataResource;
+ this.redissonClient = redissonClient;
this.scheduledStopPointAndQuayIdCache = scheduledStopPointAndQuayIdCache;
this.serviceLinksAndFromToScheduledStopPointIdCache =
serviceLinksAndFromToScheduledStopPointIdCache;
@@ -100,56 +106,36 @@ public List lineNames(String validationReportId) {
return lineInfoForReportId.stream().map(SimpleLine::fromString).toList();
}
- @Override
- public List serviceJourneyStops(
- String validationReportId,
- ServiceJourneyId serviceJourneyId
+ public Map> serviceJourneyStops(
+ String validationReportId
) {
- Map> serviceJourneyStopsForReport =
- serviceJourneyStopsCache.get(validationReportId);
- if (serviceJourneyStopsForReport == null) {
- throw new AntuException(
- "ServiceJourneyStops cache not found for validation report with id: " +
- validationReportId
+ return serviceJourneyStopsCache
+ .keySet()
+ .stream()
+ .filter(k -> k.startsWith(validationReportId))
+ .map(serviceJourneyStopsCache::get)
+ .flatMap(m -> m.entrySet().stream())
+ .collect(
+ Collectors.toMap(
+ k -> ServiceJourneyId.ofValidId(k.getKey()),
+ v ->
+ v.getValue().stream().map(ServiceJourneyStop::fromString).toList(),
+ (p, n) -> n
+ )
);
- }
- return Optional
- .ofNullable(serviceJourneyStopsForReport.get(serviceJourneyId.id()))
- .map(serviceJourneyStops ->
- serviceJourneyStops
- .stream()
- .map(ServiceJourneyStop::fromString)
- .filter(ServiceJourneyStop::isValid)
- .toList()
- )
- .orElse(List.of());
- }
-
- @Override
- public boolean hasServiceJourneyInterchangeInfos(String validationReportId) {
- List serviceJourneyInterchangeInfos =
- serviceJourneyInterchangeInfoCache.get(validationReportId);
- return (
- serviceJourneyInterchangeInfos != null &&
- !serviceJourneyInterchangeInfos.isEmpty()
- );
}
@Override
public List serviceJourneyInterchangeInfos(
String validationReportId
) {
- List serviceJourneyInterchangeInfosForReport =
- serviceJourneyInterchangeInfoCache.get(validationReportId);
- if (serviceJourneyInterchangeInfosForReport == null) {
- throw new AntuException(
- "ServiceJourneyInterchangeInfoCache not found for validation report with id: " +
- validationReportId
- );
- }
-
- return serviceJourneyInterchangeInfosForReport
+ return Optional
+ .ofNullable(serviceJourneyInterchangeInfoCache)
+ .map(Map::entrySet)
.stream()
+ .flatMap(Set::stream)
+ .filter(entry -> entry.getKey().startsWith(validationReportId))
+ .flatMap(entry -> entry.getValue().stream())
.map(ServiceJourneyInterchangeInfo::fromString)
.toList();
}
@@ -176,7 +162,7 @@ public void fillNetexDataCache(
.getFromToScheduledStopPointIdPerServiceLinkId()
.entrySet()
.stream()
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
serviceLinksAndFromToScheduledStopPointIdCache.merge(
validationReportId,
@@ -199,7 +185,12 @@ public void cleanUp(String validationReportId) {
scheduledStopPointAndQuayIdCache.remove(validationReportId);
serviceLinksAndFromToScheduledStopPointIdCache.remove(validationReportId);
lineInfoCache.remove(validationReportId);
- serviceJourneyStopsCache.remove(validationReportId);
- serviceJourneyInterchangeInfoCache.remove(validationReportId);
+ redissonClient.getKeys().deleteByPattern(validationReportId + '*');
+ serviceJourneyStopsCache
+ .keySet()
+ .removeIf(k -> k.startsWith(validationReportId));
+ serviceJourneyInterchangeInfoCache
+ .keySet()
+ .removeIf(k -> k.startsWith(validationReportId));
}
}
diff --git a/src/main/java/no/entur/antu/netexdata/collectors/ServiceJourneyInterchangeInfoCollector.java b/src/main/java/no/entur/antu/netexdata/collectors/ServiceJourneyInterchangeInfoCollector.java
index a73d265e..19af0dc8 100644
--- a/src/main/java/no/entur/antu/netexdata/collectors/ServiceJourneyInterchangeInfoCollector.java
+++ b/src/main/java/no/entur/antu/netexdata/collectors/ServiceJourneyInterchangeInfoCollector.java
@@ -1,12 +1,15 @@
package no.entur.antu.netexdata.collectors;
-import java.util.ArrayList;
+import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_INTERCHANGE_INFO_CACHE;
+
import java.util.List;
import java.util.Map;
+import java.util.stream.Stream;
import no.entur.antu.validation.AntuNetexData;
import org.entur.netex.validation.validator.jaxb.JAXBValidationContext;
import org.entur.netex.validation.validator.jaxb.NetexDataCollector;
import org.entur.netex.validation.validator.model.ServiceJourneyInterchangeInfo;
+import org.redisson.api.RList;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
@@ -35,20 +38,18 @@ protected void collectDataFromLineFile(
validationContext.getStopPlaceRepository()
);
- antuNetexData
- .serviceJourneyInterchanges()
- .map(serviceJourneyInterchange ->
- ServiceJourneyInterchangeInfo.of(
- validationContext.getFileName(),
- serviceJourneyInterchange
- )
- )
- .forEach(serviceJourneyInterchangeInfo ->
- addData(
- antuNetexData.validationReportId(),
- serviceJourneyInterchangeInfo
+ addData(
+ validationContext.getFileName(),
+ antuNetexData.validationReportId(),
+ antuNetexData
+ .serviceJourneyInterchanges()
+ .map(serviceJourneyInterchange ->
+ ServiceJourneyInterchangeInfo.of(
+ validationContext.getFileName(),
+ serviceJourneyInterchange
+ )
)
- );
+ );
}
@Override
@@ -59,20 +60,31 @@ protected void collectDataFromCommonFile(
}
private void addData(
+ String fileName,
String validationReportId,
- ServiceJourneyInterchangeInfo serviceJourneyInterchangeInfo
+ Stream serviceJourneyInterchangeInfos
) {
RLock lock = redissonClient.getLock(validationReportId);
try {
lock.lock();
- serviceJourneyInterchangeInfoCache.merge(
- validationReportId,
- new ArrayList<>(List.of(serviceJourneyInterchangeInfo.toString())),
- (existingList, newList) -> {
- existingList.addAll(newList);
- return existingList;
- }
+ String keyName =
+ validationReportId +
+ "_" +
+ SERVICE_JOURNEY_INTERCHANGE_INFO_CACHE +
+ "_" +
+ fileName;
+
+ RList serviceJourneyInterchangeInfosListCache =
+ redissonClient.getList(keyName);
+ serviceJourneyInterchangeInfosListCache.addAll(
+ serviceJourneyInterchangeInfos
+ .map(ServiceJourneyInterchangeInfo::toString)
+ .toList()
+ );
+ serviceJourneyInterchangeInfoCache.put(
+ keyName,
+ serviceJourneyInterchangeInfosListCache
);
} finally {
if (lock.isHeldByCurrentThread()) {
diff --git a/src/main/java/no/entur/antu/netexdata/collectors/ServiceJourneyStopsCollector.java b/src/main/java/no/entur/antu/netexdata/collectors/ServiceJourneyStopsCollector.java
index 87719efb..0662458d 100644
--- a/src/main/java/no/entur/antu/netexdata/collectors/ServiceJourneyStopsCollector.java
+++ b/src/main/java/no/entur/antu/netexdata/collectors/ServiceJourneyStopsCollector.java
@@ -1,5 +1,7 @@
package no.entur.antu.netexdata.collectors;
+import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_STOPS_CACHE;
+
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -9,6 +11,7 @@
import org.entur.netex.validation.validator.model.ScheduledStopPointId;
import org.entur.netex.validation.validator.model.ServiceJourneyStop;
import org.redisson.api.RLock;
+import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;
@@ -44,7 +47,6 @@ protected void collectDataFromLineFile(
Map> serviceJourneyStops = antuNetexData
.validServiceJourneys()
- // TODO: unique service journeys ids
.map(serviceJourney -> {
Map scheduledStopPointIdMap =
AntuNetexData.scheduledStopPointIdByStopPointId(
@@ -71,6 +73,7 @@ protected void collectDataFromLineFile(
addServiceJourneyStops(
validationContext.getValidationReportId(),
+ validationContext.getFileName(),
serviceJourneyStops
);
}
@@ -84,20 +87,21 @@ protected void collectDataFromCommonFile(
private void addServiceJourneyStops(
String validationReportId,
+ String filename,
Map> serviceJourneyStops
) {
RLock lock = redissonClient.getLock(validationReportId);
try {
lock.lock();
- serviceJourneyStopsCache.merge(
- validationReportId,
- serviceJourneyStops,
- (existingMap, newMap) -> {
- existingMap.putAll(newMap);
- return existingMap;
- }
+ String keyName =
+ validationReportId + "_" + SERVICE_JOURNEY_STOPS_CACHE + "_" + filename;
+
+ RMap> serviceJourneyStopsMap = redissonClient.getMap(
+ keyName
);
+ serviceJourneyStopsMap.putAll(serviceJourneyStops);
+ serviceJourneyStopsCache.put(keyName, serviceJourneyStopsMap);
} finally {
if (lock.isHeldByCurrentThread()) {
lock.unlock();
diff --git a/src/main/java/no/entur/antu/validation/AntuNetexData.java b/src/main/java/no/entur/antu/validation/AntuNetexData.java
index 15a13d5a..47f73c41 100644
--- a/src/main/java/no/entur/antu/validation/AntuNetexData.java
+++ b/src/main/java/no/entur/antu/validation/AntuNetexData.java
@@ -283,32 +283,6 @@ public ServiceJourney serviceJourney(
.orElse(null);
}
- public ServiceJourneyStop serviceJourneyStopAtScheduleStopPoint(
- VehicleJourneyRefStructure vehicleJourneyRefStructure,
- ScheduledStopPointId scheduledStopPointId
- ) {
- return serviceJourneyStops(vehicleJourneyRefStructure)
- .stream()
- .filter(serviceJourneyStop ->
- serviceJourneyStop.scheduledStopPointId().equals(scheduledStopPointId)
- )
- .findFirst()
- .orElse(null);
- }
-
- public List serviceJourneyStops(
- VehicleJourneyRefStructure vehicleJourneyRefStructure
- ) {
- return Optional
- .ofNullable(
- netexDataRepository.serviceJourneyStops(
- validationReportId(),
- ServiceJourneyId.ofValidId(vehicleJourneyRefStructure)
- )
- )
- .orElse(List.of());
- }
-
/**
* Returns the Stream of all ServiceJourneyInterchanges in all the TimeTableFrames.
*/
diff --git a/src/main/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyContext.java b/src/main/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyContext.java
index 5e1f9c76..28090638 100644
--- a/src/main/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyContext.java
+++ b/src/main/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyContext.java
@@ -1,7 +1,9 @@
package no.entur.antu.validation.validator.interchange.stoppoints;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
+import no.entur.antu.netexdata.DefaultNetexDataRepository;
import org.entur.netex.validation.validator.jaxb.NetexDataRepository;
import org.entur.netex.validation.validator.model.ServiceJourneyId;
import org.entur.netex.validation.validator.model.ServiceJourneyInterchangeInfo;
@@ -12,57 +14,49 @@ public record StopPointsInVehicleJourneyContext(
List serviceJourneyStopsForFromJourneyRef,
List serviceJourneyStopsForToJourneyRef
) {
- public static StopPointsInVehicleJourneyContext of(
- String validationReportId,
- NetexDataRepository netexDataRepository,
- ServiceJourneyInterchangeInfo serviceJourneyInterchangeInfo
- ) {
- return new StopPointsInVehicleJourneyContext(
- serviceJourneyInterchangeInfo,
- Optional
- .ofNullable(serviceJourneyInterchangeInfo.fromJourneyRef())
- .map(serviceJourneyId ->
- serviceJourneyStops(
- validationReportId,
- netexDataRepository,
- serviceJourneyId
+ public static class Builder {
+
+ private final String validationReportId;
+ private final NetexDataRepository netexDataRepository;
+ private Map> serviceJourneyIdListMap;
+
+ public Builder(
+ String validationReportId,
+ NetexDataRepository netexDataRepository
+ ) {
+ this.validationReportId = validationReportId;
+ this.netexDataRepository = netexDataRepository;
+ }
+
+ public Builder primeCache() {
+ serviceJourneyIdListMap =
+ netexDataRepository.serviceJourneyStops(validationReportId);
+ return this;
+ }
+
+ public StopPointsInVehicleJourneyContext build(
+ ServiceJourneyInterchangeInfo serviceJourneyInterchangeInfo
+ ) {
+ return new StopPointsInVehicleJourneyContext(
+ serviceJourneyInterchangeInfo,
+ Optional
+ .ofNullable(serviceJourneyInterchangeInfo.fromJourneyRef())
+ .map(serviceJourneyId -> serviceJourneyIdListMap.get(serviceJourneyId)
)
- )
- .orElse(null),
- Optional
- .ofNullable(serviceJourneyInterchangeInfo.toJourneyRef())
- .map(serviceJourneyId ->
- serviceJourneyStops(
- validationReportId,
- netexDataRepository,
- serviceJourneyId
+ .orElse(null),
+ Optional
+ .ofNullable(serviceJourneyInterchangeInfo.toJourneyRef())
+ .map(serviceJourneyId -> serviceJourneyIdListMap.get(serviceJourneyId)
)
- )
- .orElse(null)
- );
+ .orElse(null)
+ );
+ }
}
public boolean isValid() {
return (
serviceJourneyInterchangeInfo != null &&
- serviceJourneyInterchangeInfo.isValid() &&
- serviceJourneyStopsForFromJourneyRef != null &&
- serviceJourneyStopsForToJourneyRef != null
+ serviceJourneyInterchangeInfo.isValid()
);
}
-
- private static List serviceJourneyStops(
- String validationReportId,
- NetexDataRepository netexDataRepository,
- ServiceJourneyId serviceJourneyId
- ) {
- return Optional
- .ofNullable(
- netexDataRepository.serviceJourneyStops(
- validationReportId,
- serviceJourneyId
- )
- )
- .orElse(List.of());
- }
}
diff --git a/src/main/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyValidator.java b/src/main/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyValidator.java
index d20d2847..9ca0ded2 100644
--- a/src/main/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyValidator.java
+++ b/src/main/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyValidator.java
@@ -1,5 +1,6 @@
package no.entur.antu.validation.validator.interchange.stoppoints;
+import java.util.List;
import java.util.Objects;
import org.entur.netex.validation.validator.AbstractDatasetValidator;
import org.entur.netex.validation.validator.DataLocation;
@@ -9,7 +10,10 @@
import org.entur.netex.validation.validator.jaxb.NetexDataRepository;
import org.entur.netex.validation.validator.model.ScheduledStopPointId;
import org.entur.netex.validation.validator.model.ServiceJourneyId;
+import org.entur.netex.validation.validator.model.ServiceJourneyInterchangeInfo;
import org.entur.netex.validation.validator.model.ServiceJourneyStop;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Validates that the stop points in interchange are part of the respective service journeys in the interchange.
@@ -18,6 +22,10 @@
public class StopPointsInVehicleJourneyValidator
extends AbstractDatasetValidator {
+ private static final Logger LOGGER = LoggerFactory.getLogger(
+ StopPointsInVehicleJourneyValidator.class
+ );
+
private final NetexDataRepository netexDataRepository;
public StopPointsInVehicleJourneyValidator(
@@ -30,28 +38,37 @@ public StopPointsInVehicleJourneyValidator(
@Override
public ValidationReport validate(ValidationReport validationReport) {
- if (
- netexDataRepository.hasServiceJourneyInterchangeInfos(
+ LOGGER.info("Validating interchange stop points in vehicle journey.");
+
+ List serviceJourneyInterchangeInfos =
+ netexDataRepository.serviceJourneyInterchangeInfos(
validationReport.getValidationReportId()
- )
+ );
+
+ if (
+ serviceJourneyInterchangeInfos == null ||
+ serviceJourneyInterchangeInfos.isEmpty()
) {
- netexDataRepository
- .serviceJourneyInterchangeInfos(
- validationReport.getValidationReportId()
- )
- .stream()
- .map(serviceJourneyInterchange ->
- StopPointsInVehicleJourneyContext.of(
- validationReport.getValidationReportId(),
- netexDataRepository,
- serviceJourneyInterchange
- )
- )
- .filter(StopPointsInVehicleJourneyContext::isValid)
- .map(this::validateStopPoint)
- .filter(Objects::nonNull)
- .forEach(validationReport::addValidationReportEntry);
+ return validationReport;
}
+
+ StopPointsInVehicleJourneyContext.Builder builder =
+ new StopPointsInVehicleJourneyContext.Builder(
+ validationReport.getValidationReportId(),
+ netexDataRepository
+ );
+
+ builder.primeCache();
+
+ serviceJourneyInterchangeInfos
+ .stream()
+ .map(builder::build)
+ .filter(Objects::nonNull)
+ .filter(StopPointsInVehicleJourneyContext::isValid)
+ .map(this::validateStopPoint)
+ .filter(Objects::nonNull)
+ .forEach(validationReport::addValidationReportEntry);
+
return validationReport;
}
@@ -59,6 +76,7 @@ private ValidationReportEntry validateStopPoint(
StopPointsInVehicleJourneyContext context
) {
if (
+ context.serviceJourneyStopsForFromJourneyRef() == null ||
context
.serviceJourneyStopsForFromJourneyRef()
.stream()
@@ -80,6 +98,7 @@ private ValidationReportEntry validateStopPoint(
}
if (
+ context.serviceJourneyStopsForToJourneyRef() == null ||
context
.serviceJourneyStopsForToJourneyRef()
.stream()
diff --git a/src/main/java/no/entur/antu/validation/validator/line/DuplicateLineNameValidator.java b/src/main/java/no/entur/antu/validation/validator/line/DuplicateLineNameValidator.java
index e59a8fd7..50f13cd5 100644
--- a/src/main/java/no/entur/antu/validation/validator/line/DuplicateLineNameValidator.java
+++ b/src/main/java/no/entur/antu/validation/validator/line/DuplicateLineNameValidator.java
@@ -6,9 +6,15 @@
import org.entur.netex.validation.validator.*;
import org.entur.netex.validation.validator.jaxb.NetexDataRepository;
import org.entur.netex.validation.validator.model.SimpleLine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DuplicateLineNameValidator extends AbstractDatasetValidator {
+ private static final Logger LOGGER = LoggerFactory.getLogger(
+ DuplicateLineNameValidator.class
+ );
+
private final NetexDataRepository netexDataRepository;
public DuplicateLineNameValidator(
@@ -21,6 +27,8 @@ public DuplicateLineNameValidator(
@Override
public ValidationReport validate(ValidationReport validationReport) {
+ LOGGER.info("Validating duplicate line names.");
+
List lineNames = netexDataRepository.lineNames(
validationReport.getValidationReportId()
);
diff --git a/src/test/java/no/entur/antu/config/TestConfig.java b/src/test/java/no/entur/antu/config/TestConfig.java
index 6496030c..ac52d45f 100644
--- a/src/test/java/no/entur/antu/config/TestConfig.java
+++ b/src/test/java/no/entur/antu/config/TestConfig.java
@@ -2,6 +2,7 @@
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import no.entur.antu.organisation.OrganisationRepository;
import org.entur.netex.validation.validator.jaxb.*;
@@ -44,16 +45,10 @@ public List lineNames(String validationReportId) {
}
@Override
- public List serviceJourneyStops(
- String validationReportId,
- ServiceJourneyId serviceJourneyId
+ public Map> serviceJourneyStops(
+ String validationReportId
) {
- return List.of();
- }
-
- @Override
- public boolean hasServiceJourneyInterchangeInfos(String s) {
- return false;
+ return Map.of();
}
@Override
diff --git a/src/test/java/no/entur/antu/validation/ValidationTest.java b/src/test/java/no/entur/antu/validation/ValidationTest.java
index 64e549cf..fc5ee6a6 100644
--- a/src/test/java/no/entur/antu/validation/ValidationTest.java
+++ b/src/test/java/no/entur/antu/validation/ValidationTest.java
@@ -6,6 +6,7 @@
import static org.mockito.Mockito.when;
import java.util.List;
+import java.util.Map;
import no.entur.antu.exception.AntuException;
import org.entur.netex.index.api.NetexEntitiesIndex;
import org.entur.netex.validation.validator.DatasetValidator;
@@ -33,11 +34,6 @@ void resetMocks() {
Mockito
.when(netexDataRepositoryMock.hasQuayIds(anyString()))
.thenReturn(true);
- Mockito
- .when(
- netexDataRepositoryMock.hasServiceJourneyInterchangeInfos(anyString())
- )
- .thenReturn(true);
this.stopPlaceRepositoryMock = mock(StopPlaceRepository.class);
}
@@ -108,16 +104,10 @@ protected void mockGetFromToScheduledStopPointId(
}
protected void mockGetServiceJourneyStops(
- ServiceJourneyId serviceJourneyId,
- List serviceJourneyStops
+ Map> serviceJourneyStops
) {
Mockito
- .when(
- netexDataRepositoryMock.serviceJourneyStops(
- anyString(),
- eq(serviceJourneyId)
- )
- )
+ .when(netexDataRepositoryMock.serviceJourneyStops(anyString()))
.thenReturn(serviceJourneyStops);
}
diff --git a/src/test/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyValidatorTest.java b/src/test/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyValidatorTest.java
index b350c5de..9a73740b 100644
--- a/src/test/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyValidatorTest.java
+++ b/src/test/java/no/entur/antu/validation/validator/interchange/stoppoints/StopPointsInVehicleJourneyValidatorTest.java
@@ -5,6 +5,7 @@
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import no.entur.antu.netextestdata.NetexTestFragment;
import no.entur.antu.validation.ValidationTest;
import org.entur.netex.validation.validator.ValidationReport;
@@ -23,26 +24,26 @@ void interchangeStopPointArePartOfVehicleJourneys() {
// Mocking both the fromPointRef and toPointRef,
// to test that both fromPointRef and toPointRef are part of the vehicle journey.
mockGetServiceJourneyStops(
- ServiceJourneyId.ofValidId("TST:ServiceJourney:1"),
- List.of(
- new ServiceJourneyStop(
- new ScheduledStopPointId("TST:ScheduledStopPoint:1"),
- null,
- null,
- 0,
- 0
- )
- )
- );
- mockGetServiceJourneyStops(
- ServiceJourneyId.ofValidId("TST:ServiceJourney:2"),
- List.of(
- new ServiceJourneyStop(
- new ScheduledStopPointId("TST:ScheduledStopPoint:2"),
- null,
- null,
- 0,
- 0
+ Map.of(
+ ServiceJourneyId.ofValidId("TST:ServiceJourney:1"),
+ List.of(
+ new ServiceJourneyStop(
+ new ScheduledStopPointId("TST:ScheduledStopPoint:1"),
+ null,
+ null,
+ 0,
+ 0
+ )
+ ),
+ ServiceJourneyId.ofValidId("TST:ServiceJourney:2"),
+ List.of(
+ new ServiceJourneyStop(
+ new ScheduledStopPointId("TST:ScheduledStopPoint:2"),
+ null,
+ null,
+ 0,
+ 0
+ )
)
)
);
@@ -56,14 +57,16 @@ void interchangeStopPointArePartOfVehicleJourneys() {
void interchangeFromStopPointIsNotAPartOfVehicleJourneys() {
// Mocking only the toPointRef, to test that the fromPointRef is not part of the vehicle journey
mockGetServiceJourneyStops(
- ServiceJourneyId.ofValidId("TST:ServiceJourney:2"),
- List.of(
- new ServiceJourneyStop(
- new ScheduledStopPointId("TST:ScheduledStopPoint:2"),
- null,
- null,
- 0,
- 0
+ Map.of(
+ ServiceJourneyId.ofValidId("TST:ServiceJourney:2"),
+ List.of(
+ new ServiceJourneyStop(
+ new ScheduledStopPointId("TST:ScheduledStopPoint:2"),
+ null,
+ null,
+ 0,
+ 0
+ )
)
)
);
@@ -116,14 +119,16 @@ void interchangeWithMissingAttributes() {
void interchangeToStopPointIsNotAPartOfVehicleJourneys() {
// Mocking only the fromPointRef, to test that the toPointRef is not part of the vehicle journey
mockGetServiceJourneyStops(
- ServiceJourneyId.ofValidId("TST:ServiceJourney:1"),
- List.of(
- new ServiceJourneyStop(
- new ScheduledStopPointId("TST:ScheduledStopPoint:1"),
- null,
- null,
- 0,
- 0
+ Map.of(
+ ServiceJourneyId.ofValidId("TST:ServiceJourney:1"),
+ List.of(
+ new ServiceJourneyStop(
+ new ScheduledStopPointId("TST:ScheduledStopPoint:1"),
+ null,
+ null,
+ 0,
+ 0
+ )
)
)
);