T235 Removed KlausController class
This commit is contained in:
		| @@ -1,65 +0,0 @@ | ||||
| package com.release11.klaus.controller; | ||||
|  | ||||
|  | ||||
| import com.release11.klaus.model.MockedMessageDto; | ||||
| import com.release11.klaus.service.KlausService; | ||||
| import com.release11.klaus.utilis.BusinessKey; | ||||
| import com.release11.klaus.utilis.TrackingClient; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.http.HttpHeaders; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.RequestEntity; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Objects; | ||||
| import java.util.UUID; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * This controller is responsible for returning the data of given mocked message. The content is made of usual | ||||
|  * http parameters like: body, status, headers etc. | ||||
|  * Basicly the api is responsible for what a client is looking for - a mocked server response. | ||||
|  * Important note: {@link TrackingClient} use is to create logs - the history. | ||||
|  * @author Gabriel Modzelewski | ||||
|  * @author Rafał Żukowicz | ||||
|  */ | ||||
| @RestController | ||||
| @Slf4j | ||||
| @RequestMapping(path = ("/klaus/v1")) | ||||
| @AllArgsConstructor | ||||
| public class KlausController { | ||||
|  | ||||
|     private final KlausService klausService; | ||||
|  | ||||
| //    TODO: Move to MockController | ||||
|     /** | ||||
|      * It's one of the most important features - the bread and butter of the Mocked Service. It's link that allows | ||||
|      * to receive mocked response from the server and use it to mock! | ||||
|      * @param requestEntity Logs the data of request | ||||
|      * @param clientUUID the key-uuid of given set of messages | ||||
|      * @param mockedResponseId unique id of given message | ||||
|      * @return | ||||
|      */ | ||||
|     @RequestMapping(value = "/get/{clientUUID}/{mockedResponseId}") | ||||
|     public ResponseEntity getMockedResponse(RequestEntity<String> requestEntity, | ||||
|                                             @PathVariable UUID clientUUID, | ||||
|                                             @PathVariable int mockedResponseId) { | ||||
|         TrackingClient.setBusinessKeys(Map.of(BusinessKey.INTERFACE_NAME, "getMockedResponse - request", | ||||
|                 BusinessKey.CLIENT_UUID, String.valueOf(clientUUID), | ||||
|                 BusinessKey.MESSAGE_ID, String.valueOf(mockedResponseId))); | ||||
|         log.info(requestEntity.toString().replaceAll("\"", "\\\\\"").substring(1)); | ||||
|         TrackingClient.setBusinessKeys(Map.of(BusinessKey.INTERFACE_NAME, "getMockedResponse - response", | ||||
|                 BusinessKey.CLIENT_UUID, String.valueOf(clientUUID), | ||||
|                 BusinessKey.MESSAGE_ID, String.valueOf(mockedResponseId))); | ||||
|         MockedMessageDto mockedMessageDto = klausService.getMockedResponse(clientUUID, mockedResponseId); | ||||
|         HttpHeaders httpHeaders = new HttpHeaders(); | ||||
|         if (mockedMessageDto.getHttpHeaders() != null) mockedMessageDto.getHttpHeaders().forEach(httpHeaders::set); | ||||
|         return new ResponseEntity<>(mockedMessageDto.getMessageBody(), httpHeaders, | ||||
|                 Objects.requireNonNull(HttpStatus.valueOf(mockedMessageDto.getHttpStatus()))); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -3,11 +3,12 @@ package com.release11.klaus.controller; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import com.release11.klaus.model.MockedMessageDto; | ||||
| import com.release11.klaus.service.KlausService; | ||||
| import com.release11.klaus.utilis.BusinessKey; | ||||
| import com.release11.klaus.utilis.TrackingClient; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.SneakyThrows; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.http.MediaType; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.stereotype.Controller; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.servlet.ModelAndView; | ||||
| @@ -154,5 +155,31 @@ public class MockController { | ||||
|         return ++highestId; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * It's one of the most important features - the bread and butter of the Mocked Service. It's link that allows | ||||
|      * to receive mocked response from the server and use it to mock! | ||||
|      * @param requestEntity Logs the data of request | ||||
|      * @param clientUUID the key-uuid of given set of messages | ||||
|      * @param mockedResponseId unique id of given message | ||||
|      * @return | ||||
|      */ | ||||
|     @GetMapping(value = "/klaus/v1/get/{clientUUID}/{mockedResponseId}") | ||||
|     public ResponseEntity getMockedResponse(RequestEntity<String> requestEntity, | ||||
|                                             @PathVariable UUID clientUUID, | ||||
|                                             @PathVariable int mockedResponseId) { | ||||
|         TrackingClient.setBusinessKeys(Map.of(BusinessKey.INTERFACE_NAME, "getMockedResponse - request", | ||||
|                 BusinessKey.CLIENT_UUID, String.valueOf(clientUUID), | ||||
|                 BusinessKey.MESSAGE_ID, String.valueOf(mockedResponseId))); | ||||
|         log.info(requestEntity.toString().replaceAll("\"", "\\\\\"").substring(1)); | ||||
|         TrackingClient.setBusinessKeys(Map.of(BusinessKey.INTERFACE_NAME, "getMockedResponse - response", | ||||
|                 BusinessKey.CLIENT_UUID, String.valueOf(clientUUID), | ||||
|                 BusinessKey.MESSAGE_ID, String.valueOf(mockedResponseId))); | ||||
|         MockedMessageDto mockedMessageDto = klausService.getMockedResponse(clientUUID, mockedResponseId); | ||||
|         HttpHeaders httpHeaders = new HttpHeaders(); | ||||
|         if (mockedMessageDto.getHttpHeaders() != null) mockedMessageDto.getHttpHeaders().forEach(httpHeaders::set); | ||||
|         return new ResponseEntity<>(mockedMessageDto.getMessageBody(), httpHeaders, | ||||
|                 Objects.requireNonNull(HttpStatus.valueOf(mockedMessageDto.getHttpStatus()))); | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user