Merge with modzeleg

This commit is contained in:
2021-02-18 16:16:53 +01:00
29 changed files with 117 additions and 1487 deletions

8
.idea/workspace.xml generated
View File

@@ -29,7 +29,11 @@
<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/main/resources/templates/mock.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/mock.html" 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" />
<<<<<<< HEAD
<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" />
>>>>>>> modzeleg
=======
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/mock.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/mock.html" afterDir="false" />
>>>>>>> modzeleg >>>>>>> modzeleg
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@@ -327,6 +331,10 @@
======= =======
<workItem from="1612868404302" duration="13841000" /> <workItem from="1612868404302" duration="13841000" />
<workItem from="1613384221052" duration="5569000" /> <workItem from="1613384221052" duration="5569000" />
<<<<<<< HEAD
>>>>>>> modzeleg
=======
<workItem from="1613557608694" duration="9724000" />
>>>>>>> modzeleg >>>>>>> modzeleg
</task> </task>
<task id="LOCAL-00077" summary="testing jenkins docker"> <task id="LOCAL-00077" summary="testing jenkins docker">

26
Jenkinsfile vendored
View File

@@ -1,24 +1,8 @@
pipeline { node('master'){
agent any stage('git') {
tools {
maven "Maven 3.6.3"
} }
stages { stage('deploy'){
stage('Build') { sh 'docker-compose --context gordon up --build -d'
steps {
sh "docker-compose --context DEV build"
}
}
stage('Deploy') {
steps {
sh "docker-compose --context DEV up -d"
}
}
stage('Logs') {
steps {
sleep time: 1, unit: 'MINUTES'
sh 'docker --context DEV logs klaus'
}
}
} }
} }

View File

@@ -1,241 +0,0 @@
html {
height: 100%;
}
body {
min-height: 100%;
}
.page-section{
padding: 2rem 0;
}
.page-section .column{
float: left;
width: 50%;
}
.page-section .row:after {
content: "";
display: table;
clear: both;
}
@media screen and (max-width: 600px) {
.column {
width: 100%;
}
}
button:hover { font-weight: 600; }
button:hover i { margin-right: 20px; }
button:focus {
outline: none;
}
.pageable {
border: 1px solid rgba(0, 0, 0, .11);
;
padding: 10px;
}
.tr-pageable{
margin-left:1000px;
}
.controls-item {
display: inline-block;
}
.btn {
margin: 1px;
}
tr[name="tr-button"]:hover{
background-color: #ddd;
cursor: pointer;
}
#pagination-wrapper button {
background: none;
border: 2px solid #00b3b3;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
button[name="removeMessage"]{
background: none;
border: none;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
button[name="updateMessage"]{
background: none;
border: none;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
button[name="allMessagesClicked"] {
color: #00b3b3;
}
button[name="removeHeader"] {
position: absolute;
background: none;
border: none;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
.btn-sort {
border: 0;
padding: 0 20px;
text-align: center;
color: #fff;
text-shadow: 1px 1px 1px #000;
border-radius: 10px;
background-color: rgb(0, 102, 255);
background-image: linear-gradient(to top left,
rgba(0, 0, 0, .2),
rgba(0, 0, 0, .2) 30%,
rgba(0, 0, 0, 0));
}
.btn-sort:hover {
background-color: rgb(153, 194, 255);
cursor: pointer;
}
.activeButton {
background-color: rgb(153, 194, 255);
}
#child-body{
margin-left: 220px;
}
#container1{
}
#foot {
clear: both;
position: relative;
right: 0;
bottom: 0;
left: 0;
}
/* The side navigation menu */
.sidebar {
margin-top: 100px;
padding-top: 200px;
padding: 0;
width: 200px;
background-color: #f1f1f1;
position: absolute;
height: 100%;
overflow: auto;
}
/* Sidebar links */
.sidebar a {
display: block;
color: black;
padding: 16px;
text-decoration: none;
}
/* Active/current link */
.sidebar a.active {
background-color: #4CAF50;
color: white;
}
/* Links on mouse-over */
.sidebar a:hover:not(.active) {
background-color: #555;
color: white;
}
/* On screens that are less than 700px wide, make the sidebar into a topbar */
@media screen and (max-width: 700px) {
.sidebar {
width: 100%;
height: auto;
position: fixed;
}
.sidebar a {float: left;}
div.content {margin-left: 0;}
}
/* On screens that are less than 400px, display the bar vertically, instead of horizontally */
@media screen and (max-width: 400px) {
.sidebar a {
text-align: center;
float: none;
}
}
table { border-collapse: collapse; }
tr { border: none; }
td {
border: none;
vertical-align: top;
}
button{
padding: 5px 14px;
border-width: 1px;
border-style: solid;
background: #32a6cc;
color: #fff;
transition: all 0.3s ease;
font-family: Arial, sans-serif;
font-size: 1em;
border-radius: 2px;
}
disabled-button{
padding: 5px 14px;
border-width: 1px;
border-style: solid;
background: darkgrey;
color: #fff;
font-family: Arial, sans-serif;
font-size: 1em;
border-radius: 2px;
}
label { display: block;
}
.hint { display: none; color: gray; font-style: italic; float:right;}
input:focus + .hint { display: inline; float:right;}
textarea:focus + .hint { display: inline; float:right; }
textarea:focus + .hint { display: inline; float:right; }
select:focus + .hint { display: inline; float:right; }
select#media-type {
width: 500px;
}
textarea#message-body {
width: 500px;
height: 300px;
}
gen-link {
margin-top: 60px;
margin-bottom: 30px;
font-size: 24px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,180 +0,0 @@
var state = {
'querySet': [{
"clientUUID": "436c4774-038f-4540-9c18-2691ca9b53d4",
"mockedResponseId": 1908998,
"mediaType": "application/xml",
"messageBody": "body",
"httpHeaders": null,
"httpStatus": 200
}],
'page': 1,
'rows': 10,
'window': 5,
}
var myList, data, previousSort;
state.querySet = listForPagination;
buildTable();
for (let i = 3; i >= 0; i--) {
document.querySelector('#btn-sort-' + i).addEventListener('click', function() {
addButtonListeners(i)
})
}
function addButtonListeners(i) {
var buttons = document.querySelectorAll('.btn-sort');
for (var j = buttons.length - 1; j >= 0; j--) {
buttons[j].classList.remove('activeButton');
}
document.querySelector('#btn-sort-' + i).classList.add('activeButton');
buildTable();
}
function pagination(querySet, page, rows) {
var trimStart = (page - 1) * rows
var trimEnd = trimStart + rows
var trimmedData = querySet.slice(trimStart, trimEnd)
var pages = Math.ceil(querySet.length / rows);
if (pages === 0) {
pages = 1
}
return {
'querySet': trimmedData,
'pages': pages,
}
}
function pageButtons(pages) {
var wrapper = document.getElementById('pagination-wrapper');
wrapper.innerHTML = ``;
var maxLeft = (state.page - Math.floor(state.window / 2))
var maxRight = (state.page + Math.ceil(state.window / 2))
if (maxLeft < 1) {
maxLeft = 1
maxRight = state.window
}
if (maxRight > pages) {
maxLeft = pages - (state.window - 1)
if (maxLeft < 1) {
maxLeft = 1
}
maxRight = pages
}
for (var page = maxLeft; page <= maxRight; page++) {
if (page === state.page) {
wrapper.innerHTML += `<button value=${page} class="page btn btn-sm btn-info" name="allMessagesClicked">${page}</button>`
} else {
wrapper.innerHTML += `<button value=${page} class="page btn btn-sm btn-info">${page}</button>`
}
}
if (state.page != 1) {
wrapper.innerHTML = `<button value=${1} class="page btn btn-sm btn-info">&#171; First</button>` + wrapper.innerHTML
}
if (state.page != pages) {
wrapper.innerHTML += `<button value=${pages} class="page btn btn-sm btn-info">Last &#187;</button>`
}
$('.page').on('click', function() {
$('#table-body').empty()
state.page = Number($(this).val())
buildPage()
})
}
function showBody(elt){
$("#" + elt.id + "-body").toggle();
}
function showTable() {
var table = $('#table-body')
table.empty();
var color;
console.log(myList);
for (var i = 1; i <= myList.length; i++) {
var j = i + (state.page - 1) * 10;
i % 2 === 0 ? color = "#b3ffff" : color="#e6ffff";
var row = `<tr bgcolor="${color}" id="etrack-tr-${j}" onclick="showBody(this)" name="tr-button">
<td>` + j + `</td>
<td>${myList[i-1].messageId}</td>
<td>${myList[i-1].dateTimeStamp}</td>
<td>${myList[i-1].interfaceName}</td>
</tr>
<tr bgcolor="${color}" id="etrack-tr-${j}-body" name="tr-body" hidden>
<td colspan="4">"${JSON.stringify(myList[i-1].message)}"</td>
</tr>`
table.append(row)
}
for (var i = myList.length + 1; i <= state.rows; i++) {
i % 2 === 0 ? color = "#b3ffff" : color="#e6ffff";
var j = i + (state.page - 1) * 10;
var row = `<tr bgcolor="${color}">
<td>` + j + `</td>
<td></td>
<td></td>
<td></td>
`
table.append(row)
}
pageButtons(data.pages)
}
function sortTable() {
var sortBy = document.querySelector('.activeButton').textContent
switch (sortBy) {
case "MessageId":
if (previousSort === "MessageId") {
state.querySet.sort((a, b) => (a.messageId > b.messageId) ? -1 : ((b.messageId > a.messageId) ? 1 : 0));
} else {
state.querySet.sort((a, b) => (a.messageId > b.messageId) ? 1 : ((b.messageId > a.messageId) ? -1 : 0));
}
break;
case "TimeStamp":
if (previousSort === "TimeStamp") {
state.querySet.sort((a, b) => (a.dateTimeStamp > b.dateTimeStamp) ? -1 : ((b.dateTimeStamp > a.dateTimeStamp) ? 1 : 0));
} else {
state.querySet.sort((a, b) => (a.dateTimeStamp > b.dateTimeStamp) ? 1 : ((b.dateTimeStamp > a.dateTimeStamp) ? -1 : 0));
}
break;
case "Action":
if (previousSort === "Action") {
state.querySet.sort((a, b) => (a.interfaceName > b.interfaceName) ? -1 : ((b.interfaceName > a.interfaceName) ? 1 : 0));
} else {
state.querySet.sort((a, b) => (a.interfaceName > b.interfaceName) ? 1 : ((b.interfaceName > a.interfaceName) ? -1 : 0));
}
break;
}
if (previousSort === sortBy) {
previousSort = ""
} else previousSort = sortBy;
}
function prepareTable() {
data = pagination(state.querySet, state.page, state.rows)
myList = data.querySet
}
function buildTable() {
sortTable();
prepareTable();
showTable();
}
function buildPage() {
prepareTable();
showTable();
}

View File

@@ -1,37 +0,0 @@
function httpGet()
{
var clientUUID = document.getElementById("getClientUUID").value;
var mockedResponseId = document.getElementById("getMockedResponseId").value;
var url = "http://localhost:8097/klaus/v1/get/" + clientUUID + "/" + mockedResponseId;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", url, false ); // false for synchronous request
xmlHttp.send( null );
var container = document.getElementById("getMockedResponse");
var headers = xmlHttp.getAllResponseHeaders();
container.appendChild(document.createTextNode(headers));
container.appendChild(document.createTextNode("Your message: "));
container.appendChild(document.createElement("br"));
container.appendChild(document.createTextNode((xmlHttp.responseText)));
return xmlHttp.responseText;
}
var numberOfHeaders = 0;
function addFields(){
var container = document.getElementById("headers");
numberOfHeaders++;
container.appendChild(document.createElement("br"));
container.appendChild(document.createTextNode("Header " + (numberOfHeaders)));
var headerInput = document.createElement("input");
headerInput.type = "text";
headerInput.name = "header";
container.appendChild(headerInput);
container.appendChild(document.createTextNode("Value " + (numberOfHeaders)));
var valueInput = document.createElement("input");
valueInput.type = "text";
valueInput.name = "value";
container.appendChild(valueInput);
}

View File

@@ -1,221 +0,0 @@
var pubhost = location.hostname;
document.getElementById("pubhost").innerHTML = location.hostname;
var state = {
'querySet': [{
"clientUUID": "436c4774-038f-4540-9c18-2691ca9b53d4",
"mockedResponseId": 1908998,
"mediaType": "application/xml",
"messageBody": "body",
"httpHeaders": null,
"httpStatus": 200
}],
'page': 1,
'rows': 10,
'window': 5,
}
var myList, data, previousSort;
state.querySet = listForPagination;
buildTable();
document.querySelector('#btn-list-1').addEventListener('click', function() {
var x = document.getElementById("list-wrapper");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
});
for (let i = 3; i >= 0; i--) {
document.querySelector('#btn-sort-' + i).addEventListener('click', function() {
addButtonListeners(i);
})
}
function addButtonListeners(i) {
var buttons = document.querySelectorAll('.btn-sort');
for (var j = buttons.length - 1; j >= 0; j--) {
buttons[j].classList.remove('activeButton');
}
document.querySelector('#btn-sort-' + i).classList.add('activeButton');
buildTable();
}
function pagination(querySet, page, rows) {
var trimStart = (page - 1) * rows
var trimEnd = trimStart + rows
var trimmedData = querySet.slice(trimStart, trimEnd)
var pages = Math.ceil(querySet.length / rows);
if(pages === 0){pages = 1}
return {
'querySet': trimmedData,
'pages': pages,
}
}
function pageButtons(pages) {
var wrapper = document.getElementById('pagination-wrapper');
wrapper.innerHTML = ``;
var maxLeft = (state.page - Math.floor(state.window / 2));
var maxRight = (state.page + Math.ceil(state.window / 2));
if (maxLeft < 1) {
maxLeft = 1;
maxRight = state.window;
}
if (maxRight > pages) {
maxLeft = pages - (state.window - 1);
if (maxLeft < 1) {
maxLeft = 1;
}
maxRight = pages;
}
for (var page = maxLeft; page <= maxRight; page++) {
if (page === state.page) {
wrapper.innerHTML += `<button value=${page} class="page btn btn-sm btn-info" name="allMessagesClicked">${page}</button>`
} else {
wrapper.innerHTML += `<button value=${page} class="page btn btn-sm btn-info">${page}</button>`
}
}
if (state.page != 1) {
wrapper.innerHTML = `<button value=${1} class="page btn btn-sm btn-info">&#171; First</button>` + wrapper.innerHTML
}
if (state.page != pages) {
wrapper.innerHTML += `<button value=${pages} class="page btn btn-sm btn-info">Last &#187;</button>`
}
$('.page').on('click', function() {
$('#table-body').empty();
state.page = Number($(this).val());
buildPage();
});
}
function showTable() {
var table = $('#table-body')
table.empty();
for (var i = 1; i <= myList.length; i++) {
var j = i + (state.page - 1) * 10;
if (i % 2 === 0) {
var row = `<tr bgcolor="#b3ffff">
<td>` + j + `</td>
<td>${myList[i-1].mockedResponseId}</td>
<td>${myList[i-1].mediaType}</td>
<td>${myList[i-1].httpStatus}</td>
<td>
<button type="submit" name="updateMessage" value="${myList[i-1].mockedResponseId}">
<img src="/img/update-button.png" style="width: 20px;"/>
</button>
</td>
<td>
<button type="submit" name="removeMessage" value="${myList[i-1].mockedResponseId}">
<img src="/img/icons8-cancel-64.png" style="width: 20px;"/>
</button>
</td>
`
} else {
var row = `<tr bgcolor="#e6ffff">
<td>` + j + `</td>
<td>${myList[i-1].mockedResponseId}</td>
<td>${myList[i-1].mediaType}</td>
<td>${myList[i-1].httpStatus}</td>
<td>
<button type="submit" name="updateMessage" value="${myList[i-1].mockedResponseId}">
<img src="/img/update-button.png" style="width: 20px;"/>
</button>
</td>
<td>
<button type="submit" name="removeMessage" value="${myList[i-1].mockedResponseId}">
<img src="/img/icons8-cancel-64.png" style="width: 20px;"/>
</button>
</td>
`
}
table.append(row);
}
for (var i = myList.length + 1; i <= state.rows; i++) {
var j = i + (state.page - 1) * 10;
if (i % 2 === 0) {
var row = `<tr bgcolor="#b3ffff">
<td>` + j + `</td>
<td></td>
<td></td>
<td></td>
`
} else {
var row = `<tr bgcolor="#e6ffff">
<td>` + j + `</td>
<td></td>
<td></td>
<td></td>
`
}
table.append(row)
}
pageButtons(data.pages);
}
function sortTable() {
console.log("sortTable");
var sortBy = document.querySelector('.activeButton').textContent;
console.log(sortBy);
switch (sortBy) {
case "MessageId":
if (previousSort === "MessageId") {
state.querySet.sort((a, b) => (a.mockedResponseId > b.mockedResponseId) ? -1 : ((b.mockedResponseId > a.mockedResponseId) ? 1 : 0));
} else {
state.querySet.sort((a, b) => (a.mockedResponseId > b.mockedResponseId) ? 1 : ((b.mockedResponseId > a.mockedResponseId) ? -1 : 0));
}
break;
case "Media Type":
if (previousSort === "Media Type") {
state.querySet.sort((a, b) => (a.mediaType > b.mediaType) ? -1 : ((b.mediaType > a.mediaType) ? 1 : 0));
} else {
state.querySet.sort((a, b) => (a.mediaType > b.mediaType) ? 1 : ((b.mediaType > a.mediaType) ? -1 : 0));
}
break;
case "Http Status":
if (previousSort === "Http Status") {
state.querySet.sort((a, b) => (a.httpStatus > b.httpStatus) ? -1 : ((b.httpStatus > a.httpStatus) ? 1 : 0));
} else {
state.querySet.sort((a, b) => (a.httpStatus > b.httpStatus) ? 1 : ((b.httpStatus > a.httpStatus) ? -1 : 0));
}
break;
}
if (previousSort === sortBy) {
previousSort = ""
} else previousSort = sortBy;
myList = state.querySet;
console.log(myList);
}
function prepareTable() {
data = pagination(state.querySet, state.page, state.rows);
myList = data.querySet;
}
function buildTable() {
console.log("buildTable");
sortTable();
prepareTable();
showTable();
}
function buildPage(){
prepareTable();
showTable();
}

View File

@@ -1,92 +0,0 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>R11 Klaus</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,600" rel="stylesheet" type="text/css">
<link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css">
<link href="/css/styles.css" rel="stylesheet" />
</head>
<body>
<div id="container">
<div id="header"></div>
<div id="container1">
<div id="sidebar"></div>
<div id="child-body">
<section class="page-section" id="main-section">
<div class="row">
<div class="column">
<br>To see your activity history use the form below
<form action="#" th:action="@{/etrack/__${clientUUID}__}" th:object="${eventRequestDto}" method="post">
<input type="text" th:name="clientUUID" th:value="${clientUUID}" hidden />
<br><label>Mocked response id:</label><br>
<input type="text" th:name="mockedResponseId" th:id="mockedResponseId" th:placeholder="all" />
<td th:if="${#fields.hasErrors('mockedResponseId')}" th:errors="*{mockedResponseId}">mockedResponseId
error
</td>
<br><label>Date from:</label><br>
<input type="datetime-local" th:field="*{localDateTimeFrom}"/>
<td th:if="${#fields.hasErrors('localDateTimeFrom')}" th:errors="*{localDateTimeFrom}">localDateTimeFrom
Error
</td>
<br><label>Date to:</label><br>
<input type="datetime-local" th:field="*{localDateTimeTo}"/>
<td th:if="${#fields.hasErrors('localDateTimeTo')}" th:errors="*{localDateTimeTo}">localDateTimeTo
Error
</td>
<div th:if="${#fields.hasAnyErrors()}">
<p th:each="err : ${#fields.allErrors()}" th:text="${err}">...</p>
</div>
<input type="submit" value="See my history"/>
</form>
</div>
<div class="column">
<br>
<table>
<thead>
<tr>
<th class="tr-pageable"><p class="btn-sort" id="btn-sort-0">#</p></th>
<th class="tr-pageable"><p class="btn-sort activeButton" id="btn-sort-1">MessageId</p></th>
<th class="tr-pageable"><p class="btn-sort" id="btn-sort-2">TimeStamp</p></th>
<th class="tr-pageable"><p class="btn-sort" id="btn-sort-3">Action</p></th>
</tr>
</thead>
<tbody id="table-body">
</tbody>
</table>
<div class="container ">
<div id="pagination-wrapper"></div>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
<div id="foot"></div>
</div>
<hr>
<script>
$.get("https://raw.githubusercontent.com/Szakalakamaka/viewpresenter/master/src/main/resources/templates/navbar.html", function(data){
$("#header").html(data);
});
$.get("https://raw.githubusercontent.com/Szakalakamaka/viewpresenter/master/src/main/resources/templates/sidebar.html", function(data){
$("#sidebar").html(data);
});
$.get("https://raw.githubusercontent.com/Szakalakamaka/viewpresenter/master/src/main/resources/templates/footer.html", function(data){
$("#foot").html(data);
});
</script>
<script type="text/javascript" th:inline="javascript">
var listForPagination = /*[[${eventList}]]*/;
</script>
<script src="/js/etrackPaggination.js"></script>
</body>
</html>

View File

@@ -1,193 +0,0 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>R11 Tools: Mock</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,600" rel="stylesheet" type="text/css">
<link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css">
<link href="/css/styles.css" rel="stylesheet"/>
</head>
<body>
<hr>
<div id="container">
<div class="container">
<section class="page-section" id="main-section">
<div class="container">
<p>With this tool you can create mockups for http requests and use them for integration tests of
your system.
</p>
<div>
<br>
<p>You can test the mocked message using the url default values from the form will be used.</p>
<script>
var pubhost = location.hostname;
document.getElementById("pubhost").innerHTML = location.hostname;
</script>
<gen-link>http://<span id="pubhost">localhost</span>:8097/klaus/v1/get/[[${mockedMessageDto.clientUUID}]]/[[${mockedMessageDto.mockedResponseId}]]</gen-link>
<p>Use this link to get your message.</p>
<br>
<table>
<p>In order to change mockup response settings please fill the form below and save.</p>
<br>
<form action="#" th:action="@{/mock/__${mockedMessageDto.clientUUID}__}"
th:object="${mockedMessageDto}" method="post">
<input type="text" th:field="*{clientUUID}" hidden/>
<tr>
<td>Media type:</td>
<td>
<label>
<select id="media-type" th:field="*{mediaType}">
<option value="application/xml">application/xml</option>
<option value="application/json">application/json</option>
<option value="text/xml">text/xml</option>
</select>
<span class="hint">Standard that indicates the nature and format of a document, file, or assortment of bytes.</span>
</label>
</td>
<td>
</td>
</tr>
<tr>
<td>Mocked response body:</td>
<!-- rows="4" cols="30"-->
<td><label>
<textarea id="message-body" th:field="*{messageBody}" placeholder="Your message body"></textarea>
<span class="hint">The resource data that will be requested by the client.</span>
</label>
</td>
<td th:if="${#fields.hasErrors('messageBody')}" th:errors="*{messageBody}">
Body Error
</td>
</tr>
<tr>
<td>Mocked response http code status:</td>
<td>
<label>
<input type="text" th:field="*{httpStatus}" placeholder="200">
<span class="hint">Status codes are issued by a server in response to a client's request made to the server.</span>
</label>
</td>
<td th:if="${#fields.hasErrors('httpStatus')}" th:errors="*{httpStatus}">
HttpStatus Error
</td>
</tr>
<tr>
<td><br></td>
<td><br></td>
</tr>
<tr>
<td>Header name</td>
<td>Header value</td>
</tr>
<tr>
<label>
<td><input type="text" name="headerKey" id="headerKey"
placeholder="myHeaderKey"/>
<span class="hint"></span>
</label>
</td>
<td>
<label>
<input type="text" name="headerValue" id="headerValue"
placeholder="myHeaderValue"/>
<span class="hint">HTTP headers let the client and the server pass additional information with an HTTP request or response.</span>
<input type="image" name="addHeader" src="/img/icons8-plus-48.png"
style="width: 20px;"/>
</label>
</td>
</tr>
<tr th:each="entry, stats : *{httpHeaders}">
<td bgcolor="#b3ffff"><input type="text" name="value" th:value="${entry.key}"
disabled="disabled"/></td>
<td>
&#9;
<input type="text" name="value"
th:field="*{httpHeaders[__${entry.key}__]}"/>
<button type="submit" name="removeHeader" th:value="${entry.key}">
<img src="/img/icons8-cancel-64.png" style="width: 20px;"/>
</button>
</td>
</tr>
<tr>
<td>Mocked response id:</td>
<td><label><input type="text" th:field="*{mockedResponseId}"
th:value="*{mockedResponseId}"/>
<span class="hint">Unique identifier for the mocked message.</span>
</label>
</td>
<td th:if="${#fields.hasErrors('mockedResponseId')}"
th:errors="*{mockedResponseId}">Id
Error
</td>
</tr>
<tr>
<td><input type="submit" value="Save settings"/></td>
<td>
<button type="submit" name="newMessage" th:value="*{clientUUID}">
<img src="/img/update-button.png" style="width: 20px;"/>
</button>
</td>
</tr>
</form>
</table>
<p th:if="${mockSaved}">Mock has been saved</p>
<table>
<tr>
<td>
<form action="#" th:action="@{/etrack/__${mockedMessageDto.clientUUID}__}"
th:object="${mockedMessageDto}"
method="get">
<p><input type="submit" value="History"/></p>
</form>
</td>
<td>
<button class="btn-list" name="Messages List" id="btn-list-1">Messages List
</button>
</td>
</tr>
</table>
</div>
</div>
</section>
<hr>
</div>
<div>
<div id="list-wrapper" style="display: none;">
<p>Here you can see the interactive list of all your mocked messages. You can call all of them. Use
the buttons to sort the list and also update or delete messages.
</p>
<form action="#" th:action="@{/mock/__${mockedMessageDto.clientUUID}__}"
th:object="${mockedMessageDto}" method="post">
<table>
<thead>
<tr>
<th class="tr-pageable">
<p class="btn-sort" id="btn-sort-0">#</p>
</th>
<th class="tr-pageable">
<p class="btn-sort activeButton" id="btn-sort-1">MessageId</p>
</th>
<th class="tr-pageable">
<p class="btn-sort" id="btn-sort-2">Media Type</p>
</th>
<th class="tr-pageable">
<p class="btn-sort" id="btn-sort-3">Http Status</p>
</th>
</tr>
</thead>
<input type="text" th:field="*{clientUUID}" hidden/>
<tbody id="table-body"></tbody>
</table>
</form>
<div class="container ">
<div id="pagination-wrapper"></div>
</div>
</div>
</div>
<hr>
</div>
<script src="/js/paggination.js"></script>
</body>
</html>

View File

@@ -1,5 +1,5 @@
#container { #container {
width: 1330px; width: 1400px;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
min-height: 1900px; min-height: 1900px;
@@ -235,6 +235,13 @@
} }
#mockIntroTip {
margin-top: 10px;
text-align: justify;
padding: 5px;
margin-bottom: 10px;
}
.btn-function-table { .btn-function-table {
font-size: 24px; font-size: 24px;
font-weight: 700; font-weight: 700;
@@ -259,3 +266,4 @@
color:indianred; color:indianred;
} }

View File

@@ -0,0 +1,49 @@
p#tooltipText {
/* /* padding: 20px; */
width: 200px;
height: 150px;
}
div#tooltip {
border-radius: 15px;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
margin-top: 20px;
border: 2px solid rgba(155, 165, 160, 0.507);
width: 350px;
/* width: 70%; */
/* background-color: rgb(68, 158, 116); */
min-height: 591px;
}
.collapsible {
/*background-color: rgba(155, 165, 160, 0.507);*/
color: rgb(44, 44, 44);
cursor: pointer;
padding: 5px;
width: 100%;
/*border: none;*/
/*outline: none;*/
/*max-height: 0;*/
/*overflow: hidden;*/
/*transition: max-height 0.2s ease-out;*/
}
/*.active, .collapsibleActive:hover {*/
/* background-color: rgb(85, 85, 85);*/
/*}*/
.collapsibleData {
padding: 0 18px;
background-color: #f1f1f1;
}
.fixed {
position: fixed;
/*top: 50%;*/
left: 50%;
margin-top: 150px;
margin-left: 300px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -3,10 +3,11 @@ var clientUUID;
var json; var json;
var jsonIndex = 0; var jsonIndex = 0;
var htable_row = 0; var htable_row = 0;
var host = getDomain();
const C_UUID = 'mock-uuid'; const C_UUID = 'mock-uuid';
function getData(){ function getData(){
loadCookies(); loadCookies();
$.getJSON('http://localhost:8097/mock/json/'+clientUUID, function(data) { $.getJSON(host + '/mock/json/'+clientUUID, function(data) {
json = data; json = data;
clientUUID = json[jsonIndex].clientUUID; clientUUID = json[jsonIndex].clientUUID;
setCookies(); setCookies();
@@ -16,6 +17,13 @@ function getData(){
}); });
} }
function getDomain(){
var url = window.location.href;
var arr = url.split("/");
var result = arr[0] + "//" + arr[2];
return result;
}
function refreshData(){ function refreshData(){
fillMessageList(); fillMessageList();
console.log("List initiated"); console.log("List initiated");
@@ -50,7 +58,7 @@ function getCookie(cname) {
function updateData(){ function updateData(){
var updatedJson = generateJson(); var updatedJson = generateJson();
var request = $.ajax({ var request = $.ajax({
url: 'http://localhost:8097/mock/json', url: host + '/mock/json',
type: 'PUT', type: 'PUT',
data: JSON.stringify(updatedJson, null, 2), data: JSON.stringify(updatedJson, null, 2),
dataType: "json", dataType: "json",
@@ -64,7 +72,7 @@ function updateData(){
function addMessage(){ function addMessage(){
var request = $.ajax({ var request = $.ajax({
url: 'http://localhost:8097/mock/json/'+clientUUID, url: host + '/mock/json/'+clientUUID,
type: 'POST', type: 'POST',
}); });
request.done(function () { request.done(function () {
@@ -75,7 +83,7 @@ function addMessage(){
function removeTile(id){ function removeTile(id){
var jsonObject = findJsonById(id); var jsonObject = findJsonById(id);
var request = $.ajax({ var request = $.ajax({
url: 'http://localhost:8097/mock/json/'+clientUUID + '/' + id, url: host + '/mock/json/'+clientUUID + '/' + id,
type: 'DELETE', type: 'DELETE',
}); });
request.done(function () { request.done(function () {
@@ -110,7 +118,7 @@ function fillStaticFields(uuid, id, mediaType, body, httpStatus){
} }
function createLink(uuid, id){ function createLink(uuid, id){
var link = 'http://localhost:8097/klaus/v1/get/'+uuid+'/'+id; var link = host + '/klaus/v1/get/'+uuid+'/'+id;
return link; return link;
} }

File diff suppressed because one or more lines are too long

View File

@@ -51,24 +51,35 @@ function showHeaders(){
$('#headersTab').off('click'); $('#headersTab').off('click');
} }
function hidTip(){$('#toolTipContent').css('display', 'none');} function hidTip(){
// $('#toolTipContent').css('display', 'none');
}
function showTip(){$('#toolTipContent').css('display', 'block');} function showTip(){
// $('#toolTipContent').css('display', 'block');
}
$('#messageLink').mouseover(function(){$('#messageLinkTip').css('display', 'block'); showTip();}); $('#messageLink').mouseover(function(){$('#messageLinkTip').css('display', 'block'); showTip();});
$('#messageLink').mouseleave(function(){$('#messageLinkTip').css('display', 'none'); hidTip();}); $('#messageLink').mouseleave(function(){$('#messageLinkTip').css('display', 'none'); hidTip();});
$('#httpStatus').mouseover(function(){$('#httpStatusTip').css('display', 'block'); showTip();}); $('#httpStatus').mouseover(function(){$('#httpStatusTip').css('display', 'block'); showTip();});
$('#httpStatus').mouseleave(function(){$('#httpStatusTip').css('display', 'none'); hidTip();}); $('#httpStatus').mouseleave(function(){$('#httpStatusTip').css('display', 'none'); hidTip();});
$('#typeSelector').mouseover(function(){$('#typeSelectorTip').css('display', 'block'); showTip();}); $('#typeSelector').mouseover(function(){$('#typeSelectorTip').css('display', 'block'); showTip();});
$('#typeSelector').mouseleave(function(){$('#typeSelectorTip').css('display', 'none'); hidTip();}); $('#typeSelector').mouseleave(function(){$('#typeSelectorTip').css('display', 'none'); hidTip();});
$('#bodyEditor').mouseover(function(){$('#bodyEditorTip').css('display', 'block'); showTip();}); $('#bodyEditor').mouseover(function(){$('#bodyEditorTip').css('display', 'block'); showTip();});
$('#bodyEditor').mouseleave(function(){$('#bodyEditorTip').css('display', 'none'); hidTip();}); $('#bodyEditor').mouseleave(function(){$('#bodyEditorTip').css('display', 'none'); hidTip();});
$('#headersTab').mouseover(function(){$('#headersTabTip').css('display', 'block'); showTip();}); $('#headersTab').mouseover(function(){$('#headersTabTip').css('display', 'block'); showTip();});
$('#headersTab').mouseleave(function(){$('#headersTabTip').css('display', 'none'); hidTip();}); $('#headersTab').mouseleave(function(){$('#headersTabTip').css('display', 'none'); hidTip();});
$('#historyTab').mouseover(function(){$('#historyTabTip').css('display', 'block'); showTip();}); $('#historyTab').mouseover(function(){$('#historyTabTip').css('display', 'block'); showTip();});
$('#historyTab').mouseleave(function(){$('#historyTabTip').css('display', 'none'); hidTip();}); $('#historyTab').mouseleave(function(){$('#historyTabTip').css('display', 'none'); hidTip();});
$('#headerKeyInput').mouseover(function(){$('#newHeaderTip').css('display', 'block'); showTip();}); $('#headerKeyInput').mouseover(function(){$('#newHeaderTip').css('display', 'block'); showTip();});
$('#headerKeyInput').mouseleave(function(){$('#newHeaderTip').css('display', 'none'); hidTip();}); $('#headerKeyInput').mouseleave(function(){$('#newHeaderTip').css('display', 'none'); hidTip();});
$('#headerValueInput').mouseover(function(){$('#newHeaderTip').css('display', 'block'); showTip();}); $('#headerValueInput').mouseover(function(){$('#newHeaderTip').css('display', 'block'); showTip();});
$('#headerValueInput').mouseleave(function(){$('#newHeaderTip').css('display', 'none'); hidTip();}); $('#headerValueInput').mouseleave(function(){$('#newHeaderTip').css('display', 'none'); hidTip();});

View File

@@ -1,36 +0,0 @@
[{
"clientUUID": "dfdea9a4-03e4-4157-abda-3723f998b6ee",
"mockedResponseId": 3,
"mediaType": "application/xml",
"messageBody": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<note>\n <to>Tove</to>\n <from>Jani</from>\n <heading>Reminder</heading>\n <body>Don't forget me this weekend!</body>\n</note>",
"httpHeaders": {"Connection": "keep-alive", "Keep-Alive": "timeout=60", "Date": "2021-02-08T11:36:43.375639"},
"httpStatus": 200
}, {
"clientUUID": "dfdea9a4-03e4-4157-abda-3723f998b6ee",
"mockedResponseId": 4,
"mediaType": "application/xml",
"messageBody": "Hello world!",
"httpHeaders": {"Keep-Alive": "timeout=60", "Connection": "keep-alive", "Date": "2021-02-08T11:37:00.644399"},
"httpStatus": 200
}, {
"clientUUID": "dfdea9a4-03e4-4157-abda-3723f998b6ee",
"mockedResponseId": 1,
"mediaType": "application/xml",
"messageBody": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<note>\n <to>Tove</to>\n <from>Jani</from>\n <heading>Reminder</heading>\n <body>Don't forget me this weekend!</body>\n</note>",
"httpHeaders": {"Connection": "keep-alive", "Keep-Alive": "timeout=60", "Date": "2021-02-08T11:36:39.348495"},
"httpStatus": 200
}, {
"clientUUID": "dfdea9a4-03e4-4157-abda-3723f998b6ee",
"mockedResponseId": 2,
"mediaType": "application/xml",
"messageBody": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<note>\n <to>Tove</to>\n <from>Jani</from>\n <heading>Reminder</heading>\n <body>Don't forget me this weekend!</body>\n</note>",
"httpHeaders": {"Keep-Alive": "timeout=60", "Connection": "keep-alive", "Date": "2021-02-08T11:36:41.569362"},
"httpStatus": 200
}, {
"clientUUID": "dfdea9a4-03e4-4157-abda-3723f998b6ee",
"mockedResponseId": 5,
"mediaType": "application/xml",
"messageBody": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<note>\n <to>Tove</to>\n <from>Jani</from>\n <heading>Reminder</heading>\n <body>Don't forget me this weekend!</body>\n</note>",
"httpHeaders": {"Keep-Alive": "timeout=60", "Connection": "keep-alive", "Date": "2021-02-08T11:37:28.249797"},
"httpStatus": 200
}]

View File

@@ -4,7 +4,7 @@
<title>R11 MockedServices</title> <title>R11 MockedServices</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" href="/css/main.css" type="text/css"> <link rel="stylesheet" href="/css/main.css" type="text/css">
<!-- <link rel="stylesheet" href="/css/wojtas.css" type="text/css">--> <link rel="stylesheet" href="/css/tooltip.css" type="text/css">
<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">
@@ -101,34 +101,47 @@
<div style="clear: both;"></div> <div style="clear: both;"></div>
</div> </div>
</div> </div>
<div id="tooltip"> <div id="tooltip" class="fixed">
<div id="toolTipContent" style="display: none;"> <div id="mockIntroTip">
<div id="toolHeader"><h2>Tip:</h2></div> <h2>What's mock service?</h2>
<div> <p>It's super simple! Need data as response from the server? Mock your api in just a few clicks.</p>
<p>Hover over an item to see description!</p>
<br>
<h2>Help:</h2>
</div>
<!-- <div id="toolTipContent" style="display: none;">-->
<!-- <div>-->
<div id="messageLinkTip" class="collapsible" style="display: none;"> <div id="messageLinkTip" class="collapsible" style="display: none;">
<!--style="display: none;"--> <!--style="display: none;"-->
<h4>The link</h4>
<p>It's url where you need send your request</p> <p>It's url where you need send your request</p>
</div> </div>
<div id="httpStatusTip" class="collapsible" style="display: none;"> <div id="httpStatusTip" class="collapsible" style="display: none;">
<h4>Http status</h4>
<p>Set http status for server response. 200 OK is default.</p> <p>Set http status for server response. 200 OK is default.</p>
</div> </div>
<div id="typeSelectorTip" class="collapsible" style="display: none;"> <div id="typeSelectorTip" class="collapsible" style="display: none;">
<h4>Content type</h4>
<p>Select content type of body. Set plain text if data has no format.</p> <p>Select content type of body. Set plain text if data has no format.</p>
</div> </div>
<div id="bodyEditorTip" class="collapsible" style="display: none;"> <div id="bodyEditorTip" class="collapsible" style="display: none;">
<h4>Body</h4>
<p>Text placed in this field will be displayed as response body</p> <p>Text placed in this field will be displayed as response body</p>
</div> </div>
<div id="headersTabTip" class="collapsible" style="display: none;"> <div id="headersTabTip" class="collapsible" style="display: none;">
<h4>Headers</h4>
<p>Set headers for your messages.</p> <p>Set headers for your messages.</p>
</div> </div>
<div id="historyTabTip" class="collapsible" style="display: none;"> <div id="historyTabTip" class="collapsible" style="display: none;">
<h4>History</h4>
<p>Check history of this message</p> <p>Check history of this message</p>
</div> </div>
<div id="newHeaderTip" class="collapsible" style="display: none;"> <div id="newHeaderTip" class="collapsible" style="display: none;">
<h4>Next header value</h4>
<p>Type values and press enter to add new header.</p> <p>Type values and press enter to add new header.</p>
</div> </div>
</div> <!-- </div>-->
</div> <!-- </div>-->
</div> </div>
<div style="clear:both;"></div> <div style="clear:both;"></div>

View File

@@ -1,12 +0,0 @@
package com.release11.klaus;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class KlausApplicationTests {
// @Test
// void contextLoads() {
// }
}

View File

@@ -1,12 +0,0 @@
package com.release11.klaus.config;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class RedisConfigTest {
// @Test
// void jedisPool() {
//
// }
}

View File

@@ -1,77 +0,0 @@
package com.release11.klaus.controller;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
class KlausControllerTest {
// @Mock
// KlausService klausService;
//
// @InjectMocks
// KlausController klausController;
//
// ObjectMapper objectMapper;
// MockMvc mockMvc;
// UUID uuid;
// MockedMessageDto mockedMessageDto;
// List<MockedMessageDto> mockedMessageDtoList = new ArrayList<>();
//
// @BeforeEach
// void setUp() {
// uuid = UUID.randomUUID();
// mockedMessageDto = MockedMessageDto.builder()
// .clientUUID(uuid)
// .mockedResponseId(323)
// .mediaType(MediaType.APPLICATION_JSON.toString())
// .messageBody("my message body")
// .httpHeaders(new HashMap<>())
// .httpStatus(200)
// .build();
// mockedMessageDtoList.add(mockedMessageDto);
//
// mockMvc = MockMvcBuilders.standaloneSetup(klausController).build();
//
// objectMapper = new ObjectMapper();
// }
//
// @Test
// void deleteMockedResponse() throws Exception {
// mockMvc.perform(delete("/klaus/v1/delete/" + uuid + "/" + mockedMessageDto.getMockedResponseId()))
// .andExpect(status().isOk());
//
// verify(klausService).deleteMockedResponse(any(), anyInt());
// }
//
//
//
// @Test
// void getAllMockedResponses() throws Exception {
// when(klausService.getAllMockedResponses(uuid))
// .thenReturn(mockedMessageDtoList);
//
// mockMvc.perform(get("/klaus/v1/getAll/" + uuid)
// .accept(MediaType.APPLICATION_JSON))
// .andExpect(status().isOk());
//
// verify(klausService).getAllMockedResponses(any());
// }
//
// @Test
// void testGetMockedResponse() throws Exception {
// when(klausService.getMockedResponse(uuid, mockedMessageDto.getMockedResponseId()))
// .thenReturn(mockedMessageDto);
//
// mockMvc.perform(get("/klaus/v1/get/" + uuid + "/" + mockedMessageDto.getMockedResponseId())
// .accept(MediaType.APPLICATION_JSON))
// .andExpect(status().isOk());
//
// verify(klausService).getMockedResponse(any(), anyInt());
// }
//
// @AfterEach
// void tearDown() {
// reset(klausService);
// }
}

View File

@@ -1,212 +0,0 @@
//package com.release11.klaus.controller;
//
//import com.release11.klaus.model.MockedMessageDto;
//import com.release11.klaus.service.KlausService;
//import org.junit.jupiter.api.AfterEach;
//import org.junit.jupiter.api.BeforeEach;
//import org.junit.jupiter.api.Test;
//import org.junit.jupiter.api.extension.ExtendWith;
//import org.mockito.InjectMocks;
//import org.mockito.Mock;
//import org.mockito.junit.jupiter.MockitoExtension;
//import org.springframework.http.MediaType;
//import org.springframework.test.web.servlet.MockMvc;
//import org.springframework.test.web.servlet.setup.MockMvcBuilders;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.UUID;
//
//import static org.mockito.ArgumentMatchers.any;
//import static org.mockito.Mockito.*;
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
//
//@ExtendWith(MockitoExtension.class)
//class KlausMvcControllerTest {
//
// @Mock
// KlausService klausService;
//
// @InjectMocks
// KlausMvcController klausMvcController;
//
// MockMvc mockMvc;
// UUID uuid;
// MockedMessageDto mockedMessageDto;
// List<MockedMessageDto> mockedMessageDtoList = new ArrayList<>();
//
// @BeforeEach
// void beforeEach() {
// uuid = UUID.randomUUID();
// mockedMessageDto = MockedMessageDto.builder()
// .clientUUID(uuid)
// .mockedResponseId(323)
// .mediaType(MediaType.APPLICATION_JSON.toString())
// .messageBody("my message body")
// .httpHeaders(new HashMap<>())
// .httpStatus(200)
// .build();
// mockedMessageDtoList.add(mockedMessageDto);
//
// mockMvc = MockMvcBuilders.standaloneSetup(klausMvcController).build();
// }
//
// @Test
// void showHome() throws Exception {
// when(klausService.getAllMockedResponses(any()))
// .thenReturn(mockedMessageDtoList);
//
// mockMvc.perform(get("/mock/" + uuid))
// .andExpect(status().isOk())
// .andExpect(view().name("mock"))
// .andExpect(model().attributeExists("mockedMessageDtoList"));
//
// verify(klausService).getAllMockedResponses(any());
// }
//
// @Test
// void showHomePost() throws Exception {
// mockMvc.perform(post("/mock/e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
// .param("clientUUID", "e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
// .param("mockedResponseId", "323")
// .param("mediaType", "application/json")
// .param("messageBody", "my message body")
// .param("httpStatus", "200"))
// .andExpect(status().isOk())
// .andExpect(model().attributeExists("mockedMessageDtoList"))
// .andExpect(view().name("mock"));
//
// verify(klausService).setMockedResponse(any());
// }
//
// @Test
// void showHomePostNotValid() throws Exception {
//// mockMvc.perform(post("/mock/e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
//// .param("clientUUID", "e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
//// .param("mockedResponseId", "aaaa")
//// .param("mediaType", "application/json")
//// .param("messageBody", "my message body")
//// .param("httpStatus", "200"))
//// .andExpect(status().isOk())
//// .andExpect(model().attributeHasErrors("mockedMessageDto"))
//// .andExpect(model().attributeHasFieldErrors("mockedMessageDto", "mockedResponseId"))
//// .andExpect(view().name("mock"));
// }
//
// @Test
// void newMessage() throws Exception {
// when(klausService.getAllMockedResponses(any()))
// .thenReturn(mockedMessageDtoList);
//
// mockMvc.perform(post("/mock/e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
// .param("newMessage", "newMessage")
// .param("clientUUID", "e9dc0ad9-acd2-4699-99f7-368d53d7afd6"))
// .andExpect(status().isOk())
// .andExpect(model().attributeExists("mockedMessageDtoList"))
// .andExpect(view().name("mock"));
//
// verify(klausService).getAllMockedResponses(any());
// }
//
// @Test
// void showGetMockedResponse() throws Exception {
// when(klausService.getMockedResponse(any(), anyInt()))
// .thenReturn(mockedMessageDto);
//
// mockMvc.perform(get("/mock/getMockedResponse")
// .param("clientUUID", "e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
// .param("mockedResponseId", "323")
// .param("mediaType", "application/json")
// .param("messageBody", "my message body")
// .param("httpStatus", "200"))
// .andExpect(status().isOk());
//
// verify(klausService).getMockedResponse(any(), anyInt());
// }
//
// @Test
// void addHeader() throws Exception {
//// when(klausService.getAllMockedResponses(any()))
//// .thenReturn(mockedMessageDtoList);
////
//// mockMvc.perform(post("/mock/e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
//// .param("addHeader", "addHeader")
//// .param("headerKey", "myKey")
//// .param("headerValue", "myValue")
//// .param("clientUUID", "e9dc0ad9-acd2-4699-99f7-368d53d7afd6"))
//// .andExpect(status().isOk())
//// .andExpect(view().name("mock"))
//// .andExpect(model().attributeExists("mockedMessageDtoList"));
////
//// verify(klausService, times(0)).getAllMockedResponses(any());
// }
//
// @Test
// void removeHeader() throws Exception {
//// when(klausService.getAllMockedResponses(any()))
//// .thenReturn(mockedMessageDtoList);
////
//// mockMvc.perform(post("/mock/e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
//// .param("removeHeader", "removeHeader")
//// .param("clientUUID", "e9dc0ad9-acd2-4699-99f7-368d53d7afd6"))
//// .andExpect(status().isOk())
//// .andExpect(view().name("mock"))
//// .andExpect(model().attributeExists("mockedMessageDtoList"));
////
//// verify(klausService, times(0)).getAllMockedResponses(any());
// }
//
// @Test
// void updateMessage() throws Exception {
// when(klausService.getAllMockedResponses(any()))
// .thenReturn(mockedMessageDtoList);
// when(klausService.getMockedResponse(any(), anyInt())).
// thenReturn(mockedMessageDto);
//
// mockMvc.perform(post("/mock/e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
// .param("updateMessage", "323"))
// .andExpect(status().isOk())
// .andExpect(view().name("mock"))
// .andExpect(model().attributeExists("canTest"))
// .andExpect(model().attributeExists("mockedMessageDtoList"));
//
// verify(klausService, times(0)).getAllMockedResponses(any());
// verify(klausService).getMockedResponse(any(), anyInt());
// }
//
// @Test
// void removeMessage() throws Exception {
// when(klausService.getAllMockedResponses(any()))
// .thenReturn(mockedMessageDtoList);
//
// mockMvc.perform(post("/mock/e9dc0ad9-acd2-4699-99f7-368d53d7afd6")
// .param("removeMessage", "323"))
// .andExpect(status().isOk())
// .andExpect(view().name("mock"))
// .andExpect(model().attributeDoesNotExist("canTest"))
// .andExpect(model().attributeExists("mockedMessageDtoList"));
//
// verify(klausService).getAllMockedResponses(any());
// verify(klausService).deleteMockedResponse(any(), anyInt());
// }
//
// @Test
// void localhost() {
// assert klausMvcController.localhost() != null;
// }
//
// @Test
// void clientUUID() {
// assert klausMvcController.clientUUID() != null;
// }
//
//
// @AfterEach
// void afterEach() {
// reset(klausService);
// }
//
//}

View File

@@ -1,19 +0,0 @@
package com.release11.klaus.repository;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class EventRepositoryImplTest {
// @BeforeEach
// void setUp() {
// }
//
// @Test
// void findEvents() {
// }
//
// @AfterEach
// void tearDown() {
// }
}

View File

@@ -1,117 +0,0 @@
//package com.release11.klaus.service;
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.release11.klaus.mappers.MockedMessageMapper;
//import com.release11.klaus.mappers.MockedMessageMapperImpl;
//import com.release11.klaus.model.MockedMessage;
//import com.release11.klaus.model.MockedMessageDto;
//import com.release11.klaus.repository.MockedResponseRepository;
//import org.junit.jupiter.api.AfterEach;
//import org.junit.jupiter.api.BeforeEach;
//import org.junit.jupiter.api.Test;
//import org.junit.runner.RunWith;
//import org.mockito.InjectMocks;
//import org.mockito.Mock;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import javax.ws.rs.core.MediaType;
//import java.util.*;
//
//import static org.assertj.core.api.Assertions.assertThat;
//import static org.mockito.ArgumentMatchers.any;
//import static org.mockito.Mockito.*;
//
//@RunWith(SpringRunner.class)
//@SpringBootTest(classes = {MockedMessageMapperImpl.class})
//class KlausServiceImplTest {
//
// @Mock
// MockedResponseRepository mockedResponseRepository;
//
// @Mock private MockedMessageMapper mockedMessageMapper;
//
// @InjectMocks
// KlausServiceImpl klausService;
//
// UUID uuid;
// MockedMessage mockedMessage1;
// Map<String, String> httpHeaders;
// MockedMessageDto mockedMessageDto1;
// MockedMessageDto mockedMessageDto2;
// MockedMessageDto mockedMessageDto3;
// List<MockedMessage> mockedMessageList = new ArrayList<>();
//
// @BeforeEach
// void setUp() {
// uuid = UUID.randomUUID();
// httpHeaders = new HashMap<>();
// mockedMessageDto1 = MockedMessageDto.builder()
// .clientUUID(uuid)
// .mockedResponseId(323)
// .mediaType(MediaType.APPLICATION_JSON)
// .messageBody("it's okey to be gey")
// .httpHeaders(httpHeaders)
// .httpStatus(200)
// .build();
//
// mockedMessageDto2 = MockedMessageDto.builder()
// .clientUUID(uuid)
// .mockedResponseId(3123)
// .mediaType(MediaType.APPLICATION_JSON)
// .messageBody("some random message")
// .httpHeaders(httpHeaders)
// .httpStatus(404)
// .build();
//
// mockedMessageDto3 = MockedMessageDto.builder()
// .clientUUID(uuid)
// .mockedResponseId(3233)
// .mediaType(MediaType.APPLICATION_XML)
// .messageBody("loooking good")
// .httpHeaders(httpHeaders)
// .httpStatus(205)
// .build();
//
// mockedMessage1 = new MockedMessage();
// mockedMessageList.add(mockedMessage1);
// mockedMessageList.add(mockedMessage1);
// mockedMessageList.add(mockedMessage1);
// }
//
// @Test
// void deleteMockedResponse() {
// klausService.deleteMockedResponse(uuid, 323);
// verify(mockedResponseRepository).deleteById(any());
// }
//
// @Test
// void getAllMockedResponses() {
//// when(mockedResponseRepository.findAllByClientUUID(any()))
//// .thenReturn(mockedMessageList);
////
//// assertThat(klausService.getAllMockedResponses(uuid), hasSize(3));
//// verify(mockedResponseRepository).findAllByClientUUID(any());
// }
//
// @Test
// void getMockedResponse() throws JsonProcessingException {
// when(mockedResponseRepository.getByCompositePrimaryKey(any()))
// .thenReturn(mockedMessage1);
//
// assertThat(klausService.getMockedResponse(uuid, 323)).isNotNull();
// verify(mockedResponseRepository).findById(any());
// }
//
// @Test
// void setMockedResponse() {
//// klausService.setMockedResponse(mockedMessageDto1);
////
//// verify(mockedResponseRepository).save(any());
// }
//
//
// @AfterEach
// void tearDown() { reset(mockedResponseRepository); }
//
//}