T157 put request is send. 415 response format unaccepted

This commit is contained in:
2021-02-06 13:30:24 +01:00
parent f851dd5538
commit 53215798f7
5 changed files with 29 additions and 15 deletions

8
.idea/workspace.xml generated
View File

@@ -20,13 +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 afterPath="$PROJECT_DIR$/src/main/resources/static/js/jquery.js" 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$/src/main/java/com/release11/klaus/controller/MockController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/MockController.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/MockController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/release11/klaus/controller/MockController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/static/js/datatransfer.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/static/js/datatransfer.js" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/resources/static/js/datatransfer.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/static/js/datatransfer.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/com/release11/klaus/KlausApplicationTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/release11/klaus/KlausApplicationTests.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/resources/templates/mock.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/mock.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/com/release11/klaus/config/RedisConfigTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/release11/klaus/config/RedisConfigTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/com/release11/klaus/controller/KlausControllerTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/release11/klaus/controller/KlausControllerTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/com/release11/klaus/repository/EventRepositoryImplTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/release11/klaus/repository/EventRepositoryImplTest.java" afterDir="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" />
@@ -315,7 +313,7 @@
<workItem from="1612259068808" duration="10440000" /> <workItem from="1612259068808" duration="10440000" />
<workItem from="1612279535476" duration="5692000" /> <workItem from="1612279535476" duration="5692000" />
<workItem from="1612442837870" duration="8318000" /> <workItem from="1612442837870" duration="8318000" />
<workItem from="1612609113694" duration="1761000" /> <workItem from="1612609113694" duration="5466000" />
</task> </task>
<task id="LOCAL-00077" summary="testing jenkins docker"> <task id="LOCAL-00077" summary="testing jenkins docker">
<created>1601453886631</created> <created>1601453886631</created>

View File

@@ -36,7 +36,6 @@ public class MockController {
4. After each action cookie is updated 4. After each action cookie is updated
Cookie holds uuid, last displayed message Cookie holds uuid, last displayed message
*/ */
//TODO: There is no bean for UUID
//TODO: Add cookie in javascript //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. * Responds to first user request. If UUID is given then it's set if it's not, then new one is generated.
@@ -49,7 +48,7 @@ public class MockController {
return "mock"; return "mock";
} }
@PutMapping("/mock/{uuid}") @PutMapping("/mock/json")
public ResponseEntity<String> updateMessage(@RequestBody MockedMessageDto message){ public ResponseEntity<String> updateMessage(@RequestBody MockedMessageDto message){
return klausService.setMockedResponse(message); return klausService.setMockedResponse(message);
} }

View File

@@ -23,6 +23,23 @@ function getData(uuid){
}); });
} }
function updateData(){
var updatedJson = generateJson();
$.ajax({
url: 'http://localhost:8097/mock/json',
type: 'PUT',
data: updatedJson,
success: function(data) {
console.log('PUT request received 200');
}
});
// $.put('http://localhost:8097/mock/json', function(data){
//
// });
// console.log('PUT request sent');
getData();
}
function clearMock(){ function clearMock(){
fillStaticFields('','','',''); fillStaticFields('','','','');
@@ -143,13 +160,9 @@ function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
} }
function saveChanges(){
convertTableToJson();
generateJson();
}
function generateJson(){ function generateJson(){
console.log("Save button click");
var newJson = var newJson =
{ {
clientUUID: json[jsonIndex].clientUUID, clientUUID: json[jsonIndex].clientUUID,
@@ -160,7 +173,8 @@ function generateJson(){
httpHeaders: {}, httpHeaders: {},
}; };
newJson['httpHeaders'] = convertTableToJson(); newJson['httpHeaders'] = convertTableToJson();
document.write(JSON.stringify(newJson, null, 2)); console.log(JSON.stringify(newJson, null, 2));
return newJson;
} }
// $("table tr").eq(row).find("td").eq(i%2).append("<img src='"+dataJson[i].imagen+"' width='100'/>"); // $("table tr").eq(row).find("td").eq(i%2).append("<img src='"+dataJson[i].imagen+"' width='100'/>");

File diff suppressed because one or more lines are too long

View File

@@ -7,7 +7,8 @@
<link rel="stylesheet" href="/Dependency/fontello-plus/css/fontello.css" type="text/css"/> <link rel="stylesheet" href="/Dependency/fontello-plus/css/fontello.css" type="text/css"/>
<link rel="preconnect" href="https://fonts.gstatic.com"> <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Acme&family=Josefin+Slab:wght@500&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Acme&family=Josefin+Slab:wght@500&display=swap" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>-->
<script type="text/javascript" src="/js/datatransfer.js"></script> <script type="text/javascript" src="/js/datatransfer.js"></script>
</head> </head>
<body> <body>
@@ -75,7 +76,7 @@
<div id="history" style="display:none;"></div> <div id="history" style="display:none;"></div>
</div> </div>
<div id="functionBar"> <div id="functionBar">
<button id="btn-save" type="submit" class="functionBarButton" onclick="saveChanges()">Save</button> <button id="btn-save" type="submit" class="functionBarButton" onclick="updateData()">Save</button>
<div style="clear: both;"></div> <div style="clear: both;"></div>
</div> </div>
</div> </div>