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.*;
17 import java.util.Calendar;
18 import java.util.Date;
19 import java.util.GregorianCalendar;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.deutschebahn.internal.timetable.dto.Timetable;
26 * Tests for {@link TimetablesV1Impl}
28 * @author Sönke Küper - Initial contribution.
31 public class TimetablesV1ImplTest implements TimetablesV1ImplTestHelper {
34 public void testGetDataForLehrte() throws Exception {
35 TimetablesV1Api timeTableApi = createApiWithTestdata().getApi();
37 Date time = new GregorianCalendar(2021, Calendar.AUGUST, 16, 9, 22).getTime();
39 Timetable timeTable = timeTableApi.getPlan(EVA_LEHRTE, time);
40 assertNotNull(timeTable);
41 assertEquals(8, timeTable.getS().size());
45 public void testGetNonExistingData() throws Exception {
46 TimetablesV1Api timeTableApi = createApiWithTestdata().getApi();
48 Date time = new GregorianCalendar(2021, Calendar.AUGUST, 16, 9, 22).getTime();
50 Timetable timeTable = timeTableApi.getPlan("ABCDEF", time);
51 assertNotNull(timeTable);
52 assertEquals(0, timeTable.getS().size());
56 public void testGetDataForHannoverHBF() throws Exception {
57 TimetablesV1Api timeTableApi = createApiWithTestdata().getApi();
59 Date time = new GregorianCalendar(2021, Calendar.OCTOBER, 14, 11, 0).getTime();
61 Timetable timeTable = timeTableApi.getPlan(EVA_HANNOVER_HBF, time);
62 assertNotNull(timeTable);
63 assertEquals(50, timeTable.getS().size());
65 Timetable changes = timeTableApi.getFullChanges(EVA_HANNOVER_HBF);
66 assertNotNull(changes);
67 assertEquals(730, changes.getS().size());