summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/de/test/antennapod/gpodnet/GPodnetServiceTest.java
blob: e7e8c5b0991cb8f26c75c483db18543dad9eddfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package de.test.antennapod.gpodnet;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import androidx.test.runner.AndroidJUnit4;
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetService;
import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetServiceException;
import de.danoeh.antennapod.core.sync.gpoddernet.model.GpodnetDevice;
import de.danoeh.antennapod.core.sync.gpoddernet.model.GpodnetTag;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import static java.util.Collections.singletonList;

/**
 * Test class for GpodnetService
 */
@Ignore
@RunWith(AndroidJUnit4.class)
public class GPodnetServiceTest {

    private GpodnetService service;

    private static final String USER = "";
    private static final String PW = "";

    @Before
    public void setUp() {
        service = new GpodnetService(AntennapodHttpClient.getHttpClient(), GpodnetService.DEFAULT_BASE_HOST);
    }

    private void authenticate() throws GpodnetServiceException {
        service.authenticate(USER, PW);
    }

    @Test
    public void testUploadSubscription() throws GpodnetServiceException {
        authenticate();
        ArrayList<String> l = new ArrayList<>();
        l.add("http://bitsundso.de/feed");
        service.uploadSubscriptions("radio", l);
    }

    @Test
    public void testUploadSubscription2() throws GpodnetServiceException {
        authenticate();
        ArrayList<String> l = new ArrayList<>();
        l.add("http://bitsundso.de/feed");
        l.add("http://gamesundso.de/feed");
        service.uploadSubscriptions("radio", l);
    }

    @Test
    public void testUploadChanges() throws GpodnetServiceException {
        authenticate();
        String[] URLS = {"http://bitsundso.de/feed", "http://gamesundso.de/feed", "http://cre.fm/feed/mp3/", "http://freakshow.fm/feed/m4a/"};
        List<String> subscriptions = Arrays.asList(URLS[0], URLS[1]);
        List<String> removed = singletonList(URLS[0]);
        List<String> added = Arrays.asList(URLS[2], URLS[3]);
        service.uploadSubscriptions("radio", subscriptions);
        service.uploadChanges("radio", added, removed);
    }

    @Test
    public void testGetSubscriptionChanges() throws GpodnetServiceException {
        authenticate();
        service.getSubscriptionChanges("radio", 1362322610L);
    }

    @Test
    public void testGetSubscriptionsOfUser()
            throws GpodnetServiceException {
        authenticate();
        service.getSubscriptionsOfUser();
    }

    @Test
    public void testGetSubscriptionsOfDevice()
            throws GpodnetServiceException {
        authenticate();
        service.getSubscriptionsOfDevice("radio");
    }

    @Test
    public void testConfigureDevices() throws GpodnetServiceException {
        authenticate();
        service.configureDevice("foo", "This is an updated caption",  GpodnetDevice.DeviceType.LAPTOP);
    }

    @Test
    public void testGetDevices() throws GpodnetServiceException {
        authenticate();
        service.getDevices();
    }

    @Test
    public void testGetSuggestions() throws GpodnetServiceException {
        authenticate();
        service.getSuggestions(10);
    }

    @Test
    public void testTags() throws GpodnetServiceException {
        service.getTopTags(20);
    }

    @Test
    public void testPodcastForTags() throws GpodnetServiceException {
        List<GpodnetTag> tags = service.getTopTags(20);
        service.getPodcastsForTag(tags.get(1),
                10);
    }

    @Test
    public void testSearch() throws GpodnetServiceException {
        service.searchPodcasts("linux", 64);
    }

    @Test
    public void testToplist() throws GpodnetServiceException {
        service.getPodcastToplist(10);
    }
}