diff --git a/api/synapse-api-rest-imperative/src/main/java/io/americanexpress/synapse/api/rest/imperative/controller/BaseUpdateImperativeRestController.java b/api/synapse-api-rest-imperative/src/main/java/io/americanexpress/synapse/api/rest/imperative/controller/BaseUpdateImperativeRestController.java index eac8372cc..33cc1045a 100644 --- a/api/synapse-api-rest-imperative/src/main/java/io/americanexpress/synapse/api/rest/imperative/controller/BaseUpdateImperativeRestController.java +++ b/api/synapse-api-rest-imperative/src/main/java/io/americanexpress/synapse/api/rest/imperative/controller/BaseUpdateImperativeRestController.java @@ -1,12 +1,14 @@ package io.americanexpress.synapse.api.rest.imperative.controller; -import io.americanexpress.synapse.api.rest.imperative.controller.helpers.CreateResponseEntityCreator; +import io.americanexpress.synapse.api.rest.imperative.controller.helpers.MonoResponseEntityCreator; import io.americanexpress.synapse.service.imperative.model.BaseServiceRequest; import io.americanexpress.synapse.service.imperative.model.BaseServiceResponse; import io.americanexpress.synapse.service.imperative.service.BaseService; +import jakarta.validation.Valid; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; /** @@ -30,10 +32,10 @@ public class BaseUpdateImperativeRestController< * @return response to the consumer */ @PutMapping - public ResponseEntity update(@RequestHeader HttpHeaders headers, I serviceRequest) { + public ResponseEntity update(@RequestHeader HttpHeaders headers, @RequestBody @Valid I serviceRequest) { logger.entry(serviceRequest); O serviceResponse = service.execute(serviceRequest); - ResponseEntity responseEntity = CreateResponseEntityCreator.create(serviceResponse); + ResponseEntity responseEntity = MonoResponseEntityCreator.create(serviceResponse); logger.exit(); return responseEntity; } diff --git a/api/synapse-api-rest-imperative/src/main/java/io/americanexpress/synapse/api/rest/imperative/controller/healthcheck/HealthCheckController.java b/api/synapse-api-rest-imperative/src/main/java/io/americanexpress/synapse/api/rest/imperative/controller/healthcheck/HealthCheckController.java index 641c6a271..da3fe1fa2 100644 --- a/api/synapse-api-rest-imperative/src/main/java/io/americanexpress/synapse/api/rest/imperative/controller/healthcheck/HealthCheckController.java +++ b/api/synapse-api-rest-imperative/src/main/java/io/americanexpress/synapse/api/rest/imperative/controller/healthcheck/HealthCheckController.java @@ -31,7 +31,7 @@ public class HealthCheckController { /** * The health global Geographically Distributed High Availability (gdha) check endpoint. */ - public static final String HEALTH_CHECK__GDHA_ENDPOINT = "/health-gdha"; + public static final String HEALTH_CHECK_GDHA_ENDPOINT = "/health-gdha"; /** * Health message used for the health check URIs. @@ -52,7 +52,7 @@ public String healthCheck() { * * @return a constant message to notify that the service is receiving a request */ - @GetMapping(HEALTH_CHECK__GDHA_ENDPOINT) + @GetMapping(HEALTH_CHECK_GDHA_ENDPOINT) public String healthGdhaCheck() { return HEALTH_MESSAGE; } diff --git a/service/synapse-service-imperative/src/main/java/io/americanexpress/synapse/service/imperative/model/NullServiceResponse.java b/service/synapse-service-imperative/src/main/java/io/americanexpress/synapse/service/imperative/model/NullServiceResponse.java new file mode 100644 index 000000000..1e5d92cc7 --- /dev/null +++ b/service/synapse-service-imperative/src/main/java/io/americanexpress/synapse/service/imperative/model/NullServiceResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright 2020 American Express Travel Related Services Company, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package io.americanexpress.synapse.service.imperative.model; + +/** + * {@code NullServiceResponse} is used whenever a null response is required from a service. The service can just return + * NullServiceResponse.INSTANCE rather than just returning null directly as this class also extends {@code BaseServiceResponse} + * adhering to the prototype contracts. + */ +public class NullServiceResponse implements BaseServiceResponse { + + /** + * Returns a null instance as a singleton pattern for when a null response is required from the service. + */ + public static final NullServiceResponse INSTANCE = null; + + /** + * Private constructor to prevent multiple instances being made. + */ + private NullServiceResponse() { + + } +}