]> git.basschouten.com Git - openhab-addons.git/blob
96f5002d724fd1e1a2888cce885036d410b6d9f6
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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 java.net.URISyntaxException;
16 import java.util.List;
17
18 import javax.xml.bind.JAXBException;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.deutschebahn.internal.timetable.TimetablesV1Impl.HttpCallable;
22 import org.xml.sax.SAXException;
23
24 /**
25  * Testmodule that contains the {@link TimetablesV1Api} and {@link TimetableStubHttpCallable}.
26  * Used in tests to check which http calls have been made.
27  * 
28  * @author Sönke Küper - Initial contribution.
29  */
30 @NonNullByDefault
31 public final class TimetablesApiTestModule {
32
33     private final TimetablesV1Api api;
34     private final TimetableStubHttpCallable httpStub;
35
36     public TimetablesApiTestModule(TimetablesV1Api api, TimetableStubHttpCallable httpStub) {
37         this.api = api;
38         this.httpStub = httpStub;
39     }
40
41     public TimetablesV1Api getApi() {
42         return api;
43     }
44
45     public void addAvailableUrl(String url) {
46         this.httpStub.addAvailableUrl(url);
47     }
48
49     public List<String> getRequestedPlanUrls() {
50         return httpStub.getRequestedPlanUrls();
51     }
52
53     public List<String> getRequestedFullChangesUrls() {
54         return httpStub.getRequestedFullChangesUrls();
55     }
56
57     public List<String> getRequestedRecentChangesUrls() {
58         return httpStub.getRequestedRecentChangesUrls();
59     }
60
61     public TimetablesV1ApiFactory getApiFactory() {
62         return new TimetablesV1ApiFactory() {
63
64             @Override
65             public TimetablesV1Api create(String authToken, HttpCallable httpCallable)
66                     throws JAXBException, SAXException, URISyntaxException {
67                 return api;
68             }
69         };
70     }
71 }