"produces": ["application/json"],
"operationId": "putEiTypeUsingPUT",
"responses": {
- "200": {
- "schema": {"type": "object"},
- "description": "OK"
- },
+ "200": {"description": "OK"},
"201": {"description": "Created"},
+ "400": {
+ "schema": {"$ref": "#/definitions/ProblemDetails"},
+ "description": "Bad request"
+ },
"401": {"description": "Unauthorized"},
"403": {"description": "Forbidden"},
"404": {"description": "Not Found"}
"description": "Information for an EI type",
"type": "object",
"title": "producer_ei_type_info",
+ "required": ["ei_job_data_schema"],
"properties": {"ei_job_data_schema": {
"description": "Json schema for the job data",
"type": "object"
responses:
200:
description: OK
- content:
- application/json:
- schema:
- type: object
+ content: {}
201:
description: Created
content: {}
+ 400:
+ description: Bad request
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ProblemDetails'
401:
description: Unauthorized
content: {}
type: object
producer_ei_type_info:
title: producer_ei_type_info
+ required:
+ - ei_job_data_schema
type: object
properties:
ei_job_data_schema:
}
@PutMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE)
+ @ApiResponses(
+ value = { //
+ @ApiResponse(code = 200, message = "OK", response = VoidResponse.class), @ApiResponse(
+ code = 400, //
+ message = "Bad request",
+ response = ErrorResponse.ErrorInfo.class)})
@ApiOperation(value = "Individual EI type", notes = "")
public ResponseEntity<Object> putEiType( //
@PathVariable("eiTypeId") String eiTypeId, @RequestBody ProducerEiTypeInfo registrationInfo) {
EiType previousDefinition = this.eiTypes.get(eiTypeId);
+ if (registrationInfo.jobDataSchema == null) {
+ return ErrorResponse.create("No schema provided", HttpStatus.BAD_REQUEST);
+ }
this.eiTypes.put(new EiType(eiTypeId, registrationInfo.jobDataSchema));
return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK);
}
@ApiModel(value = "producer_ei_type_info", description = "Information for an EI type")
public class ProducerEiTypeInfo {
- @ApiModelProperty(value = "Json schema for the job data")
+ @ApiModelProperty(value = "Json schema for the job data", required = true)
@SerializedName("ei_job_data_schema")
- @JsonProperty("ei_job_data_schema")
+ @JsonProperty(value = "ei_job_data_schema", required = true)
public Object jobDataSchema;
public ProducerEiTypeInfo(Object jobDataSchema) {
assertThat(putEiType(EI_TYPE_ID)).isEqualTo(HttpStatus.OK);
}
+ @Test
+ void testPutEiType_noSchema() {
+ String url = ProducerConsts.API_ROOT + "/eitypes/" + EI_TYPE_ID;
+ String body = "{}";
+ testErrorCode(restClient().put(url, body), HttpStatus.BAD_REQUEST, "No schema provided");
+ }
+
@Test
void testGetEiType() throws Exception {
putEiProducerWithOneType(EI_PRODUCER_ID, "test");
assertThat(request.id).isEqualTo("jobId");
}
+ @Test
+ void testPutEiProducer_noType() throws Exception {
+ String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId";
+ String body = gson.toJson(producerEiRegistratioInfo(EI_TYPE_ID));
+ testErrorCode(restClient().put(url, body), HttpStatus.NOT_FOUND, "EI type not found");
+ }
+
@Test
void testPutProducerAndEiJob() throws Exception {
this.putEiType(EI_TYPE_ID);