mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-07 13:38:23 +00:00
Merge branch 'issue/exec-query-timezone' for #16
This commit is contained in:
commit
f133c04a02
3 changed files with 59 additions and 2 deletions
|
@ -36,6 +36,9 @@ import java.util.*;
|
||||||
abstract class QueryParameterBuilder implements ApiPathBuilder.BuildsParameters {
|
abstract class QueryParameterBuilder implements ApiPathBuilder.BuildsParameters {
|
||||||
public static final String W3C_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
public static final String W3C_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||||
static final SimpleDateFormat format = new SimpleDateFormat(W3C_DATE_FORMAT);
|
static final SimpleDateFormat format = new SimpleDateFormat(W3C_DATE_FORMAT);
|
||||||
|
static {
|
||||||
|
format.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a value to the builder for a given key
|
* Add a value to the builder for a given key
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package org.rundeck.api;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.rundeck.api.query.ExecutionQuery;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ExecutionQueryParametersTest is ...
|
||||||
|
*
|
||||||
|
* @author Greg Schueler <greg@simplifyops.com>
|
||||||
|
* @since 2014-11-07
|
||||||
|
*/
|
||||||
|
public class ExecutionQueryParametersTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void stringParameter() {
|
||||||
|
ExecutionQuery.Builder description = ExecutionQuery.builder().description("a description");
|
||||||
|
ExecutionQueryParameters executionQueryParameters = new ExecutionQueryParameters(
|
||||||
|
description.build()
|
||||||
|
);
|
||||||
|
ApiPathBuilder param = new ApiPathBuilder("").param(executionQueryParameters);
|
||||||
|
Assert.assertEquals("?descFilter=a+description", param.toString());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void listParameter() {
|
||||||
|
ExecutionQuery.Builder description = ExecutionQuery.builder().excludeJobList(
|
||||||
|
Arrays.asList(
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
ExecutionQueryParameters executionQueryParameters = new ExecutionQueryParameters(
|
||||||
|
description.build()
|
||||||
|
);
|
||||||
|
ApiPathBuilder param = new ApiPathBuilder("").param(executionQueryParameters);
|
||||||
|
Assert.assertEquals("?excludeJobListFilter=a&excludeJobListFilter=b", param.toString());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void dateParameter() {
|
||||||
|
ExecutionQuery.Builder description = ExecutionQuery.builder().end(
|
||||||
|
new Date(1347581178168L)
|
||||||
|
);
|
||||||
|
ExecutionQueryParameters executionQueryParameters = new ExecutionQueryParameters(
|
||||||
|
description.build()
|
||||||
|
);
|
||||||
|
ApiPathBuilder param = new ApiPathBuilder("").param(executionQueryParameters);
|
||||||
|
//nb: timezone should be GMT
|
||||||
|
//2012-09-14T00:06:18Z
|
||||||
|
Assert.assertEquals("?end=2012-09-14T00%3A06%3A18Z", param.toString());
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,7 +38,7 @@ interactions:
|
||||||
- recorded: 2012-09-14T22:04:13.342Z
|
- recorded: 2012-09-14T22:04:13.342Z
|
||||||
request:
|
request:
|
||||||
method: GET
|
method: GET
|
||||||
uri: http://rundeck.local:4440/api/5/executions?project=blah&begin=2012-09-13T17%3A06%3A18Z&max=2&offset=0
|
uri: http://rundeck.local:4440/api/5/executions?project=blah&begin=2012-09-14T00%3A06%3A18Z&max=2&offset=0
|
||||||
headers:
|
headers:
|
||||||
Accept: text/xml
|
Accept: text/xml
|
||||||
Host: rundeck.local:4440
|
Host: rundeck.local:4440
|
||||||
|
@ -54,7 +54,7 @@ interactions:
|
||||||
- recorded: 2012-09-14T22:04:13.404Z
|
- recorded: 2012-09-14T22:04:13.404Z
|
||||||
request:
|
request:
|
||||||
method: GET
|
method: GET
|
||||||
uri: http://rundeck.local:4440/api/5/executions?project=blah&end=2012-09-13T17%3A06%3A18Z&max=2&offset=0
|
uri: http://rundeck.local:4440/api/5/executions?project=blah&end=2012-09-14T00%3A06%3A18Z&max=2&offset=0
|
||||||
headers:
|
headers:
|
||||||
Accept: text/xml
|
Accept: text/xml
|
||||||
Host: rundeck.local:4440
|
Host: rundeck.local:4440
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue