Started to removing changing UUID and many messages system
This commit is contained in:
		| @@ -51,106 +51,35 @@ public class MockController { | ||||
|      * Returns the full list of messages. It's used by javascript on the client side to initialize homepage | ||||
|      * with data from the database. | ||||
|      * @param uuidValue the key-uuid of given set of messages | ||||
|      * @return responds with 200 OK and list of {@link MockedMessageDto} | ||||
|      * @return responds with 200 OK and {@link MockedMessageDto} | ||||
|      */ | ||||
|     @GetMapping({"/", "/{uuidValue}"}) | ||||
|     public List<MockedMessageDto> getListOfMessages(@PathVariable(required = false) String uuidValue){ | ||||
|     public MockedMessageDto getMessage(@PathVariable(required = false) String uuidValue){ | ||||
|         UUID clientUUID; | ||||
|         MockedMessageDto message ; | ||||
|         if(uuidValue == null || uuidValue.equals("")) clientUUID = UUID.randomUUID(); | ||||
|         else clientUUID = UUID.fromString(uuidValue); | ||||
|         List<MockedMessageDto> messages = klausService.getAllMockedResponses(clientUUID); | ||||
|         if(messages.size() == 0) { | ||||
|             klausService.setMockedResponse(buildDefaultMessage(clientUUID)); | ||||
|             messages = klausService.getAllMockedResponses(clientUUID); | ||||
|         } | ||||
|         Collections.sort(messages); | ||||
|         return messages; | ||||
|     } | ||||
|         message = klausService | ||||
|                 .getMockedMessageByClientUUID(clientUUID) | ||||
|                 .orElse( buildDefaultMessage(clientUUID) ); | ||||
|  | ||||
|     /** | ||||
|     * If provided UUID does not exist in database returns ResponseEntity with new generated UUID(if previous UUID is not provided), | ||||
|     * or old UUID(if previous UUID is provided). If provided UUID exists function returns provided UUID. | ||||
|     * @param givenUUIDValue the UUID client wants to check exsitance in database | ||||
|     * @param previousUUIDValue the previous UUID used by client(optional variable) | ||||
|     * @return ResponseEntity with UUID | ||||
|      */ | ||||
|     @RequestMapping( | ||||
|             method = RequestMethod.GET , | ||||
|             path = {"/check/{givenUUIDValue}/{previousUUIDValue}", | ||||
|                     "/check/{givenUUIDValue}"}) | ||||
|     public ResponseEntity<String> checkUUID( | ||||
|             @PathVariable String givenUUIDValue | ||||
|             ,@PathVariable(required = false) String previousUUIDValue  ){ | ||||
|         try{ | ||||
|             UUID.fromString(givenUUIDValue); | ||||
|         } catch (IllegalArgumentException ex){ | ||||
|             log.error("Wrong UUID value!"); | ||||
|             if (previousUUIDValue == null || previousUUIDValue.equals("")){ | ||||
|                 UUID newUUID = UUID.randomUUID(); | ||||
|                 log.info("New UUID generated."); | ||||
|                 return ResponseEntity.ok(newUUID.toString()); | ||||
|             } | ||||
|             log.info("Previous UUID value restored."); | ||||
|             return ResponseEntity.ok(previousUUIDValue); | ||||
|         } | ||||
|         return ResponseEntity.ok(givenUUIDValue); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Accepts empty post request and creates new message in given set. The new message has default set of data, | ||||
|      * which is constructed in {@link #buildDefaultMessage(UUID, int)} method. | ||||
|      * @param uuidValue the key-uuid of given set of messages | ||||
|      * @return confirmation response with 200 OK | ||||
|      */ | ||||
|     @PostMapping("/{uuidValue}") | ||||
|     public ResponseEntity<String> addNewMessage(@PathVariable String uuidValue){ | ||||
|         UUID clientUUID = UUID.fromString(uuidValue); | ||||
|         List<MockedMessageDto> messages = klausService.getAllMockedResponses(clientUUID); | ||||
|         MockedMessageDto nextMessage = buildDefaultMessage(clientUUID, findNextId(messages)); | ||||
|         return klausService.setMockedResponse(nextMessage); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Deletes message of given id via client request | ||||
|      * @param uuidValue the key-uuid of given set of messages | ||||
|      * @param idValue unique id of given message | ||||
|      * @return after deletion the confirmation is send with status 200 OK | ||||
|      */ | ||||
|     @DeleteMapping("/{uuidValue}/{idValue}") | ||||
|     public ResponseEntity<String> removeMessage(@PathVariable String uuidValue, | ||||
|                                                 @PathVariable String idValue){ | ||||
|         UUID clientUUID = UUID.fromString(uuidValue); | ||||
|         int id = Integer.parseInt(idValue); | ||||
|         return klausService.deleteMockedResponse(clientUUID, id); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * Recalls {@link #buildDefaultMessage(UUID)} for message construction and sets id of message | ||||
|      * @param uuid the key-uuid of given set of messages | ||||
|      * @param id unique id of given message | ||||
|      * @return message with default dataset and set id | ||||
|      */ | ||||
|     private static MockedMessageDto buildDefaultMessage(UUID uuid, int id){ | ||||
|         MockedMessageDto message = buildDefaultMessage(uuid); | ||||
|         message.setMockedResponseId(id); | ||||
|         return message; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * Constructs message with default set of data | ||||
|      * @param uuid the key-uuid of given set of messages | ||||
|      * @return message with default dataset | ||||
|      */ | ||||
|     private static MockedMessageDto buildDefaultMessage(UUID uuid){ | ||||
|     private MockedMessageDto buildDefaultMessage(UUID uuid){ | ||||
|         Map<String, String> headers = new HashMap<>(); | ||||
|         headers.put("Keep-Alive", "timeout=60"); | ||||
|         headers.put("Connection", "keep-alive"); | ||||
|         headers.put("Date", LocalDateTime.now().toString()); | ||||
|         return MockedMessageDto.builder() | ||||
|         MockedMessageDto mockedMessageDto = MockedMessageDto.builder() | ||||
|                 .clientUUID(uuid) | ||||
|                 .mockedResponseId(1) | ||||
|                 .mediaType(MediaType.APPLICATION_XML_VALUE) | ||||
|                 .contentType(MediaType.APPLICATION_XML_VALUE) | ||||
|                 .messageBody("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + | ||||
|                         "<note>\n" + | ||||
|                         "  <to>Tove</to>\n" + | ||||
| @@ -161,38 +90,24 @@ public class MockController { | ||||
|                 .httpHeaders(headers) | ||||
|                 .httpStatus(200) | ||||
|                 .build(); | ||||
|         klausService.setMockedResponse(mockedMessageDto); | ||||
|         return mockedMessageDto; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Finds the highest id in the list and returns it incremented by 1 | ||||
|      * @param messages list of messages | ||||
|      * @return highest id incremented by 1 | ||||
|      */ | ||||
|     public static int findNextId(List<MockedMessageDto> messages) { | ||||
|         int highestId = 0; | ||||
|         for (MockedMessageDto m : messages) | ||||
|             highestId = highestId > m.getMockedResponseId() ? highestId : m.getMockedResponseId(); | ||||
|         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 clientUUID the key-uuid of given set of messages | ||||
|      * @param mockedResponseId unique id of given message | ||||
|      * @return | ||||
|      */ | ||||
|     @RequestMapping(value = "/r/{clientUUID}/{mockedResponseId}") | ||||
|     @RequestMapping(value = "/r/{clientUUID}") | ||||
|     public ResponseEntity getMockedResponse( | ||||
|                                             @PathVariable UUID clientUUID, | ||||
|                                             @PathVariable int mockedResponseId) { | ||||
|         MockedMessageDto mockedMessageDto = klausService.getMockedResponse(clientUUID, mockedResponseId); | ||||
|                                             @PathVariable UUID clientUUID) { | ||||
|         MockedMessageDto mockedMessageDto = klausService.getMockedResponse(clientUUID); | ||||
|         HttpHeaders httpHeaders = new HttpHeaders(); | ||||
|         if (mockedMessageDto.getHttpHeaders() != null) mockedMessageDto.getHttpHeaders().forEach(httpHeaders::set); | ||||
|         httpHeaders.add("Content-Type", mockedMessageDto.getMediaType()); | ||||
|         httpHeaders.add("Content-Type", mockedMessageDto.getContentType()); | ||||
|         return new ResponseEntity<>(mockedMessageDto.getMessageBody(), httpHeaders, | ||||
|                 Objects.requireNonNull(HttpStatus.valueOf(mockedMessageDto.getHttpStatus()))); | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -47,12 +47,10 @@ public class RequestHistoryController { | ||||
|     /** | ||||
|      * Returns the list of Events of last 24h from given date. | ||||
|      * @param uuid unique id of message list | ||||
|      * @param messageId unique id of message in message list | ||||
|      * @return list of {@link RequestHistory} | ||||
|      */ | ||||
|     @GetMapping(path = "/{uuid}/{messageId}") | ||||
|     public ResponseEntity<List<RequestHistoryDTO>> getLastDay(@PathVariable UUID uuid, | ||||
|                                                         @PathVariable Integer messageId){ | ||||
|     public ResponseEntity<List<RequestHistoryDTO>> getLastDay(@PathVariable UUID uuid){ | ||||
|         LocalDateTime requestTime = LocalDateTime.now(); | ||||
|         LocalDateTime dayBeforeRequest = requestTime.minusDays(1L); | ||||
|         List<RequestHistoryDTO> requestHistory = service.getHistoryRecordsBetweenDatesAndByUUIDAndMessageId( | ||||
| @@ -60,7 +58,6 @@ public class RequestHistoryController { | ||||
|                         .localDateTimeFrom(dayBeforeRequest) | ||||
|                         .localDateTimeTo(requestTime) | ||||
|                         .clientUUID(uuid) | ||||
|                         .mockedResponseId(messageId) | ||||
|                         .build() | ||||
|         ).stream() | ||||
|                 .map(mapper::requestHistoryToRequestHistoryDTO) | ||||
|   | ||||
| @@ -39,7 +39,6 @@ public class IncomingMockRequestInterceptor implements HandlerInterceptor { | ||||
|         RequestHistoryDTO historyDTO = RequestHistoryDTO.builder() | ||||
|                 .httpMethod(HttpMethod.valueOf(httpRequest.getMethod())) | ||||
|                 .headers( headers ) | ||||
|                 .messageID(Integer.valueOf(pathVariable.get("mockedResponseId"))) | ||||
|                 .clientUUID(UUID.fromString(pathVariable.get("clientUUID"))) | ||||
|                 .dateTimeStamp(LocalDateTime.now()) | ||||
|                 .requestBody(requestBody) | ||||
|   | ||||
| @@ -4,15 +4,23 @@ import com.r11.tools.model.MockedMessage; | ||||
| import com.r11.tools.model.MockedMessageDto; | ||||
| import org.mapstruct.*; | ||||
|  | ||||
| import java.util.Optional; | ||||
|  | ||||
| /** | ||||
|  * Creates key value for redis entry | ||||
|  * @author Rafał Źukowicz | ||||
|  */ | ||||
| @Mapper | ||||
| public interface MockedMessageMapper { | ||||
|     @Mapping( target = "compositePrimaryKey", expression = "java(mockedMessageDto.getClientUUID() + \"_\"" + | ||||
|             " + mockedMessageDto.getMockedResponseId())") | ||||
|     @Mapping( target = "createdAt" , expression = "java(java.time.LocalDateTime.now())") | ||||
|     MockedMessage mockedMessageDtoToMockedMessage(MockedMessageDto mockedMessageDto); | ||||
|     MockedMessageDto mockedMessageToMockedMessageDto(MockedMessage mockedMessage); | ||||
|  | ||||
|     default Optional<MockedMessageDto> optionalMockedMessageToOptionalMockedMessageDTO(Optional<MockedMessage> optionalMockedMessage){ | ||||
|         return optionalMockedMessage.map(this::mockedMessageToMockedMessageDto); | ||||
|     } | ||||
|  | ||||
|     default Optional<MockedMessage> optionalMockedMessageDTOToOptionalMockedMessage(Optional<MockedMessageDto> optionalMockedMessageDto){ | ||||
|         return optionalMockedMessageDto.map(this::mockedMessageDtoToMockedMessage); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -15,7 +15,6 @@ import org.mapstruct.Mapping; | ||||
| @Mapper | ||||
| public interface RequestHistoryMapper { | ||||
|  | ||||
|     @Mapping(target = "id", expression = "java(null)") | ||||
|     @Mapping(target = "clientUUID", expression = "java(requestHistoryDTO.getClientUUID().toString())") | ||||
|     RequestHistory requestHistoryDTOToRequestHistory(RequestHistoryDTO requestHistoryDTO); | ||||
|     @Mapping(target = "clientUUID", expression = "java(java.util.UUID.fromString(requestHistory.getClientUUID()))") | ||||
|   | ||||
| @@ -25,6 +25,5 @@ public class HistoryRequestModel { | ||||
|     private LocalDateTime localDateTimeFrom; | ||||
|     @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) | ||||
|     private LocalDateTime localDateTimeTo; | ||||
|     private Integer mockedResponseId; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,11 +1,6 @@ | ||||
| package com.r11.tools.model; | ||||
|  | ||||
| import com.r11.tools.model.constraints.HttpCode; | ||||
| import java.io.Serializable; | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.Map; | ||||
| import java.util.UUID; | ||||
| import javax.validation.constraints.Positive; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
| @@ -14,6 +9,11 @@ import org.springframework.data.annotation.Id; | ||||
| import org.springframework.data.redis.core.RedisHash; | ||||
| import org.springframework.data.redis.core.index.Indexed; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.Map; | ||||
| import java.util.UUID; | ||||
|  | ||||
| /** | ||||
|  * MockedMessage redis entity pojo | ||||
|  * @author Rafał Żukowicz | ||||
| @@ -24,13 +24,10 @@ import org.springframework.data.redis.core.index.Indexed; | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class MockedMessage implements Serializable { | ||||
|     @Id | ||||
|     private String compositePrimaryKey; | ||||
|     @Indexed | ||||
|     @Id | ||||
|     private UUID clientUUID; | ||||
|     @Positive | ||||
|     private Integer mockedResponseId; | ||||
|     private String mediaType; | ||||
|     private String contentType; | ||||
|     private String messageBody; | ||||
|     private Map<String, String> httpHeaders; | ||||
|     @HttpCode | ||||
| @@ -38,5 +35,3 @@ public class MockedMessage implements Serializable { | ||||
|     private LocalDateTime createdAt; | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,12 +1,11 @@ | ||||
| package com.r11.tools.model; | ||||
|  | ||||
| import com.r11.tools.model.constraints.HttpCode; | ||||
| import lombok.*; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.Map; | ||||
| import java.util.UUID; | ||||
| import javax.validation.constraints.NotNull; | ||||
| import javax.validation.constraints.Positive; | ||||
| import lombok.*; | ||||
|  | ||||
| /** | ||||
|  * Alternative version of {@link MockedMessage} used in http body | ||||
| @@ -18,19 +17,12 @@ import lombok.*; | ||||
| @ToString | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class MockedMessageDto implements Serializable, Comparable<MockedMessageDto> { | ||||
| public class MockedMessageDto implements Serializable{ | ||||
|     private UUID clientUUID; | ||||
|     @NotNull | ||||
|     @Positive | ||||
|     private Integer mockedResponseId; | ||||
|     private String mediaType; | ||||
|     private String contentType; | ||||
|     private String messageBody; | ||||
|     private Map<String, String> httpHeaders; | ||||
|     @HttpCode | ||||
|     private Integer httpStatus; | ||||
|  | ||||
|     @Override | ||||
|     public int compareTo(MockedMessageDto message) { | ||||
|         return this.mockedResponseId > message.getMockedResponseId() ? 1 : -1; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -26,14 +26,11 @@ import java.util.Map; | ||||
| @RedisHash("mockHistory") | ||||
| public class RequestHistory implements Comparable<RequestHistory>, Serializable { | ||||
|  | ||||
|     @Id | ||||
|     private String id; | ||||
|     @DateTimeFormat(pattern = "yyyy-MM-ddTHH:mm:ss") | ||||
|     private LocalDateTime dateTimeStamp; | ||||
|     @Indexed | ||||
|     @Id | ||||
|     private String clientUUID; | ||||
|     @Indexed | ||||
|     private Integer messageID; | ||||
|     private Map<String,String> headers; | ||||
|     private HttpMethod httpMethod; | ||||
|     private String requestBody; | ||||
|   | ||||
| @@ -25,7 +25,6 @@ public class RequestHistoryDTO { | ||||
|     private UUID clientUUID; | ||||
|     @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) | ||||
|     private LocalDateTime dateTimeStamp; | ||||
|     private Integer messageID; | ||||
|     private Map<String,String> headers; | ||||
|     private HttpMethod httpMethod; | ||||
|     private String requestBody; | ||||
|   | ||||
| @@ -14,11 +14,11 @@ import org.springframework.transaction.annotation.Transactional; | ||||
|  */ | ||||
| @Repository | ||||
| @Transactional | ||||
| public interface MockedResponseRepository extends CrudRepository<MockedMessage, String> { | ||||
| public interface MockedResponseRepository extends CrudRepository<MockedMessage, UUID> { | ||||
|     /** | ||||
|      * Finds all messages by their uuid | ||||
|      * @param clientUUID the key-uuid of given set of messages | ||||
|      * @return Optional of list of {@link com.r11.tools.model.MockedMessage} | ||||
|      */ | ||||
|     Optional<List<MockedMessage>> findAllByClientUUID(UUID clientUUID); | ||||
|     Optional<MockedMessage> findAllByClientUUID(UUID clientUUID); | ||||
| } | ||||
|   | ||||
| @@ -14,7 +14,5 @@ import java.util.List; | ||||
| @Repository | ||||
| @Transactional | ||||
| public interface RequestHistoryRepository extends CrudRepository<RequestHistory,String> { | ||||
|     List<RequestHistory> findAllByClientUUIDAndMessageID( | ||||
|             String clientUUID, | ||||
|             Integer messageID); | ||||
|     List<RequestHistory> findAllByClientUUID(String clientUUID); | ||||
| } | ||||
|   | ||||
| @@ -1,7 +1,8 @@ | ||||
| package com.r11.tools.service; | ||||
|  | ||||
| import com.r11.tools.model.MockedMessageDto; | ||||
| import java.util.List; | ||||
|  | ||||
| import java.util.Optional; | ||||
| import java.util.UUID; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.stereotype.Service; | ||||
| @@ -12,8 +13,7 @@ import org.springframework.stereotype.Service; | ||||
|  */ | ||||
| @Service | ||||
| public interface KlausService { | ||||
|     ResponseEntity<String> deleteMockedResponse(UUID clientUUID, int mockedResponseId); | ||||
|     List<MockedMessageDto> getAllMockedResponses(UUID clientUUID); | ||||
|     MockedMessageDto getMockedResponse(UUID clientUUID, int mockedResponseId); | ||||
|     Optional<MockedMessageDto> getMockedMessageByClientUUID(UUID clientUUID); | ||||
|     MockedMessageDto getMockedResponse(UUID clientUUID); | ||||
|     ResponseEntity<String> setMockedResponse(MockedMessageDto mockedMessageDto); | ||||
| } | ||||
|   | ||||
| @@ -13,16 +13,15 @@ import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
| import java.util.UUID; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| /** | ||||
|  * Service for {@link com.r11.tools.controller.MockController} and {@link com.r11.tools.controller.MockController} | ||||
|  * Allows for performing CRUD operations on {@link MockedMessageDto} | ||||
|  * @author Rafał Żukowicz | ||||
|  * @author Gabriel Modzelewski | ||||
|  * @author Mikołaj Widła | ||||
|  */ | ||||
| @Service | ||||
| @AllArgsConstructor | ||||
| @@ -31,20 +30,6 @@ public class KlausServiceImpl implements KlausService { | ||||
|     private final Logger log = LogManager.getRootLogger(); | ||||
|     private final MockedResponseRepository mockedResponseRepository; | ||||
|  | ||||
|     /** | ||||
|      * Removes message of given id in given key-uuid set | ||||
|      * @param clientUUID the key-uuid of given set of messages | ||||
|      * @param mockedResponseId unique id of given message | ||||
|      * @return confirmation and status 200 OK | ||||
|      */ | ||||
|     @Override | ||||
|     public ResponseEntity<String> deleteMockedResponse(UUID clientUUID, int mockedResponseId) { | ||||
|         String key = clientUUID.toString() + "_" + mockedResponseId; | ||||
|         mockedResponseRepository.deleteById(key); | ||||
|         log.info("Message: "+mockedResponseId+" has been removed."); | ||||
|         return new ResponseEntity<>("MockedResponse has been removed successfully", | ||||
|                 new HttpHeaders(), HttpStatus.ACCEPTED); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns all messages of given key-uuid | ||||
| @@ -52,28 +37,23 @@ public class KlausServiceImpl implements KlausService { | ||||
|      * @return List of {@link MockedMessageDto} | ||||
|      */ | ||||
|     @Override | ||||
|     public List<MockedMessageDto> getAllMockedResponses(UUID clientUUID){ | ||||
|         Optional<List<MockedMessage>> listOptional = mockedResponseRepository.findAllByClientUUID(clientUUID); | ||||
|         log.info("Messages for UUID: "+clientUUID+" has been fetched from DB."); | ||||
|         return listOptional.map(mockedMessages -> mockedMessages.stream() | ||||
|                 .map(mockedMessageMapper::mockedMessageToMockedMessageDto) | ||||
|                 .collect(Collectors.toList())).orElse(List.of()); | ||||
|     public Optional<MockedMessageDto> getMockedMessageByClientUUID(UUID clientUUID){ | ||||
|         Optional<MockedMessage> mockedMessageOptional = mockedResponseRepository.findAllByClientUUID(clientUUID); | ||||
|         log.info("Message for UUID: "+clientUUID+" has been fetched from DB."); | ||||
|         return mockedMessageMapper.optionalMockedMessageToOptionalMockedMessageDTO(mockedMessageOptional); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns {@link MockedMessageDto} of given id and key-uuid. If message doesn't then empty message is returned | ||||
|      * @param clientUUID the key-uuid of given set of messages | ||||
|      * @param mockedResponseId unique id of given message | ||||
|      * @return {@link MockedMessageDto} object | ||||
|      */ | ||||
|     @SneakyThrows | ||||
|     @Override | ||||
|     public MockedMessageDto getMockedResponse(UUID clientUUID, int mockedResponseId){ | ||||
|         String key = clientUUID.toString() + "_" + mockedResponseId; | ||||
|         Optional<MockedMessage> optionalMockedMessage = mockedResponseRepository.findById(key); | ||||
|     public MockedMessageDto getMockedResponse(UUID clientUUID){ | ||||
|         Optional<MockedMessage> optionalMockedMessage = mockedResponseRepository.findById(clientUUID); | ||||
|         MockedMessageDto mockedMessageDto = MockedMessageDto.builder() | ||||
|                 .clientUUID(clientUUID) | ||||
|                 .mockedResponseId(mockedResponseId) | ||||
|                 .build(); | ||||
|         if (optionalMockedMessage.isPresent()) { | ||||
|             mockedMessageDto = mockedMessageMapper.mockedMessageToMockedMessageDto(optionalMockedMessage.get()); | ||||
|   | ||||
| @@ -33,9 +33,8 @@ public class RequestHistoryServiceImpl implements RequestHistoryService { | ||||
|      */ | ||||
|     @Override | ||||
|     public List<RequestHistory> getHistoryRecordsBetweenDatesAndByUUIDAndMessageId(HistoryRequestModel historyRequestModel) { | ||||
|         List<RequestHistory> history = repository.findAllByClientUUIDAndMessageID( | ||||
|                 historyRequestModel.getClientUUID().toString(), | ||||
|                 historyRequestModel.getMockedResponseId() | ||||
|         List<RequestHistory> history = repository.findAllByClientUUID( | ||||
|                 historyRequestModel.getClientUUID().toString() | ||||
|                 ); | ||||
|         Collections.sort(history); | ||||
|  | ||||
|   | ||||
| @@ -62,10 +62,6 @@ body { | ||||
|     width: 90%; | ||||
| } | ||||
|  | ||||
| .tool.extended .tool-context { | ||||
|     width: 75%; | ||||
| } | ||||
|  | ||||
| .tool.extended .tool-extention { | ||||
|     width: 20%; | ||||
|     padding-top: 2%; | ||||
|   | ||||
| @@ -217,19 +217,19 @@ function initializeMock(index){ | ||||
|         clearMock(); | ||||
|         fillStaticFields(json[index].clientUUID | ||||
|             , json[index].mockedResponseId | ||||
|             , json[index].mediaType | ||||
|             , json[index].contentType | ||||
|             , json[index].messageBody | ||||
|             , json[index].httpStatus); | ||||
|         fillHeaderTable(json[index].httpHeaders); | ||||
| } | ||||
|  | ||||
| function fillStaticFields(uuid, id, mediaType, body, httpStatus){ | ||||
| function fillStaticFields(uuid, id, contentType, body, httpStatus){ | ||||
|     let link = createLink(uuid,id); | ||||
|     let linkHtml = '<a class="hyperlink" target="_blank" href="'+link+'">'+link+'</a>'; | ||||
|     $('#messageLink').html(linkHtml); | ||||
|     $('#httpStatus').val(httpStatus); | ||||
|     $('#uuid-input').val(uuid); | ||||
|     $('#typeSelector').val(mediaType); | ||||
|     $('#typeSelector').val(contentType); | ||||
|     $('#bodyEditor').val(body); | ||||
|     $('#mockedMessageId').html(id); | ||||
|  | ||||
| @@ -401,7 +401,7 @@ function fillMessageList(){ | ||||
|     $("#listItems").html(''); | ||||
|     var innerHTML = ''; | ||||
|     for(let i=0; i<json.length; i++){ | ||||
|         innerHTML += generateMessageTileHtml(json[i].mockedResponseId, json[i].httpStatus, json[i].mediaType); | ||||
|         innerHTML += generateMessageTileHtml(json[i].mockedResponseId, json[i].httpStatus, json[i].contentType); | ||||
|     } | ||||
|     $("#listItems").append(innerHTML); | ||||
|     $('.tile').click(function(e) { | ||||
| @@ -475,7 +475,7 @@ function selectMessage(id){ | ||||
|  | ||||
|  | ||||
|  | ||||
| function generateMessageTileHtml(id, httpStatus, mediaType){ | ||||
| function generateMessageTileHtml(id, httpStatus, contentType){ | ||||
|     var innerHTML = '' + | ||||
|     '<div tileid="' + id + '" class="tile">' + | ||||
|         '<div class="content">' + | ||||
| @@ -515,8 +515,7 @@ function generateJson(){ | ||||
|     var newJson = | ||||
|         { | ||||
|             clientUUID: json[jsonIndex].clientUUID, | ||||
|             mockedResponseId: json[jsonIndex].mockedResponseId, | ||||
|             mediaType: $('#typeSelector').val(), | ||||
|             contentType: $('#typeSelector').val(), | ||||
|             messageBody: $('#bodyEditor').val(), | ||||
|             httpStatus: $('#httpStatus').val(), | ||||
|             httpHeaders: {}, | ||||
|   | ||||
| @@ -43,36 +43,9 @@ | ||||
|                 <div> | ||||
|                     <h1>MockedServices</h1> | ||||
|                 </div> | ||||
|                 <div> | ||||
|                     <label for="uuid-input" class="block-display">UUID</label> | ||||
|                     <div id="uuid-edit"> | ||||
|                         <div id="uuid-edit-field" class="bordered-field disabled"> | ||||
|                             <input id="uuid-input" disabled onfocusout="changeUUID(this);" value="UUID" /> | ||||
|                             <button onclick="copyUUIDToClipboard();" class="uuid-inputField-icon modification-button flex-item btn-copy action-button">  | ||||
|                                 <span class="material-icons uuid-inputField-icon-span ">content_copy</span>  | ||||
|                             </button> | ||||
|                         </div> | ||||
|                         <div id="editableBlock"> | ||||
|                             <input type="checkbox" onchange="changeEditionOfUUID(this)" name="editable" id="editable" value="false"/> | ||||
|                             <label for="editable">Editable</label> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                      | ||||
|                     <div class="hiddable" id="uuid-validation-strategy"> | ||||
|                         <label><b>UUID generation strategy:</b></label> | ||||
|                          | ||||
|                         <input type="radio" checked name="uuid-validation-type" value="new" id="generateNew"/> | ||||
|                         <label for="generateNew">Generate new UUID</label> | ||||
|                          | ||||
|                         <input type="radio" name="uuid-validation-type" value="restore" id="restore"/> | ||||
|                         <label for="restore">Restore previous UUID</label> | ||||
|                     </div> | ||||
|  | ||||
|                 </div> | ||||
|                 <div> | ||||
|                     <!-- h2 --> | ||||
|                     <div id="basicItemData" class="hiddable active"><h2>Your Message</h2></div> | ||||
|                     <div id="advancedItemData" class="hiddable"><h2>Messaged id: <span id="mockedMessageId">1</span></h2></div> | ||||
|                     <div><h2>Your Message</h2></div> | ||||
|  | ||||
|                     <!-- link --> | ||||
|                     <div> | ||||
| @@ -195,18 +168,6 @@ | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div id="selectMenuContent" class="tool-extention"> | ||||
|                 <!-- header --> | ||||
|                 <div> | ||||
|                     <h2>Message List</h2> | ||||
|                 </div> | ||||
|                 <!-- tile list --> | ||||
|                 <div id="listItems"> | ||||
|                 </div> | ||||
|                 <div id="new-tile" class="max-width centered-content small-vertical-margin"> | ||||
|                     <button id="btn-newtile" class="modification-button btn-addtile"><i class="icon-plus"></i></button> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="tooltip-window lite"> | ||||
|             <div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user