WiP: Building stateless backend
This commit is contained in:
19
.idea/workspace.xml
generated
19
.idea/workspace.xml
generated
@@ -20,11 +20,11 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="458cde88-df3d-44bc-9d57-a33823e2f1a6" name="Default Changelist" comment="">
|
<list default="true" id="458cde88-df3d-44bc-9d57-a33823e2f1a6" name="Default Changelist" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/MockController.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Klaus.iml" beforeDir="false" afterPath="$PROJECT_DIR$/Klaus.iml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/KlausController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/KlausController.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/KlausMvcController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/KlausMvcController.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/release11/klaus/model/TestModel.java" beforeDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -311,7 +311,7 @@
|
|||||||
<workItem from="1611915874625" duration="15194000" />
|
<workItem from="1611915874625" duration="15194000" />
|
||||||
<workItem from="1612178634549" duration="20097000" />
|
<workItem from="1612178634549" duration="20097000" />
|
||||||
<workItem from="1612259068808" duration="10440000" />
|
<workItem from="1612259068808" duration="10440000" />
|
||||||
<workItem from="1612279535476" duration="432000" />
|
<workItem from="1612279535476" duration="5692000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00077" summary="testing jenkins docker">
|
<task id="LOCAL-00077" summary="testing jenkins docker">
|
||||||
<created>1601453886631</created>
|
<created>1601453886631</created>
|
||||||
@@ -863,15 +863,6 @@
|
|||||||
<state x="1010" y="253" width="1478" height="1186" key="search.everywhere.popup/62.0.3378.1440@62.0.3378.1440" timestamp="1612279508335" />
|
<state x="1010" y="253" width="1478" height="1186" key="search.everywhere.popup/62.0.3378.1440@62.0.3378.1440" timestamp="1612279508335" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
|
||||||
<breakpoints>
|
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/KlausController.java</url>
|
|
||||||
<line>100</line>
|
|
||||||
<option name="timeStamp" value="36" />
|
|
||||||
</line-breakpoint>
|
|
||||||
</breakpoints>
|
|
||||||
</breakpoint-manager>
|
|
||||||
<watches-manager>
|
<watches-manager>
|
||||||
<configuration name="Application">
|
<configuration name="Application">
|
||||||
<watch expression="eventString.hash" />
|
<watch expression="eventString.hash" />
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.release11.klaus.controller;
|
|||||||
|
|
||||||
import com.release11.klaus.model.MockedMessageDto;
|
import com.release11.klaus.model.MockedMessageDto;
|
||||||
import com.release11.klaus.model.MockedMessageDtoTest;
|
import com.release11.klaus.model.MockedMessageDtoTest;
|
||||||
import com.release11.klaus.model.TestModel;
|
|
||||||
import com.release11.klaus.service.KlausService;
|
import com.release11.klaus.service.KlausService;
|
||||||
import com.release11.klaus.utilis.BusinessKey;
|
import com.release11.klaus.utilis.BusinessKey;
|
||||||
import com.release11.klaus.utilis.TrackingClient;
|
import com.release11.klaus.utilis.TrackingClient;
|
||||||
@@ -40,12 +39,6 @@ public class KlausController {
|
|||||||
.httpHeaders(new HashMap<>())
|
.httpHeaders(new HashMap<>())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ResponseBody
|
|
||||||
@GetMapping(value = "klaus/v1/get/test/test")
|
|
||||||
public TestModel getTestTest(){
|
|
||||||
TestModel testModel = new TestModel();
|
|
||||||
return testModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping(value = "klaus/v1/get/test/msgtest")
|
@GetMapping(value = "klaus/v1/get/test/msgtest")
|
||||||
@@ -109,20 +102,4 @@ public class KlausController {
|
|||||||
Objects.requireNonNull(HttpStatus.valueOf(mockedMessageDto.getHttpStatus())));
|
Objects.requireNonNull(HttpStatus.valueOf(mockedMessageDto.getHttpStatus())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @PostMapping(value = "klaus/v1/set/{clientUUID}/{mockedResponseId}")
|
|
||||||
// public ResponseEntity<String> setMockedResponse(@PathVariable UUID clientUUID,
|
|
||||||
// @PathVariable int mockedResponseId,
|
|
||||||
// @RequestParam(required = false) Integer httpStatus,
|
|
||||||
// RequestEntity<String> requestEntity){
|
|
||||||
// TrackingClient.setBusinessKeys(Map.of(BusinessKey.INTERFACE_NAME, "setMockedResponse",
|
|
||||||
// BusinessKey.CLIENT_UUID, String.valueOf(clientUUID),
|
|
||||||
// BusinessKey.MESSAGE_ID, String.valueOf(mockedResponseId)));
|
|
||||||
// if (httpStatus == null) httpStatus = 200;
|
|
||||||
//
|
|
||||||
// MockedMessageDto mockedMessageDto = new MockedMessageDto(clientUUID, mockedResponseId,
|
|
||||||
// requestEntity.getHeaders().getContentType().toString(), requestEntity.getBody(),
|
|
||||||
// requestEntity.getHeaders().toSingleValueMap(), httpStatus);
|
|
||||||
// return klausService.setMockedResponse(mockedMessageDto);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping
|
@RequestMapping("/old")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class KlausMvcController {
|
public class KlausMvcController {
|
||||||
private final KlausService klausService;
|
private final KlausService klausService;
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.release11.klaus.controller;
|
||||||
|
|
||||||
|
import com.release11.klaus.model.MockedMessageDto;
|
||||||
|
import com.release11.klaus.service.KlausService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MockController {
|
||||||
|
private final KlausService klausService;
|
||||||
|
//TODO: Write a method
|
||||||
|
private final MockedMessageDto defaultMessage = MockedMessageDto.builder().build();
|
||||||
|
private UUID sessionUUID;
|
||||||
|
private final Set<MockedMessageDto> globalMockedMessageDtoList = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: Add cookie in javascript
|
||||||
|
/**
|
||||||
|
* Responds to first user request. If UUID is given then it's set if it's not, then new one is generated.
|
||||||
|
* Next recalls method that populates model based on UUID
|
||||||
|
* @param clientUUID
|
||||||
|
* @param uuid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@GetMapping({"/mock", "/mock/{uuid}"})
|
||||||
|
public String showHome(@RequestParam(required = false) UUID clientUUID,
|
||||||
|
@PathVariable(required = false) UUID uuid){
|
||||||
|
if (uuid != null) clientUUID = uuid;
|
||||||
|
if (clientUUID != null) sessionUUID = clientUUID;
|
||||||
|
else sessionUUID = UUID.randomUUID();
|
||||||
|
this.updateGlobalMockedMessageDtoList();
|
||||||
|
return "mock";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates model with current message list based on sessionUUID
|
||||||
|
*/
|
||||||
|
private void updateGlobalMockedMessageDtoList(){
|
||||||
|
globalMockedMessageDtoList.clear();
|
||||||
|
List<MockedMessageDto> mockedMessageDtoList = klausService.getAllMockedResponses(sessionUUID);
|
||||||
|
if (mockedMessageDtoList.size() == 0) mockedMessageDtoList.add(defaultMessage);
|
||||||
|
globalMockedMessageDtoList.addAll(mockedMessageDtoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Add json file
|
||||||
|
private static MockedMessageDto buildDefaultMessage(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.release11.klaus.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
|
||||||
|
|
||||||
@JsonPropertyOrder({ "name", "lastname" })
|
|
||||||
public class TestModel {
|
|
||||||
private String name = "Jason";
|
|
||||||
private String lastname = "Born";
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLastname() {
|
|
||||||
return lastname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastname(String lastname) {
|
|
||||||
this.lastname = lastname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user