forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPollHandlerIT.java
More file actions
56 lines (45 loc) · 1.78 KB
/
PollHandlerIT.java
File metadata and controls
56 lines (45 loc) · 1.78 KB
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
/*
* Copyright (C) 2004-2017, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata;
import org.springframework.web.client.RestTemplate;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static net.jadler.Jadler.onRequest;
public class PollHandlerIT extends AbstractGoodDataIT {
private static final String PATH = "/foo";
private static final String PARAM = "q";
private static final String VALUE = "eAEdizEOgCAQBL9CtraBwsLOR1gZC5QzuUROA2csiH8X7DYzswXKehAGTPKvYBJdZ1ITaGdh5VPQ%0AIZIm3jKGuUB8bP34%2BERCOVfNoQLbO%2BvwLh281nq9ldpheT%2FgtSHo%0A";
private static final String URI = PATH + "?" + PARAM + "=" + VALUE;
private PollingService service;
@BeforeMethod
public void setUp() throws Exception {
service = new PollingService(gd.getRestTemplate());
onRequest()
.havingMethodEqualTo("GET")
.havingPathEqualTo(PATH)
.havingParameterEqualTo(PARAM, VALUE)
.respond()
.withStatus(200)
;
}
@Test
public void shouldPollOnEncodedUri() throws Exception {
service.test(URI).get();
}
private static class PollingService extends AbstractService {
PollingService(final RestTemplate restTemplate) {
super(restTemplate);
}
FutureResult<Void> test(final String uri) {
return new PollResult<>(this, new SimplePollHandler<Void>(uri, Void.class) {
@Override
public void handlePollException(final GoodDataRestException e) {
throw e;
}
});
}
}
}