mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-10 06:58:47 +00:00
ApiVersion cannot be set to something less than 1
This commit is contained in:
parent
deee2ac0b1
commit
b08edf9010
2 changed files with 15 additions and 3 deletions
|
@ -157,15 +157,15 @@ public class RundeckClient implements Serializable {
|
|||
}
|
||||
|
||||
int getApiVersion() {
|
||||
return apiVersion;
|
||||
return (apiVersion > 0 ? apiVersion : API_VERSION);
|
||||
}
|
||||
|
||||
void setApiVersion(int apiVersion) {
|
||||
this.apiVersion = apiVersion;
|
||||
this.apiVersion = (apiVersion > 0 ? apiVersion : API_VERSION);
|
||||
}
|
||||
|
||||
void setApiVersion(Version apiVersion) {
|
||||
this.apiVersion = apiVersion.getVersionNumber();
|
||||
setApiVersion(apiVersion.getVersionNumber());
|
||||
}
|
||||
|
||||
String getApiEndpoint() {
|
||||
|
|
|
@ -61,6 +61,18 @@ public class RundeckClientTest {
|
|||
|
||||
private RundeckClient client;
|
||||
|
||||
@Test
|
||||
public void apiVersionDefaultLatest() {
|
||||
RundeckClient blah = createClient("blah", 0);
|
||||
Assert.assertEquals("/api/" + RundeckClient.API_VERSION, blah.getApiEndpoint());
|
||||
Assert.assertEquals(RundeckClient.API_VERSION, blah.getApiVersion());
|
||||
blah.setApiVersion(0);
|
||||
Assert.assertEquals(RundeckClient.API_VERSION, blah.getApiVersion());
|
||||
blah.setApiVersion(-1);
|
||||
Assert.assertEquals(RundeckClient.API_VERSION, blah.getApiVersion());
|
||||
blah.setApiVersion(RundeckClient.Version.V9.getVersionNumber());
|
||||
Assert.assertEquals(RundeckClient.Version.V9.getVersionNumber(), blah.getApiVersion());
|
||||
}
|
||||
@Test
|
||||
@Betamax(tape = "get_projects")
|
||||
public void getProjects() throws Exception {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue