mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-13 00:18:42 +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() {
|
int getApiVersion() {
|
||||||
return apiVersion;
|
return (apiVersion > 0 ? apiVersion : API_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setApiVersion(int apiVersion) {
|
void setApiVersion(int apiVersion) {
|
||||||
this.apiVersion = apiVersion;
|
this.apiVersion = (apiVersion > 0 ? apiVersion : API_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setApiVersion(Version apiVersion) {
|
void setApiVersion(Version apiVersion) {
|
||||||
this.apiVersion = apiVersion.getVersionNumber();
|
setApiVersion(apiVersion.getVersionNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
String getApiEndpoint() {
|
String getApiEndpoint() {
|
||||||
|
|
|
@ -61,6 +61,18 @@ public class RundeckClientTest {
|
||||||
|
|
||||||
private RundeckClient client;
|
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
|
@Test
|
||||||
@Betamax(tape = "get_projects")
|
@Betamax(tape = "get_projects")
|
||||||
public void getProjects() throws Exception {
|
public void getProjects() throws Exception {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue