embulk-input-jira 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62552f42fdada57506d9dba69a692e46a2d26ae0
4
- data.tar.gz: 98254e3f22f27b3e724b65457bc824d424c46949
3
+ metadata.gz: bffa95b4ab1e2b43adb69e1a94ca3264d4c50589
4
+ data.tar.gz: 949d00a53b677ad6264db49eaceaa405bbb6607b
5
5
  SHA512:
6
- metadata.gz: 63998e221582f23434ac6a37b2cbd0214865bc22a96b814b3946839c345f9bb7fdb714ee25818a48c077e0d8e2aee5b477af97ed0bca1bad95de65c9eb3c47e7
7
- data.tar.gz: d6eb0d245eff6dae69c25c48949767d7c9660e597740ba579f5569ca9c947c26ceefb596d01c1ba7d0f1da09651ab9be4a9324c250e01c13e67742ed22936f3a
6
+ metadata.gz: b238a357a63fab9aeefd3b195dcc2ad1c9f934c1a310b031c7648c63ea72537c9ab2fdd13f88519d2fab516d3d5c508b6d33e592b1af4a64f18f4d9a7852a630
7
+ data.tar.gz: e35f6c9bf319e7b4802ce031592ade24b11781c7231f6191ed437550275bce3a05cb77f090902a2749037c4aa33982d6ed505f2ca994e73a5f22430eb823eef2
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## 0.2.5 - 2019-03-05
1
+ ## 0.2.7 - 2019-03-05
2
+
3
+ * [enhancement] Support empty JQL [#55](https://github.com/treasure-data/embulk-input-jira/pull/55)
4
+
5
+ ## 0.2.6 - 2019-03-01
2
6
 
3
7
  * [enhancement] Change from ruby to java plugin [#53](https://github.com/treasure-data/embulk-input-jira/pull/53)
4
8
 
data/build.gradle CHANGED
@@ -17,7 +17,7 @@ configurations {
17
17
  provided
18
18
  }
19
19
 
20
- version = "0.2.6"
20
+ version = "0.2.7"
21
21
 
22
22
  sourceCompatibility = 1.8
23
23
  targetCompatibility = 1.8
@@ -3,6 +3,7 @@ package org.embulk.input.jira;
3
3
  import com.fasterxml.jackson.databind.JsonNode;
4
4
  import com.fasterxml.jackson.databind.ObjectMapper;
5
5
  import com.google.common.annotations.VisibleForTesting;
6
+ import com.google.common.base.Optional;
6
7
  import com.google.common.collect.ImmutableList;
7
8
  import com.google.gson.JsonArray;
8
9
  import com.google.gson.JsonElement;
@@ -74,7 +75,8 @@ public class JiraInputPlugin
74
75
  public int getRetryLimit();
75
76
 
76
77
  @Config("jql")
77
- public String getJQL();
78
+ @ConfigDefault("null")
79
+ public Optional<String> getJQL();
78
80
 
79
81
  @Config("columns")
80
82
  public SchemaConfig getColumns();
@@ -1,6 +1,7 @@
1
1
  package org.embulk.input.jira.client;
2
2
 
3
3
  import com.google.common.annotations.VisibleForTesting;
4
+ import com.google.common.base.Optional;
4
5
  import com.google.gson.JsonArray;
5
6
  import com.google.gson.JsonElement;
6
7
  import com.google.gson.JsonObject;
@@ -243,7 +244,8 @@ public class JiraClient
243
244
  private String createSearchIssuesBody(PluginTask task, int startAt, int maxResults)
244
245
  {
245
246
  JsonObject body = new JsonObject();
246
- body.add("jql", new JsonPrimitive(task.getJQL()));
247
+ Optional<String> jql = task.getJQL();
248
+ body.add("jql", new JsonPrimitive(jql.or("")));
247
249
  body.add("startAt", new JsonPrimitive(startAt));
248
250
  body.add("maxResults", new JsonPrimitive(maxResults));
249
251
  JsonArray fields = new JsonArray();
@@ -76,10 +76,6 @@ public final class JiraUtil
76
76
  connection.disconnect();
77
77
  }
78
78
  }
79
- String jql = task.getJQL();
80
- if (isNullOrEmpty(jql)) {
81
- throw new ConfigException("JQL could not be empty");
82
- }
83
79
  int retryInitialWaitSec = task.getInitialRetryIntervalMillis();
84
80
  if (retryInitialWaitSec < 1) {
85
81
  throw new ConfigException("Initial retry delay should be equal or greater than 1");
@@ -8,6 +8,7 @@ import org.apache.http.client.HttpClient;
8
8
  import org.apache.http.entity.StringEntity;
9
9
  import org.embulk.EmbulkTestRuntime;
10
10
  import org.embulk.config.ConfigException;
11
+ import org.embulk.config.ConfigSource;
11
12
  import org.embulk.input.jira.Issue;
12
13
  import org.embulk.input.jira.JiraInputPlugin.PluginTask;
13
14
  import org.embulk.input.jira.TestHelpers;
@@ -219,4 +220,28 @@ public class JiraClientTest
219
220
 
220
221
  assertThrows(ConfigException.class, () -> jiraClient.searchIssues(task, 0, 50));
221
222
  }
223
+
224
+ @Test
225
+ public void test_searchIssues_emptyJql() throws IOException
226
+ {
227
+ String dataName = "searchIssuesSuccess";
228
+ JsonObject messageResponse = data.get(dataName).getAsJsonObject();
229
+
230
+ int statusCode = messageResponse.get("statusCode").getAsInt();
231
+ String body = messageResponse.get("body").toString();
232
+
233
+ when(statusLine.getStatusCode()).thenReturn(statusCode);
234
+ when(response.getEntity()).thenReturn(new StringEntity(body));
235
+ ConfigSource config = TestHelpers.config().remove("jql");
236
+ task = config.loadConfig(PluginTask.class);
237
+
238
+ List<Issue> issues = jiraClient.searchIssues(task, 0, 50);
239
+ assertEquals(issues.size(), 2);
240
+
241
+ config = TestHelpers.config().set("jql", "");
242
+ task = config.loadConfig(PluginTask.class);
243
+
244
+ issues = jiraClient.searchIssues(task, 0, 50);
245
+ assertEquals(issues.size(), 2);
246
+ }
222
247
  }
@@ -196,9 +196,19 @@ public class JiraUtilTest
196
196
  catch (Exception e) {
197
197
  exception = e;
198
198
  }
199
- assertNotNull(exception);
200
- assertTrue(exception instanceof ConfigException);
201
- assertEquals("JQL could not be empty", exception.getMessage());
199
+ assertNull(exception);
200
+
201
+ configSource = TestHelpers.config();
202
+ configSource.remove("jql");
203
+ task = configSource.loadConfig(PluginTask.class);
204
+ exception = null;
205
+ try {
206
+ JiraUtil.validateTaskConfig(task);
207
+ }
208
+ catch (Exception e) {
209
+ exception = e;
210
+ }
211
+ assertNull(exception);
202
212
 
203
213
  // initial_retry_interval_millis = 0
204
214
  configSource = TestHelpers.config();
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-jira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - uu59
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-03-01 00:00:00.000000000 Z
12
+ date: 2019-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ files:
56
56
  - build.gradle
57
57
  - classpath/commons-codec-1.10.jar
58
58
  - classpath/commons-logging-1.2.jar
59
- - classpath/embulk-input-jira-0.2.6.jar
59
+ - classpath/embulk-input-jira-0.2.7.jar
60
60
  - classpath/embulk-util-retryhelper-jetty92-0.6.0.jar
61
61
  - classpath/gson-2.8.5.jar
62
62
  - classpath/httpclient-4.5.6.jar