Add project to parsed execution result for api v9

This commit is contained in:
Greg Schueler 2013-08-21 10:16:03 -07:00
parent d662909719
commit 2854fa9df3
4 changed files with 51 additions and 0 deletions

View file

@ -51,6 +51,7 @@ public class RundeckExecution implements Serializable {
private String description;
private String argstring;
private String project;
/**
* @return the duration of the execution in milliseconds (or null if the duration is still running, or has been
@ -190,6 +191,7 @@ public class RundeckExecution implements Serializable {
result = prime * result + ((startedBy == null) ? 0 : startedBy.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result + ((url == null) ? 0 : url.hashCode());
result = prime * result + ((project == null) ? 0 : project.hashCode());
return result;
}
@ -252,6 +254,11 @@ public class RundeckExecution implements Serializable {
return false;
} else if (!url.equals(other.url))
return false;
if (project == null) {
if (other.project != null)
return false;
} else if (!project.equals(other.project))
return false;
return true;
}
@ -266,6 +273,14 @@ public class RundeckExecution implements Serializable {
this.argstring = argstring;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
/**
* The status of an execution
*/

View file

@ -60,6 +60,7 @@ public class ExecutionParser implements XmlNodeParser<RundeckExecution> {
execution.setArgstring(StringUtils.trimToNull(execNode.valueOf("argstring")));
execution.setStartedBy(StringUtils.trimToNull(execNode.valueOf("user")));
execution.setAbortedBy(StringUtils.trimToNull(execNode.valueOf("abortedby")));
execution.setProject(StringUtils.trimToNull(execNode.valueOf("@project")));
String startedAt = StringUtils.trimToNull(execNode.valueOf("date-started/@unixtime"));
if (startedAt != null) {
execution.setStartedAt(new Date(Long.valueOf(startedAt)));

View file

@ -131,4 +131,29 @@ public class ExecutionParserTest {
Assert.assertNull(job);
}
@Test
public void parseV9Execution() throws Exception {
InputStream input = getClass().getResourceAsStream("execution-running-v9.xml");
Document document = ParserHelper.loadDocument(input);
RundeckExecution execution = new ExecutionParser("result/executions/execution").parseXmlNode(document);
RundeckJob job = execution.getJob();
Assert.assertEquals(null, job);
Assert.assertEquals(new Long(119), execution.getId());
Assert.assertEquals("http://localhost:4440/execution/follow/119", execution.getUrl());
Assert.assertEquals(ExecutionStatus.RUNNING, execution.getStatus());
Assert.assertEquals("admin", execution.getStartedBy());
Assert.assertEquals(new Date(1377104570966L), execution.getStartedAt());
Assert.assertEquals(null, execution.getEndedAt());
Assert.assertEquals(null, execution.getDurationInMillis());
Assert.assertEquals(null, execution.getDuration());
Assert.assertEquals(null, execution.getAbortedBy());
Assert.assertEquals("echo asdf; sleep 120", execution.getDescription());
Assert.assertEquals(null, execution.getArgstring());
Assert.assertEquals("test", execution.getProject());
}
}

View file

@ -0,0 +1,10 @@
<result success='true' apiversion='9'>
<executions count='1'>
<execution id='119' href='http://localhost:4440/execution/follow/119' status='running' project='test'>
<user>admin</user>
<date-started unixtime='1377104570966'>2013-08-21T17:02:50Z</date-started>
<description>echo asdf; sleep 120</description>
<argstring/>
</execution>
</executions>
</result>