Skip to content

Commit

Permalink
Fix #1 execution parser to include argstring
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Oct 5, 2012
1 parent adfcc63 commit 1a810ac
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/main/java/org/rundeck/api/domain/RundeckExecution.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class RundeckExecution implements Serializable {
private String abortedBy;

private String description;
private String argstring;

/**
* @return the duration of the execution in milliseconds (or null if the duration is still running, or has been
Expand Down Expand Up @@ -170,6 +171,7 @@ public void setDescription(String description) {
@Override
public String toString() {
return "RundeckExecution [id=" + id + ", description=" + description + ", url=" + url + ", status=" + status
+ ", argstring=" + argstring
+ ", startedBy=" + startedBy + ", startedAt=" + startedAt + ", endedAt=" + endedAt
+ ", durationInSeconds=" + getDurationInSeconds() + ", abortedBy=" + abortedBy + ", job=" + job + "]";
}
Expand All @@ -179,6 +181,7 @@ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((abortedBy == null) ? 0 : abortedBy.hashCode());
result = prime * result + ((argstring == null) ? 0 : argstring.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((endedAt == null) ? 0 : endedAt.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
Expand All @@ -204,6 +207,11 @@ public boolean equals(Object obj) {
return false;
} else if (!abortedBy.equals(other.abortedBy))
return false;
if (argstring == null) {
if (other.argstring != null)
return false;
} else if (!argstring.equals(other.argstring))
return false;
if (description == null) {
if (other.description != null)
return false;
Expand Down Expand Up @@ -247,6 +255,17 @@ public boolean equals(Object obj) {
return true;
}

/**
* the argument string for the execution
*/
public String getArgstring() {
return argstring;
}

public void setArgstring(String argstring) {
this.argstring = argstring;
}

/**
* The status of an execution
*/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/rundeck/api/parser/ExecutionParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public RundeckExecution parseXmlNode(Node node) {
execution.setStatus(null);
}
execution.setDescription(StringUtils.trimToNull(execNode.valueOf("description")));
execution.setArgstring(StringUtils.trimToNull(execNode.valueOf("argstring")));
execution.setStartedBy(StringUtils.trimToNull(execNode.valueOf("user")));
execution.setAbortedBy(StringUtils.trimToNull(execNode.valueOf("abortedby")));
String startedAt = StringUtils.trimToNull(execNode.valueOf("date-started/@unixtime"));
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/org/rundeck/api/parser/ExecutionParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void parseRunningExecution() throws Exception {
Assert.assertEquals(null, execution.getDuration());
Assert.assertEquals(null, execution.getAbortedBy());
Assert.assertEquals("ls ${option.dir}", execution.getDescription());
Assert.assertEquals("-arg1 value -arg2 value", execution.getArgstring());

Assert.assertEquals("1", job.getId());
Assert.assertEquals("ls", job.getName());
Expand All @@ -75,6 +76,7 @@ public void parseSucceededExecution() throws Exception {
Assert.assertEquals("1 minute 4 seconds", execution.getDuration());
Assert.assertEquals(null, execution.getAbortedBy());
Assert.assertEquals("ls ${option.dir}", execution.getDescription());
Assert.assertEquals("-argA some -argB thing", execution.getArgstring());

Assert.assertEquals("1", job.getId());
Assert.assertEquals("ls", job.getName());
Expand All @@ -101,6 +103,7 @@ public void parseAdhocExecution() throws Exception {
Assert.assertEquals("0 seconds", execution.getDuration());
Assert.assertEquals(null, execution.getAbortedBy());
Assert.assertEquals("w", execution.getDescription());
Assert.assertEquals("-monkey true", execution.getArgstring());

Assert.assertNull(job);
}
Expand All @@ -123,6 +126,7 @@ public void parseMinimalistExecution() throws Exception {
Assert.assertNull(execution.getDuration());
Assert.assertNull(execution.getAbortedBy());
Assert.assertNull(execution.getDescription());
Assert.assertNull(execution.getArgstring());

Assert.assertNull(job);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<result success='true' apiversion='1'><executions count='1'><execution id='1' href='http://localhost:4440/execution/follow/1' status='succeeded'><user>admin</user><date-started unixtime='1309857539137'>2011-07-05T09:18:59Z</date-started><date-ended unixtime='1309857539606'>2011-07-05T09:18:59Z</date-ended><description>w</description></execution></executions></result>
<result success='true' apiversion='1'><executions count='1'><execution id='1' href='http://localhost:4440/execution/follow/1' status='succeeded'><user>admin</user><date-started unixtime='1309857539137'>2011-07-05T09:18:59Z</date-started><date-ended unixtime='1309857539606'>2011-07-05T09:18:59Z</date-ended><description>w</description><argstring>-monkey true</argstring></execution></executions></result>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<result success='true' apiversion='1'><executions count='1'><execution id='1' href='http://localhost:4440/execution/follow/1' status='running'><user>admin</user><date-started unixtime='1302183830082'>2011-04-07T13:43:50Z</date-started><job id='1'><name>ls</name><group>system</group><project>test</project><description>list files</description></job><description>ls ${option.dir}</description></execution></executions></result>
<result success='true' apiversion='1'><executions count='1'><execution id='1' href='http://localhost:4440/execution/follow/1' status='running'><user>admin</user><date-started unixtime='1302183830082'>2011-04-07T13:43:50Z</date-started><job id='1'><name>ls</name><group>system</group><project>test</project><description>list files</description></job><description>ls ${option.dir}</description><argstring>-arg1 value -arg2 value</argstring></execution></executions></result>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<result success='true' apiversion='1'><executions count='1'><execution id='1' href='http://localhost:4440/execution/follow/1' status='succeeded'><user>admin</user><date-started unixtime="1308322895104">2011-06-17T15:01:35Z</date-started><date-ended unixtime="1308322959420">2011-06-17T15:02:39Z</date-ended><job id='1'><name>ls</name><group>system</group><project>test</project><description>list files</description></job><description>ls ${option.dir}</description></execution></executions></result>
<result success='true' apiversion='1'><executions count='1'><execution id='1' href='http://localhost:4440/execution/follow/1' status='succeeded'><user>admin</user><date-started unixtime="1308322895104">2011-06-17T15:01:35Z</date-started><date-ended unixtime="1308322959420">2011-06-17T15:02:39Z</date-ended><job id='1'><name>ls</name><group>system</group><project>test</project><description>list files</description></job><description>ls ${option.dir}</description><argstring>-argA some -argB thing</argstring></execution></executions></result>

0 comments on commit 1a810ac

Please sign in to comment.