embulk-input-http 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,125 +0,0 @@
1
- package org.embulk.input;
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
- }