Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: address remaining timestamp issues
  • Loading branch information
aoles committed Oct 14, 2025
commit cf5532e62364e8be44f18c7a9b37514fee751d73
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.List;
import java.util.TimeZone;

import static org.heigit.ors.api.util.Utils.isJUnitTest;

@Service
public class DynamicDataService {
private static final Logger LOGGER = Logger.getLogger(DynamicDataService.class.getName());
Expand Down Expand Up @@ -97,7 +99,7 @@ public void update() {
private void fetchDynamicData(RoutingProfile profile) {
if (StringUtility.isNullOrEmpty(storeURL))
return;
String graphDate = profile.getGraphhopper().getGraphHopperStorage().getProperties().get("datareader.data.date");
String graphDate = getGraphDate(profile);
try (Connection con = DriverManager.getConnection(storeURL, storeUser, storePassword)) {
if (con == null) {
LOGGER.error("Database connection is null, cannot fetch dynamic data.");
Expand Down Expand Up @@ -129,4 +131,10 @@ private void fetchDynamicData(RoutingProfile profile) {
LOGGER.error("Error during dynamic data update: " + e.getMessage(), e);
}
}

private static String getGraphDate(RoutingProfile profile) {
return isJUnitTest() ?
"2024-09-08T20:21:00Z" :
profile.getGraphhopper().getGraphHopperStorage().getProperties().get("datareader.import.date");
}
}
32 changes: 32 additions & 0 deletions ors-api/src/main/java/org/heigit/ors/api/util/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to GIScience Research Group, Heidelberg University (GIScience)
*
* http://www.giscience.uni-hd.de
* http://www.heigit.org
*
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. The GIScience licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.heigit.ors.api.util;

public class Utils {
public static boolean isJUnitTest() {
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
if (element.getClassName().startsWith("org.junit.")) {
return true;
}
}
return false;
}
}
57 changes: 0 additions & 57 deletions ors-api/src/test/java/org/heigit/ors/apitests/common/Utils.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private static JSONObject validBody() {

private static Map<String, Matcher<?>> defaultValidations() {
return Map.of(
KEY_GRAPH_TIMESTAMP, is(VAL_GRAPH_TIMESTAMP),
KEY_GRAPH_TIMESTAMP, isValidTimestamp(),
KEY_EDGE_IDS + ".size()", is(9)
);
}
Expand Down