Skip to content

Commit

Permalink
Merge pull request #90 from rundeck/issue/89
Browse files Browse the repository at this point in the history
Fix broken run command
  • Loading branch information
gschueler authored Apr 13, 2017
2 parents a4b8ef4 + ba90c40 commit 1e282fb
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ dependencies {

testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'com.squareup.retrofit2:retrofit-mock:2.1.0'
testCompile 'com.squareup.okhttp3:mockwebserver:3.4.1'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
testCompile "org.codehaus.groovy:groovy-all:2.3.7"
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/rundeck/client/api/model/DateInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.rundeck.client.api.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.rundeck.client.util.Format;

Expand All @@ -28,13 +29,15 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class DateInfo {
public static final String ISO = "yyyy-MM-dd'T'HH:mm:ss'Z'";
public final String date;
public String date;
public long unixtime;

public DateInfo(final String date) {
this.date = date;
}

public DateInfo() {
}
public Date toDate() throws ParseException {
return toDate(ISO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@
package org.rundeck.client.tool.commands

import com.simplifyops.toolbelt.CommandOutput
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.mockwebserver.RecordedRequest
import org.rundeck.client.api.RundeckApi
import org.rundeck.client.api.model.ExecOutput
import org.rundeck.client.api.model.Execution
import org.rundeck.client.tool.AppConfig
import org.rundeck.client.tool.RdApp
import org.rundeck.client.util.Client
import retrofit2.Retrofit
import retrofit2.converter.jackson.JacksonConverterFactory
import retrofit2.mock.Calls
import spock.lang.Specification

Expand Down Expand Up @@ -84,4 +91,61 @@ class ExecutionsSpec extends Specification {
'scheduled' | false | true | 'failed' | false

}

def "parse execution"() {
given:
MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().setBody('''{
"id": 5418,
"href": "http://ecto1.local:4440/api/19/execution/5418",
"permalink": "http://ecto1.local:4440/project/adubs/execution/show/5418",
"status": "succeeded",
"project": "adubs",
"user": "admin",
"date-started": {
"unixtime": 1492043359634,
"date": "2017-04-13T00:29:19Z"
},
"date-ended": {
"unixtime": 1492043360117,
"date": "2017-04-13T00:29:20Z"
},
"job": {
"id": "58d4de5d-5aac-438b-9b0f-252b46c9d117",
"averageDuration": 926,
"name": "asdf",
"group": "",
"project": "adubs",
"description": "fff",
"href": "http://ecto1.local:4440/api/19/job/58d4de5d-5aac-438b-9b0f-252b46c9d117",
"permalink": "http://ecto1.local:4440/project/adubs/job/show/58d4de5d-5aac-438b-9b0f-252b46c9d117"
},
"description": "echo blah blah",
"argstring": null,
"serverUUID": "3425B691-7319-4EEE-8425-F053C628B4BA",
"successfulNodes": [
"ecto1.local"
]
}'''
).addHeader('content-type', 'application/json')
);
server.start()

def retrofit = new Retrofit.Builder().baseUrl(server.url('/api/19/')).
addConverterFactory(JacksonConverterFactory.create()).
build()
def api = retrofit.create(RundeckApi)

when:
def body = api.getExecution('123').execute().body()

then:
RecordedRequest request1 = server.takeRequest()
request1.path == '/api/19/execution/123'

body.dateStarted != null
body.dateStarted.date == '2017-04-13T00:29:19Z'
server.shutdown()

}
}

0 comments on commit 1e282fb

Please sign in to comment.