T248 T245 /mock/json path changed to /api/mock; mapping '/' moved to MainController

This commit is contained in:
2021-03-26 15:27:59 +01:00
parent eba27650e1
commit e81e4b1d56
13 changed files with 104 additions and 80 deletions

View File

@@ -0,0 +1,27 @@
package com.release11.klaus.controller;
import lombok.SneakyThrows;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* Class responsible for returning homepage html
* @author Gabriel Modzelewski
*/
@Controller
@RequestMapping("/")
public class MainController {
/**
* Default path to get the homepage
* @return the view of homepage
*/
@SneakyThrows
@GetMapping
public ModelAndView showHome(){
ModelAndView mov = new ModelAndView();
mov.setViewName("html/mock");
return mov;
}
}

View File

@@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.http.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.time.LocalDateTime;
import java.util.*;
@@ -21,23 +20,13 @@ import java.util.*;
* @author Gabriel Modzelewski
*/
@Slf4j
@Controller
@RequestMapping(path = "/")
@RestController
@RequestMapping(path = "/api/mock")
@AllArgsConstructor
public class MockController {
private final KlausService klausService;
/**
* Default path to get the homepage
* @return the view of homepage
*/
@SneakyThrows
@GetMapping
public ModelAndView showHome(){
ModelAndView mov = new ModelAndView();
mov.setViewName("html/mock");
return mov;
}
/**
* Updates queried message with given set of data
@@ -45,8 +34,7 @@ public class MockController {
* @return confirmation and 200 OK
*/
@SneakyThrows
@ResponseBody
@PutMapping("/mock/json")
@PutMapping("/")
public ResponseEntity<String> updateMessage(@RequestBody String body){
ObjectMapper mapper = new ObjectMapper();
MockedMessageDto message = mapper.readValue(body, MockedMessageDto.class);
@@ -59,8 +47,7 @@ public class MockController {
* @param uuidValue the key-uuid of given set of messages
* @return responds with 200 OK and list of {@link MockedMessageDto}
*/
@ResponseBody
@GetMapping({"/mock/json", "/mock/json/{uuidValue}"})
@GetMapping({"/", "/{uuidValue}"})
public List<MockedMessageDto> getListOfMessages(@PathVariable(required = false) String uuidValue){
UUID clientUUID;
if(uuidValue == null || uuidValue.equals("")) clientUUID = UUID.randomUUID();
@@ -80,8 +67,7 @@ public class MockController {
* @param uuidValue the key-uuid of given set of messages
* @return confirmation response with 200 OK
*/
@ResponseBody
@PostMapping("/mock/json/{uuidValue}")
@PostMapping("/{uuidValue}")
public ResponseEntity<String> addNewMessage(@PathVariable String uuidValue){
UUID clientUUID = UUID.fromString(uuidValue);
List<MockedMessageDto> messages = klausService.getAllMockedResponses(clientUUID);
@@ -95,8 +81,7 @@ public class MockController {
* @param idValue unique id of given message
* @return after deletion the confirmation is send with status 200 OK
*/
@ResponseBody
@DeleteMapping("/mock/json/{uuidValue}/{idValue}")
@DeleteMapping("/{uuidValue}/{idValue}")
public ResponseEntity<String> removeMessage(@PathVariable String uuidValue,
@PathVariable String idValue){
UUID clientUUID = UUID.fromString(uuidValue);
@@ -163,7 +148,7 @@ public class MockController {
* @param mockedResponseId unique id of given message
* @return
*/
@GetMapping(value = "/klaus/v1/get/{clientUUID}/{mockedResponseId}")
@GetMapping(value = "/r/{clientUUID}/{mockedResponseId}")
public ResponseEntity getMockedResponse(RequestEntity<String> requestEntity,
@PathVariable UUID clientUUID,
@PathVariable int mockedResponseId) {