### Question:
ModelDistributionRequest { @PATCH @Path("/{version:[vV][1]}/distributions/{distributionId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Update model distribution status", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) @Transactional public Response updateModelDistributionStatus(String requestJSON, @PathParam("version") String version, @PathParam("distributionId") String distributionId) throws ApiException { Distribution distributionRequest; try { ObjectMapper mapper = new ObjectMapper(); distributionRequest = mapper.readValue(requestJSON, Distribution.class); } catch (IOException e) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) .build(); ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); throw validateException; } try { parse(distributionRequest); } catch (ValidationException e) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) .build(); ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); throw validateException; } CloudOrchestrationRequest cor = new CloudOrchestrationRequest(); cor.setDistribution(distributionRequest); cor.setDistributionId(distributionId); TenantIsolationRunnable runnable = tenantIsolationRunnable.get(); runnable.run(Action.distributionStatus, null, cor, null); return Response.ok().build(); }  @PATCH @Path("/{version:[vV][1]}/distributions/{distributionId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Update model distribution status", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) @Transactional Response updateModelDistributionStatus(String requestJSON, @PathParam("version") String version,
            @PathParam("distributionId") String distributionId);  }### Answer:
@Test public void testObjectMapperError() throws ApiException { thrown.expect(ValidateException.class); thrown.expectMessage(startsWith("Mapping of request to JSON object failed")); thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST))); thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); request.updateModelDistributionStatus("", null, null); }
@Test public void testParseError1() throws ApiException { thrown.expect(ValidateException.class); thrown.expectMessage(startsWith("No valid status is specified")); thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST))); thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); String requestErrorJSON = "{\"errorReason\": \"Distribution failed in AAI\" }"; request.updateModelDistributionStatus(requestErrorJSON, null, null); }
@Test public void testParseError2() throws ApiException { thrown.expect(ValidateException.class); thrown.expectMessage(startsWith("No valid errorReason is specified")); thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST))); thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); String requestErrorJSON = "{\"status\": \"DISTRIBUTION_COMPLETE_ERROR\"}"; request.updateModelDistributionStatus(requestErrorJSON, null, null); }
@Test public void testSuccess() throws ApiException { doNothing().when(runnable).run(any(Action.class), anyString(), any(CloudOrchestrationRequest.class), anyString()); Response response = request.updateModelDistributionStatus(requestJSON, null, null); assertEquals(200, response.getStatus()); }