import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
-@RestController("EcsSimulatorController")
-@Tag(name = "EcsSimulator")
+@RestController("IcsSimulatorController")
+@Tag(name = "Information Coordinator Service Simulator (exists only in test)")
public class EcsSimulatorController {
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static class TestResults {
- ProducerRegistrationInfo registrationInfo;
+ ProducerRegistrationInfo registrationInfo = null;
Map<String, ProducerInfoTypeInfo> types = new HashMap<>();
+ String infoProducerId = null;
public TestResults() {}
public void reset() {
registrationInfo = null;
types.clear();
+ infoProducerId = null;
}
}
@PathVariable("infoProducerId") String infoProducerId, //
@RequestBody ProducerRegistrationInfo registrationInfo) {
testResults.registrationInfo = registrationInfo;
+ testResults.infoProducerId = infoProducerId;
return new ResponseEntity<>(HttpStatus.OK);
}
return new ResponseEntity<>(HttpStatus.OK);
}
- public void addJob(ConsumerJobInfo job, AsyncRestClient restClient) {
+ public void addJob(ConsumerJobInfo job, String jobId, AsyncRestClient restClient) {
String url = this.testResults.registrationInfo.jobCallbackUrl;
ProducerJobInfo request =
- new ProducerJobInfo(job.jobDefinition, "ID", job.infoTypeId, job.jobResultUri, job.owner, "TIMESTAMP");
+ new ProducerJobInfo(job.jobDefinition, jobId, job.infoTypeId, job.jobResultUri, job.owner, "TIMESTAMP");
String body = gson.toJson(request);
logger.info("ECS Simulator PUT job: {}", body);
restClient.post(url, body).block();
+ }
+
+ public void deleteJob(String jobId, AsyncRestClient restClient) {
+ String url = this.testResults.registrationInfo.jobCallbackUrl + "/" + jobId;
+ logger.info("ECS Simulator DELETE job: {}", url);
+ restClient.delete(url).block();
}
}