embulk-input-http 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,125 @@
1
+ package org.embulk.input.http;
2
+
3
+ import com.google.common.base.Optional;
4
+ import com.google.common.collect.Lists;
5
+ import org.junit.Test;
6
+
7
+ import java.util.List;
8
+
9
+ import static org.junit.Assert.assertEquals;
10
+
11
+ public class TestQueryConfig {
12
+
13
+ @Test
14
+ public void testUnexpandSingleValue() throws Exception {
15
+ Optional<List<String>> nullValues = Optional.absent();
16
+ QueryConfig config = new QueryConfig("test", Optional.of("awesome"), nullValues, false);
17
+ List<QueryConfig.Query> dest = config.expand();
18
+ assertEquals(dest.size(), 1);
19
+ assertEquals(dest.get(0).getName(), "test");
20
+ assertEquals(dest.get(0).getValues().length, 1);
21
+ assertEquals(dest.get(0).getValues()[0], "awesome");
22
+ }
23
+
24
+ @Test
25
+ public void testUnexpandMultiValue() throws Exception {
26
+ Optional<String> nullValue = Optional.absent();
27
+ List<String> values = Lists.newArrayList("a", "b", "c");
28
+ QueryConfig config = new QueryConfig("test", nullValue, Optional.of(values), false);
29
+ List<QueryConfig.Query> dest = config.expand();
30
+ assertEquals(dest.size(), 1);
31
+ assertEquals(dest.get(0).getName(), "test");
32
+
33
+ assertEquals(dest.get(0).getValues().length, 3);
34
+ assertEquals(dest.get(0).getValues()[0], "a");
35
+ assertEquals(dest.get(0).getValues()[1], "b");
36
+ assertEquals(dest.get(0).getValues()[2], "c");
37
+ }
38
+
39
+ @Test
40
+ public void testExpandSingleValue() throws Exception {
41
+ Optional<List<String>> nullValues = Optional.absent();
42
+ QueryConfig config = new QueryConfig("test", Optional.of("awesome"), nullValues, true);
43
+ List<QueryConfig.Query> dest = config.expand();
44
+ assertEquals(dest.size(), 1);
45
+ assertEquals(dest.get(0).getName(), "test");
46
+ assertEquals(dest.get(0).getValues()[0], "awesome");
47
+ }
48
+
49
+ @Test
50
+ public void testExpandMultiValue() throws Exception {
51
+ Optional<String> nullValue = Optional.absent();
52
+ List<String> values = Lists.newArrayList("a", "b", "c");
53
+ QueryConfig config = new QueryConfig("test", nullValue, Optional.of(values), true);
54
+ List<QueryConfig.Query> dest = config.expand();
55
+ assertEquals(dest.size(), 3);
56
+ assertEquals(dest.get(0).getName(), "test");
57
+ assertEquals(dest.get(0).getValues().length, 1);
58
+ assertEquals(dest.get(0).getValues()[0], "a");
59
+
60
+ assertEquals(dest.get(1).getValues().length, 1);
61
+ assertEquals(dest.get(1).getName(), "test");
62
+ assertEquals(dest.get(1).getValues()[0], "b");
63
+
64
+ assertEquals(dest.get(2).getValues().length, 1);
65
+ assertEquals(dest.get(2).getName(), "test");
66
+ assertEquals(dest.get(2).getValues()[0], "c");
67
+ }
68
+
69
+ @Test(expected = IllegalArgumentException.class)
70
+ public void testExpandRaisesExceptionWhenBothValuesAreNull() throws Exception {
71
+ Optional<List<String>> nullValues = Optional.absent();
72
+ Optional<String> nullValue = Optional.absent();
73
+ QueryConfig config = new QueryConfig("test", nullValue, nullValues, false);
74
+ config.expand();
75
+ }
76
+
77
+ @Test
78
+ public void testUnExpandBrace() throws Exception {
79
+ Optional<List<String>> nullValues = Optional.absent();
80
+ QueryConfig config = new QueryConfig("test", Optional.of("{awesome1,awesome2,awesome3}"), nullValues, false);
81
+ List<QueryConfig.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
+ QueryConfig config = new QueryConfig("test", Optional.of("{awesome1,awesome2,awesome3}"), nullValues, true);
92
+ List<QueryConfig.Query> dest = config.expand();
93
+ assertEquals(dest.size(), 3);
94
+ assertEquals(dest.get(0).getName(), "test");
95
+ assertEquals(dest.get(0).getValues().length, 1);
96
+ assertEquals(dest.get(0).getValues()[0], "awesome1");
97
+ assertEquals(dest.get(1).getName(), "test");
98
+
99
+ assertEquals(dest.get(1).getValues().length, 1);
100
+ assertEquals(dest.get(1).getValues()[0], "awesome2");
101
+
102
+ assertEquals(dest.get(2).getValues().length, 1);
103
+ assertEquals(dest.get(2).getName(), "test");
104
+ assertEquals(dest.get(2).getValues()[0], "awesome3");
105
+ }
106
+
107
+ @Test
108
+ public void testExpandEscapedBrace() throws Exception {
109
+ Optional<List<String>> nullValues = Optional.absent();
110
+ QueryConfig config = new QueryConfig("test", Optional.of("{awe\\,some1,awes\\{ome2,awes\\}ome3}"), nullValues, true);
111
+ List<QueryConfig.Query> dest = config.expand();
112
+ assertEquals(dest.get(0).getName(), "test");
113
+ assertEquals(dest.get(0).getValues().length, 1);
114
+ assertEquals(dest.get(0).getValues()[0], "awe,some1");
115
+
116
+ assertEquals(dest.get(1).getName(), "test");
117
+ assertEquals(dest.get(1).getValues().length, 1);
118
+ assertEquals(dest.get(1).getValues()[0], "awes{ome2");
119
+
120
+ assertEquals(dest.get(2).getName(), "test");
121
+ assertEquals(dest.get(2).getValues().length, 1);
122
+ assertEquals(dest.get(2).getValues()[0], "awes}ome3");
123
+ }
124
+
125
+ }
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takuma kanari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
11
+ date: 2017-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
14
  requirement: !ruby/object:Gem::Requirement
21
15
  requirements:
22
16
  - - ~>
23
17
  - !ruby/object:Gem::Version
24
18
  version: '1.0'
19
+ name: bundler
25
20
  prerelease: false
26
21
  type: :development
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
- - - '>='
24
+ - - ~>
32
25
  - !ruby/object:Gem::Version
33
- version: '10.0'
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
36
30
  - - '>='
37
31
  - !ruby/object:Gem::Version
38
32
  version: '10.0'
33
+ name: rake
39
34
  prerelease: false
40
35
  type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
41
  description: Fetch data via http
42
42
  email:
43
43
  - chemtrails.t@gmail.com
@@ -45,9 +45,32 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - .gitignore
49
+ - LICENSE.txt
50
+ - README.md
51
+ - build.gradle
52
+ - config/checkstyle/checkstyle.xml
53
+ - config/checkstyle/default.xml
54
+ - example/json-example.yml
55
+ - gradle/wrapper/gradle-wrapper.jar
56
+ - gradle/wrapper/gradle-wrapper.properties
57
+ - gradlew
58
+ - gradlew.bat
59
+ - lib/embulk/input/http.rb
60
+ - settings.gradle
61
+ - src/main/java/org/embulk/input/http/BasicAuthConfig.java
62
+ - src/main/java/org/embulk/input/http/HttpFileInputPlugin.java
63
+ - src/main/java/org/embulk/input/http/PagerConfig.java
64
+ - src/main/java/org/embulk/input/http/ParamsConfig.java
65
+ - src/main/java/org/embulk/input/http/QueryConfig.java
66
+ - src/main/java/org/embulk/input/http/RetryableHandler.java
67
+ - src/test/java/org/embulk/input/http/TestHttpInputPlugin.java
68
+ - src/test/java/org/embulk/input/http/TestPagerConfig.java
69
+ - src/test/java/org/embulk/input/http/TestParamsConfig.java
70
+ - src/test/java/org/embulk/input/http/TestQueryConfig.java
48
71
  - classpath/commons-codec-1.9.jar
49
72
  - classpath/commons-logging-1.2.jar
50
- - classpath/embulk-input-http-0.0.14.jar
73
+ - classpath/embulk-input-http-0.0.15.jar
51
74
  - classpath/httpclient-4.5.jar
52
75
  - classpath/httpcore-4.4.1.jar
53
76
  homepage: https://github.com/takumakanari/embulk-input-http
Binary file