embulk-input-http 0.0.20 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/build.gradle +3 -3
- data/src/main/java/org/embulk/input/http/BasicAuthOption.java +25 -31
- data/src/main/java/org/embulk/input/http/HttpFileInputPlugin.java +274 -296
- data/src/main/java/org/embulk/input/http/PagerOption.java +73 -76
- data/src/main/java/org/embulk/input/http/ParamsOption.java +57 -66
- data/src/main/java/org/embulk/input/http/QueryOption.java +138 -161
- data/src/main/java/org/embulk/input/http/RetryableHandler.java +57 -63
- data/src/test/java/org/embulk/input/http/TestHttpInputPlugin.java +1 -3
- data/src/test/java/org/embulk/input/http/TestPagerOption.java +55 -59
- data/src/test/java/org/embulk/input/http/TestParamsOption.java +82 -87
- data/src/test/java/org/embulk/input/http/TestQueryOption.java +116 -121
- metadata +3 -3
@@ -8,125 +8,120 @@ import java.util.List;
|
|
8
8
|
|
9
9
|
import static org.junit.Assert.assertEquals;
|
10
10
|
|
11
|
-
public class TestQueryOption
|
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
|
-
assertEquals(dest.get(2).getName(), "test");
|
129
|
-
assertEquals(dest.get(2).getValues().length, 1);
|
130
|
-
assertEquals(dest.get(2).getValues()[0], "awes}ome3");
|
131
|
-
}
|
11
|
+
public class TestQueryOption {
|
12
|
+
@Test
|
13
|
+
public void testUnexpandSingleValue() throws Exception {
|
14
|
+
Optional<List<String>> nullValues = Optional.absent();
|
15
|
+
QueryOption config = new QueryOption("test", Optional.of("awesome"), nullValues, false);
|
16
|
+
List<QueryOption.Query> dest = config.expand();
|
17
|
+
assertEquals(dest.size(), 1);
|
18
|
+
assertEquals(dest.get(0).getName(), "test");
|
19
|
+
assertEquals(dest.get(0).getValues().length, 1);
|
20
|
+
assertEquals(dest.get(0).getValues()[0], "awesome");
|
21
|
+
}
|
22
|
+
|
23
|
+
@Test
|
24
|
+
public void testUnexpandMultiValue() throws Exception {
|
25
|
+
Optional<String> nullValue = Optional.absent();
|
26
|
+
List<String> values = Lists.newArrayList("a", "b", "c");
|
27
|
+
QueryOption config = new QueryOption("test", nullValue, Optional.of(values), false);
|
28
|
+
List<QueryOption.Query> dest = config.expand();
|
29
|
+
assertEquals(dest.size(), 1);
|
30
|
+
assertEquals(dest.get(0).getName(), "test");
|
31
|
+
|
32
|
+
assertEquals(dest.get(0).getValues().length, 3);
|
33
|
+
assertEquals(dest.get(0).getValues()[0], "a");
|
34
|
+
assertEquals(dest.get(0).getValues()[1], "b");
|
35
|
+
assertEquals(dest.get(0).getValues()[2], "c");
|
36
|
+
}
|
37
|
+
|
38
|
+
@Test
|
39
|
+
public void testExpandSingleValue() throws Exception {
|
40
|
+
Optional<List<String>> nullValues = Optional.absent();
|
41
|
+
QueryOption config = new QueryOption("test", Optional.of("awesome"), nullValues, true);
|
42
|
+
List<QueryOption.Query> dest = config.expand();
|
43
|
+
assertEquals(dest.size(), 1);
|
44
|
+
assertEquals(dest.get(0).getName(), "test");
|
45
|
+
assertEquals(dest.get(0).getValues()[0], "awesome");
|
46
|
+
}
|
47
|
+
|
48
|
+
@Test
|
49
|
+
public void testExpandMultiValue() throws Exception {
|
50
|
+
Optional<String> nullValue = Optional.absent();
|
51
|
+
List<String> values = Lists.newArrayList("a", "b", "c");
|
52
|
+
QueryOption config = new QueryOption("test", nullValue, Optional.of(values), true);
|
53
|
+
List<QueryOption.Query> dest = config.expand();
|
54
|
+
assertEquals(dest.size(), 3);
|
55
|
+
assertEquals(dest.get(0).getName(), "test");
|
56
|
+
assertEquals(dest.get(0).getValues().length, 1);
|
57
|
+
assertEquals(dest.get(0).getValues()[0], "a");
|
58
|
+
|
59
|
+
assertEquals(dest.get(1).getValues().length, 1);
|
60
|
+
assertEquals(dest.get(1).getName(), "test");
|
61
|
+
assertEquals(dest.get(1).getValues()[0], "b");
|
62
|
+
|
63
|
+
assertEquals(dest.get(2).getValues().length, 1);
|
64
|
+
assertEquals(dest.get(2).getName(), "test");
|
65
|
+
assertEquals(dest.get(2).getValues()[0], "c");
|
66
|
+
}
|
67
|
+
|
68
|
+
@Test(expected = IllegalArgumentException.class)
|
69
|
+
public void testExpandRaisesExceptionWhenBothValuesAreNull() throws Exception {
|
70
|
+
Optional<List<String>> nullValues = Optional.absent();
|
71
|
+
Optional<String> nullValue = Optional.absent();
|
72
|
+
QueryOption config = new QueryOption("test", nullValue, nullValues, false);
|
73
|
+
config.expand();
|
74
|
+
}
|
75
|
+
|
76
|
+
@Test
|
77
|
+
public void testUnExpandBrace() throws Exception {
|
78
|
+
Optional<List<String>> nullValues = Optional.absent();
|
79
|
+
QueryOption config =
|
80
|
+
new QueryOption("test", Optional.of("{awesome1,awesome2,awesome3}"), nullValues, false);
|
81
|
+
List<QueryOption.Query> dest = config.expand();
|
82
|
+
assertEquals(dest.size(), 1);
|
83
|
+
assertEquals(dest.get(0).getName(), "test");
|
84
|
+
assertEquals(dest.get(0).getValues().length, 1);
|
85
|
+
assertEquals(dest.get(0).getValues()[0], "{awesome1,awesome2,awesome3}");
|
86
|
+
}
|
87
|
+
|
88
|
+
@Test
|
89
|
+
public void testExpandBrace() throws Exception {
|
90
|
+
Optional<List<String>> nullValues = Optional.absent();
|
91
|
+
QueryOption config =
|
92
|
+
new QueryOption("test", Optional.of("{awesome1,awesome2,awesome3}"), nullValues, true);
|
93
|
+
List<QueryOption.Query> dest = config.expand();
|
94
|
+
assertEquals(dest.size(), 3);
|
95
|
+
assertEquals(dest.get(0).getName(), "test");
|
96
|
+
assertEquals(dest.get(0).getValues().length, 1);
|
97
|
+
assertEquals(dest.get(0).getValues()[0], "awesome1");
|
98
|
+
assertEquals(dest.get(1).getName(), "test");
|
99
|
+
|
100
|
+
assertEquals(dest.get(1).getValues().length, 1);
|
101
|
+
assertEquals(dest.get(1).getValues()[0], "awesome2");
|
102
|
+
|
103
|
+
assertEquals(dest.get(2).getValues().length, 1);
|
104
|
+
assertEquals(dest.get(2).getName(), "test");
|
105
|
+
assertEquals(dest.get(2).getValues()[0], "awesome3");
|
106
|
+
}
|
107
|
+
|
108
|
+
@Test
|
109
|
+
public void testExpandEscapedBrace() throws Exception {
|
110
|
+
Optional<List<String>> nullValues = Optional.absent();
|
111
|
+
QueryOption config =
|
112
|
+
new QueryOption(
|
113
|
+
"test", Optional.of("{awe\\,some1,awes\\{ome2,awes\\}ome3}"), nullValues, true);
|
114
|
+
List<QueryOption.Query> dest = config.expand();
|
115
|
+
assertEquals(dest.get(0).getName(), "test");
|
116
|
+
assertEquals(dest.get(0).getValues().length, 1);
|
117
|
+
assertEquals(dest.get(0).getValues()[0], "awe,some1");
|
118
|
+
|
119
|
+
assertEquals(dest.get(1).getName(), "test");
|
120
|
+
assertEquals(dest.get(1).getValues().length, 1);
|
121
|
+
assertEquals(dest.get(1).getValues()[0], "awes{ome2");
|
122
|
+
|
123
|
+
assertEquals(dest.get(2).getName(), "test");
|
124
|
+
assertEquals(dest.get(2).getValues().length, 1);
|
125
|
+
assertEquals(dest.get(2).getValues()[0], "awes}ome3");
|
126
|
+
}
|
132
127
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takuma kanari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,7 @@ files:
|
|
53
53
|
- classpath/commons-codec-1.10.jar
|
54
54
|
- classpath/commons-io-2.6.jar
|
55
55
|
- classpath/commons-logging-1.2.jar
|
56
|
-
- classpath/embulk-input-http-0.0.
|
56
|
+
- classpath/embulk-input-http-0.21.0.jar
|
57
57
|
- classpath/httpclient-4.5.5.jar
|
58
58
|
- classpath/httpcore-4.4.9.jar
|
59
59
|
- config/checkstyle/checkstyle.xml
|