- private EiJob addEiJob(String typeId, String jobId) {
- EiType type = addEiType(typeId);
- EiJob job = ImmutableEiJob.builder() //
- .id(jobId) //
- .type(type) //
- .owner("owner") //
- .jobData(jsonObject()) //
- .build();
- this.eiJobs.put(job);
- return job;
- }
-
- private EiType addEiType(String typeId) {
- EiType eiType = new EiType(typeId, jsonObject());
- this.eiTypes.put(eiType); //
- EiProducer producer = ImmutableEiProducer.builder() //
- .id("producerId") //
- .eiTypes(Arrays.asList(eiType)) //
- .jobCreationCallbackUrl(baseUrl() + ProducerSimulatorController.JOB_CREATED_URL) //
- .jobDeletionCallbackUrl(baseUrl() + ProducerSimulatorController.JOB_DELETED_URL) //
- .build();
- this.eiProducers.put(producer);
- eiType.addProducer(producer);
- return eiType;
+ ConsumerEiJobInfo eiJobInfo(String typeId) throws JsonMappingException, JsonProcessingException {
+ return new ConsumerEiJobInfo(typeId, jsonObject(), "owner", "targetUri");
+ }
+
+ Object jsonObject(String json) {
+ try {
+ return JsonParser.parseString(json).getAsJsonObject();
+ } catch (Exception e) {
+ throw new NullPointerException(e.toString());
+ }
+ }
+
+ Object jsonSchemaObject() {
+ // a json schema with one mandatory property named "string"
+ String schemaStr = "{" //
+ + "\"$schema\": \"http://json-schema.org/draft-04/schema#\"," //
+ + "\"type\": \"object\"," //
+ + "\"properties\": {" //
+ + EI_JOB_PROPERTY + " : {" //
+ + " \"type\": \"string\"" //
+ + " }" //
+ + "}," //
+ + "\"required\": [" //
+ + EI_JOB_PROPERTY //
+ + "]" //
+ + "}"; //
+ return jsonObject(schemaStr);
+ }
+
+ Object jsonObject() {
+ return jsonObject("{ " + EI_JOB_PROPERTY + " : \"value\" }");
+ }
+
+ private EiJob putEiJob(String eiTypeId, String jobId)
+ throws JsonMappingException, JsonProcessingException, ServiceException {
+
+ String url = ConsumerConsts.API_ROOT + "/eijobs/" + jobId;
+ String body = gson.toJson(eiJobInfo(eiTypeId));
+ restClient().putForEntity(url, body).block();
+
+ return this.eiJobs.getJob(jobId);
+ }
+
+ private EiType putEiProducerWithOneTypeRejecting(String producerId, String eiTypeId)
+ throws JsonMappingException, JsonProcessingException, ServiceException {
+ String url = ProducerConsts.API_ROOT + "/eiproducers/" + producerId;
+ String body = gson.toJson(producerEiRegistratioInfoRejecting(eiTypeId));
+
+ restClient().putForEntity(url, body).block();
+ return this.eiTypes.getType(eiTypeId);
+ }
+
+ private EiType putEiProducerWithOneType(String producerId, String eiTypeId)
+ throws JsonMappingException, JsonProcessingException, ServiceException {
+ String url = ProducerConsts.API_ROOT + "/eiproducers/" + producerId;
+ String body = gson.toJson(producerEiRegistratioInfo(eiTypeId));
+
+ restClient().putForEntity(url, body).block();
+ return this.eiTypes.getType(eiTypeId);