diff --git a/pom.xml b/pom.xml
index 7ad6f3faa..4dc15fd8c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -801,6 +801,30 @@
${version.wiremock}
test
+
+ com.squareup.okhttp3
+ mockwebserver
+ 4.10.0
+ test
+
+
+ io.projectreactor
+ reactor-test
+ 3.6.0
+ test
+
+
+ org.springframework
+ spring-test
+ 5.3.29
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ ${version.spring-webflux}
+ test
+
com.fasterxml.jackson.core
jackson-annotations
diff --git a/rest-mvc/pom.xml b/rest-mvc/pom.xml
index 09b6c8fc9..50a9c5419 100644
--- a/rest-mvc/pom.xml
+++ b/rest-mvc/pom.xml
@@ -59,6 +59,31 @@
tank-script-processor
${project.version}
+
+ com.squareup.okhttp3
+ mockwebserver
+ test
+
+
+ org.wiremock
+ wiremock
+ test
+
+
+ io.projectreactor
+ reactor-test
+ test
+
+
+ org.springframework
+ spring-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/AgentClient.java b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/AgentClient.java
index d2f9173c8..e774ca787 100644
--- a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/AgentClient.java
+++ b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/AgentClient.java
@@ -20,8 +20,6 @@
import org.springframework.http.MediaType;
import reactor.core.publisher.Mono;
-import java.util.Map;
-
public class AgentClient extends BaseClient{
private static final String SERVICE_BASE_URL = "/v2/agent";
@@ -44,7 +42,7 @@ public String getSettings() {
.uri(urlBuilder.buildUrl("/settings"))
.accept(MediaType.APPLICATION_XML)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -57,7 +55,7 @@ public Mono getSupportFiles() {
.uri(urlBuilder.buildUrl("/support-files"))
.accept(MediaType.APPLICATION_OCTET_STREAM)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -71,7 +69,7 @@ public AgentTestStartData agentReady(AgentData agentData) {
.accept(MediaType.APPLICATION_JSON)
.body(Mono.just(agentData), AgentData.class)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -84,7 +82,7 @@ public Headers getHeaders() {
.uri(urlBuilder.buildUrl("/headers"))
.accept(MediaType.APPLICATION_XML)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -97,7 +95,7 @@ public TankHttpClientDefinitionContainer getClients() {
.uri(urlBuilder.buildUrl("/clients"))
.accept(MediaType.APPLICATION_XML)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -111,7 +109,7 @@ public Void setStandaloneAgentAvailability(AgentAvailability availability) {
.contentType(MediaType.APPLICATION_JSON)
.body(Mono.just(availability), AgentAvailability.class)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -124,7 +122,7 @@ public CloudVmStatus getInstanceStatus(String instanceId) {
.uri(urlBuilder.buildUrl("/instance/status/", instanceId))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -138,7 +136,7 @@ public Void setInstanceStatus(String instanceId, CloudVmStatus VmStatus) {
.contentType(MediaType.APPLICATION_JSON)
.body(Mono.just(VmStatus), CloudVmStatus.class)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -146,12 +144,14 @@ public Void setInstanceStatus(String instanceId, CloudVmStatus VmStatus) {
.block();
}
+ // Instance Actions
+
public String stopInstance(String instanceId) {
return client.get()
.uri(urlBuilder.buildUrl("/instance/stop/", instanceId))
.accept(MediaType.TEXT_PLAIN)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -164,7 +164,7 @@ public String pauseInstance(String instanceId) {
.uri(urlBuilder.buildUrl("/instance/pause/", instanceId))
.accept(MediaType.TEXT_PLAIN)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -177,7 +177,7 @@ public String resumeInstance(String instanceId) {
.uri(urlBuilder.buildUrl("/instance/resume/", instanceId))
.accept(MediaType.TEXT_PLAIN)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -190,7 +190,7 @@ public String killInstance(String instanceId) {
.uri(urlBuilder.buildUrl("/instance/kill/", instanceId))
.accept(MediaType.TEXT_PLAIN)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
diff --git a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/BaseClient.java b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/BaseClient.java
index 15e3b8195..2f96abf91 100644
--- a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/BaseClient.java
+++ b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/BaseClient.java
@@ -76,7 +76,7 @@ public String ping() {
.uri(urlBuilder.buildUrl("/ping"))
.accept(MediaType.TEXT_PLAIN)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
diff --git a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/DataFileClient.java b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/DataFileClient.java
index 2093de274..ca0905580 100644
--- a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/DataFileClient.java
+++ b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/DataFileClient.java
@@ -14,6 +14,12 @@
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.core.io.buffer.DataBuffer;
+import org.springframework.web.reactive.function.BodyInserters;
+import org.springframework.http.ResponseEntity;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpStatus;
+import org.springframework.util.MultiValueMap;
+import org.springframework.util.LinkedMultiValueMap;
import org.springframework.http.MediaType;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -43,7 +49,7 @@ public DataFileDescriptorContainer getDatafiles() {
.uri(baseUrl)
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -56,7 +62,7 @@ public DataFileDescriptor getDatafile(Integer datafileId) {
.uri(urlBuilder.buildUrl("", datafileId))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -71,7 +77,7 @@ public String getDatafileContent(Integer datafileId) {
.queryParam("id", datafileId.toString())
.build())
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -90,29 +96,30 @@ public Mono downloadDatafile(Integer datafileId) {
.uri(urlBuilder.buildUrl("/download", datafileId))
.accept(MediaType.APPLICATION_OCTET_STREAM)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
.bodyToMono(DataBuffer.class);
}
- public Map uploadDatafile(Integer id, MultipartFile file) {
- return client.post()
- .uri(uriBuilder -> uriBuilder
- .path(urlBuilder.buildUrl("/upload"))
+ public Mono>> uploadDatafile(Integer id, MultipartFile file) {
+ MultiValueMap formData = new LinkedMultiValueMap<>();
+ formData.add("file", file.getResource());
+
+ return WebClient.create(urlBuilder.buildUrl(""))
+ .post()
+ .uri(uriBuilder -> uriBuilder.path("/upload")
.queryParam("id", id)
.build())
.contentType(MediaType.MULTIPART_FORM_DATA)
- .accept(MediaType.APPLICATION_JSON)
- .body(Mono.just(file), MultipartFile.class)
+ .body(BodyInserters.fromMultipartData(formData))
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
- .bodyToMono(Map.class)
- .block();
+ .toEntity(new ParameterizedTypeReference<>() {});
}
public String deleteDatafile(Integer datafileID) {
@@ -120,7 +127,7 @@ public String deleteDatafile(Integer datafileID) {
.uri(urlBuilder.buildUrl("", datafileID))
.accept(MediaType.TEXT_PLAIN)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
diff --git a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/FilterClient.java b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/FilterClient.java
index 3280f8477..53d7b4ef3 100644
--- a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/FilterClient.java
+++ b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/FilterClient.java
@@ -9,6 +9,7 @@
import com.intuit.tank.rest.mvc.rest.clients.util.ClientException;
import com.intuit.tank.rest.mvc.rest.models.filters.*;
+import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import reactor.core.publisher.Mono;
@@ -36,7 +37,7 @@ public FilterContainer getFilters() {
.uri(baseUrl)
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -49,7 +50,7 @@ public FilterGroupContainer getFilterGroups() {
.uri(urlBuilder.buildUrl("/groups"))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -62,7 +63,7 @@ public FilterTO getFilter(Integer filterId) {
.uri(urlBuilder.buildUrl("", filterId))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -75,7 +76,7 @@ public FilterGroupTO getFilterGroup(Integer filterGroupId) {
.uri(urlBuilder.buildUrl("", filterGroupId))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -90,7 +91,7 @@ public String applyFilters(Integer scriptId, ApplyFiltersRequest request) {
.accept(MediaType.TEXT_PLAIN)
.body(Mono.just(request), ApplyFiltersRequest.class)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -103,7 +104,7 @@ public String deleteFilter(Integer filterId) {
.uri(urlBuilder.buildUrl("", filterId))
.accept(MediaType.TEXT_PLAIN)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -116,7 +117,7 @@ public String deleteFilterGroup(Integer filterGroupId) {
.uri(urlBuilder.buildUrl("", filterGroupId))
.accept(MediaType.TEXT_PLAIN)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
diff --git a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/JobClient.java b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/JobClient.java
index 40b0e0446..84212db9b 100644
--- a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/JobClient.java
+++ b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/clients/JobClient.java
@@ -11,6 +11,8 @@
import com.intuit.tank.rest.mvc.rest.models.jobs.CreateJobRequest;
import com.intuit.tank.rest.mvc.rest.models.jobs.JobContainer;
import com.intuit.tank.rest.mvc.rest.models.jobs.JobTO;
+import com.intuit.tank.vm.vmManager.models.CloudVmStatusContainer;
+import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import reactor.core.publisher.Mono;
@@ -39,7 +41,7 @@ public JobContainer getAllJobs() {
.uri(baseUrl)
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -52,7 +54,7 @@ public JobTO getJob(Integer jobId) {
.uri(urlBuilder.buildUrl("", jobId))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -65,7 +67,7 @@ public JobContainer getJobsByProject(Integer projectId) {
.uri(urlBuilder.buildUrl("/project", projectId))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -80,7 +82,7 @@ public Map createJob(CreateJobRequest request) {
.accept(MediaType.APPLICATION_JSON)
.body(Mono.just(request), CreateJobRequest.class)
.retrieve()
- .onStatus(status -> status.isError(),
+ .onStatus(HttpStatus::isError,
response -> response.bodyToMono(String.class)
.flatMap(body -> Mono.error(new ClientException(body,
response.statusCode().value()))))
@@ -93,7 +95,7 @@ public List