2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.deutschebahn.internal.timetable;
15 import static org.junit.jupiter.api.Assertions.*;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
23 * Helper interface for jUnit Tests to provide an {@link TimetablesApiTestModule}.
25 * @author Sönke Küper - initial contribution.
28 public interface TimetablesV1ImplTestHelper {
30 public static final String EVA_LEHRTE = "8000226";
31 public static final String EVA_HANNOVER_HBF = "8000152";
32 public static final String AUTH_TOKEN = "354c8161cd7fb0936c840240280c131e";
35 * Creates an {@link TimetablesApiTestModule} that uses http response data from file system.
36 * Uses default-testdata from directory /timetablesData
38 public default TimetablesApiTestModule createApiWithTestdata() throws Exception {
39 return this.createApiWithTestdata("/timetablesData");
43 * Creates an {@link TimetablesApiTestModule} that uses http response data from file system.
45 * @param dataDirectory Directory within test-resources containing the stub-data.
47 public default TimetablesApiTestModule createApiWithTestdata(String dataDirectory) throws Exception {
48 final URL timetablesData = getClass().getResource(dataDirectory);
49 assertNotNull(timetablesData);
50 final File testDataDir = new File(timetablesData.toURI());
51 final TimetableStubHttpCallable httpStub = new TimetableStubHttpCallable(testDataDir);
52 final TimetablesV1Impl timeTableApi = new TimetablesV1Impl(AUTH_TOKEN, httpStub);
53 return new TimetablesApiTestModule(timeTableApi, httpStub);