]> git.basschouten.com Git - openhab-addons.git/blob
7cff77147a866e48c84d81f0222422e7c120548a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.deutschebahn.internal.timetable;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import java.util.Calendar;
18 import java.util.Date;
19 import java.util.GregorianCalendar;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.deutschebahn.internal.timetable.dto.Timetable;
24
25 /**
26  * Tests for {@link TimetablesV1Impl}
27  * 
28  * @author Sönke Küper - Initial contribution.
29  */
30 @NonNullByDefault
31 public class TimetablesV1ImplTest implements TimetablesV1ImplTestHelper {
32
33     @Test
34     public void testGetDataForLehrte() throws Exception {
35         TimetablesV1Api timeTableApi = createApiWithTestdata().getApi();
36
37         Date time = new GregorianCalendar(2021, Calendar.AUGUST, 16, 9, 22).getTime();
38
39         Timetable timeTable = timeTableApi.getPlan(EVA_LEHRTE, time);
40         assertNotNull(timeTable);
41         assertEquals(8, timeTable.getS().size());
42     }
43
44     @Test
45     public void testGetNonExistingData() throws Exception {
46         TimetablesV1Api timeTableApi = createApiWithTestdata().getApi();
47
48         Date time = new GregorianCalendar(2021, Calendar.AUGUST, 16, 9, 22).getTime();
49
50         Timetable timeTable = timeTableApi.getPlan("ABCDEF", time);
51         assertNotNull(timeTable);
52         assertEquals(0, timeTable.getS().size());
53     }
54
55     @Test
56     public void testGetDataForHannoverHBF() throws Exception {
57         TimetablesV1Api timeTableApi = createApiWithTestdata().getApi();
58
59         Date time = new GregorianCalendar(2021, Calendar.OCTOBER, 14, 11, 0).getTime();
60
61         Timetable timeTable = timeTableApi.getPlan(EVA_HANNOVER_HBF, time);
62         assertNotNull(timeTable);
63         assertEquals(50, timeTable.getS().size());
64
65         Timetable changes = timeTableApi.getFullChanges(EVA_HANNOVER_HBF);
66         assertNotNull(changes);
67         assertEquals(730, changes.getS().size());
68     }
69 }