@Test public void getSchemas() throws Exception { Map<Integer, Schema> schemas = Collections.singletonMap(1, schema); when(paverService.getActiveSchemas(ROAD_NAME)).thenReturn(schemas); mockMvc .perform(get(CONTEXT_PATH + "/roads/road1/schemas")) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8)) .andExpect(content().string(objectMapper.writeValueAsString(schemas))); }
@ApiOperation(value = "Returns all schemas keyed by version number") @ApiResponses({ @ApiResponse(code = 200, message = "List of schemas returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class) }) @GetMapping public Map<Integer, Schema> getSchemas(@PathVariable String name) throws UnknownRoadException { return service.getActiveSchemas(name); }
SchemaController { @ApiOperation(value = "Returns all schemas keyed by version number") @ApiResponses({ @ApiResponse(code = 200, message = "List of schemas returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class) }) @GetMapping public Map<Integer, Schema> getSchemas(@PathVariable String name) throws UnknownRoadException { return service.getActiveSchemas(name); } }
SchemaController { @ApiOperation(value = "Returns all schemas keyed by version number") @ApiResponses({ @ApiResponse(code = 200, message = "List of schemas returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class) }) @GetMapping public Map<Integer, Schema> getSchemas(@PathVariable String name) throws UnknownRoadException { return service.getActiveSchemas(name); }  }
SchemaController { @ApiOperation(value = "Returns all schemas keyed by version number") @ApiResponses({ @ApiResponse(code = 200, message = "List of schemas returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class) }) @GetMapping public Map<Integer, Schema> getSchemas(@PathVariable String name) throws UnknownRoadException { return service.getActiveSchemas(name); }  @ApiOperation(value = "Returns all schemas keyed by version number") @ApiResponses({ @ApiResponse(code = 200, message = "List of schemas returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class) }) @GetMapping Map<Integer, Schema> getSchemas(@PathVariable String name); @ApiOperation(value = "Adds a new schema to a road") @ApiResponses({ @ApiResponse(code = 200, message = "Request to add a new schema received.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class), @ApiResponse(code = 409, message = "Schema is not compatible with previous schemas.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @PostMapping StandardResponse addNewSchema(
      @ApiParam(name = "name", value = "road name", required = true) @PathVariable String name,
      @RequestBody Schema schema); @ApiOperation(value = "Adds a new schema with a specific version to a road") @ApiResponses({ @ApiResponse(code = 200, message = "Request to add a new schema received.", response = StandardResponse.class), @ApiResponse(code = 400, message = "Invalid Schema Version. The requested version must be greater than the largest registered version.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class), @ApiResponse(code = 409, message = "Schema is not compatible with previous schemas.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @PostMapping("/{version}") StandardResponse addNewSchema(
      @ApiParam(name = "name", value = "road name", required = true) @PathVariable String name,
      @PathVariable int version,
      @RequestBody Schema schema); @ApiOperation(value = "Returns a specific version of a schema") @ApiResponses({ @ApiResponse(code = 200, message = "Requested schema returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or schema not found.", response = StandardResponse.class) }) @GetMapping("/{version}") Schema getSchema(
      @ApiParam(name = "name", value = "road name", required = true) @PathVariable String name,
      @PathVariable String version); @ApiOperation(value = "Deletes the latest version of a schema") @ApiResponses({ @ApiResponse(code = 200, message = "Request to delete a schema received.", response = StandardResponse.class), @ApiResponse(code = 400, message = "Invalid Schema Version. Only the latest schema can be deleted.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Schema not found.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @DeleteMapping("/{version}") ResponseEntity<StandardResponse> deleteLatestSchema(
      @ApiParam(name = "name", value = "road name", required = true) @PathVariable String name,
      @PathVariable String version); @ExceptionHandler(AvroTypeException.class) ResponseEntity<StandardResponse> avroTypeExceptionExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(SchemaParseException.class) ResponseEntity<StandardResponse> schemaParseException(HttpServletRequest request, Exception e); @ExceptionHandler(NumberFormatException.class) ResponseEntity<StandardResponse> numberFormatExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(InvalidSchemaException.class) ResponseEntity<StandardResponse> invalidSchemaExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(InvalidSchemaVersionException.class) ResponseEntity<StandardResponse> invalidSchemaVersionException(HttpServletRequest request, Exception e); @ExceptionHandler(InvalidPiiAnnotationException.class) ResponseEntity<StandardResponse> invalidPiiAnnotationException(HttpServletRequest request, Exception e); }
SchemaController { @ApiOperation(value = "Returns all schemas keyed by version number") @ApiResponses({ @ApiResponse(code = 200, message = "List of schemas returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class) }) @GetMapping public Map<Integer, Schema> getSchemas(@PathVariable String name) throws UnknownRoadException { return service.getActiveSchemas(name); }  @ApiOperation(value = "Returns all schemas keyed by version number") @ApiResponses({ @ApiResponse(code = 200, message = "List of schemas returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class) }) @GetMapping Map<Integer, Schema> getSchemas(@PathVariable String name); @ApiOperation(value = "Adds a new schema to a road") @ApiResponses({ @ApiResponse(code = 200, message = "Request to add a new schema received.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class), @ApiResponse(code = 409, message = "Schema is not compatible with previous schemas.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @PostMapping StandardResponse addNewSchema(
      @ApiParam(name = "name", value = "road name", required = true) @PathVariable String name,
      @RequestBody Schema schema); @ApiOperation(value = "Adds a new schema with a specific version to a road") @ApiResponses({ @ApiResponse(code = 200, message = "Request to add a new schema received.", response = StandardResponse.class), @ApiResponse(code = 400, message = "Invalid Schema Version. The requested version must be greater than the largest registered version.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class), @ApiResponse(code = 409, message = "Schema is not compatible with previous schemas.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @PostMapping("/{version}") StandardResponse addNewSchema(
      @ApiParam(name = "name", value = "road name", required = true) @PathVariable String name,
      @PathVariable int version,
      @RequestBody Schema schema); @ApiOperation(value = "Returns a specific version of a schema") @ApiResponses({ @ApiResponse(code = 200, message = "Requested schema returned successfully.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or schema not found.", response = StandardResponse.class) }) @GetMapping("/{version}") Schema getSchema(
      @ApiParam(name = "name", value = "road name", required = true) @PathVariable String name,
      @PathVariable String version); @ApiOperation(value = "Deletes the latest version of a schema") @ApiResponses({ @ApiResponse(code = 200, message = "Request to delete a schema received.", response = StandardResponse.class), @ApiResponse(code = 400, message = "Invalid Schema Version. Only the latest schema can be deleted.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Schema not found.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @DeleteMapping("/{version}") ResponseEntity<StandardResponse> deleteLatestSchema(
      @ApiParam(name = "name", value = "road name", required = true) @PathVariable String name,
      @PathVariable String version); @ExceptionHandler(AvroTypeException.class) ResponseEntity<StandardResponse> avroTypeExceptionExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(SchemaParseException.class) ResponseEntity<StandardResponse> schemaParseException(HttpServletRequest request, Exception e); @ExceptionHandler(NumberFormatException.class) ResponseEntity<StandardResponse> numberFormatExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(InvalidSchemaException.class) ResponseEntity<StandardResponse> invalidSchemaExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(InvalidSchemaVersionException.class) ResponseEntity<StandardResponse> invalidSchemaVersionException(HttpServletRequest request, Exception e); @ExceptionHandler(InvalidPiiAnnotationException.class) ResponseEntity<StandardResponse> invalidPiiAnnotationException(HttpServletRequest request, Exception e);  }