2 * Copyright (c) 2010-2023 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 a {@link TimetablesApiTestModule}.
25 * @author Sönke Küper - initial contribution.
28 public interface TimetablesV1ImplTestHelper {
30 static final String EVA_LEHRTE = "8000226";
31 static final String EVA_HANNOVER_HBF = "8000152";
32 static final String CLIENT_ID = "bdwrpmxuo6157jrekftlbcc6ju9awo";
33 static final String CLIENT_SECRET = "354c8161cd7fb0936c840240280c131e";
36 * Creates a {@link TimetablesApiTestModule} that uses http response data from file system.
37 * Uses default-testdata from directory /timetablesData
39 default TimetablesApiTestModule createApiWithTestdata() throws Exception {
40 return this.createApiWithTestdata("/timetablesData");
44 * Creates a {@link TimetablesApiTestModule} that uses http response data from file system.
46 * @param dataDirectory Directory within test-resources containing the stub-data.
48 default TimetablesApiTestModule createApiWithTestdata(String dataDirectory) throws Exception {
49 final URL timetablesData = getClass().getResource(dataDirectory);
50 assertNotNull(timetablesData);
51 final File testDataDir = new File(timetablesData.toURI());
52 final TimetableStubHttpCallable httpStub = new TimetableStubHttpCallable(testDataDir);
53 final TimetablesV1Impl timeTableApi = new TimetablesV1Impl(CLIENT_ID, CLIENT_SECRET, httpStub);
54 return new TimetablesApiTestModule(timeTableApi, httpStub);