Introduced header table
This commit is contained in:
6
.idea/workspace.xml
generated
6
.idea/workspace.xml
generated
@@ -22,6 +22,10 @@
|
||||
<list default="true" id="458cde88-df3d-44bc-9d57-a33823e2f1a6" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/resources/static/css/main.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/static/css/main.css" 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/controller/KlausMvcControllerTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/release11/klaus/controller/KlausMvcControllerTest.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/release11/klaus/service/EtrackServiceImplTest.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/release11/klaus/service/KlausServiceImplTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/release11/klaus/service/KlausServiceImplTest.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -300,7 +304,7 @@
|
||||
<workItem from="1610986449789" duration="3336000" />
|
||||
<workItem from="1611052879244" duration="4081000" />
|
||||
<workItem from="1611059169455" duration="5146000" />
|
||||
<workItem from="1611126794919" duration="2268000" />
|
||||
<workItem from="1611126794919" duration="6159000" />
|
||||
</task>
|
||||
<task id="LOCAL-00077" summary="testing jenkins docker">
|
||||
<created>1601453886631</created>
|
||||
|
||||
@@ -184,3 +184,8 @@
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
#headerTable {
|
||||
margin-top: 40px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,38 +23,62 @@
|
||||
|
||||
</div>
|
||||
<div id="itemData">
|
||||
<div id="itemDataHead" class="articleHead">Your message</div>
|
||||
<div id="link">
|
||||
<p class="label">Your link</p>
|
||||
<div id="messageLink" class="borderStyle">http://<span id="pubhost">localhost</span>:8097/klaus/v1/get/[[${mockedMessageDto.clientUUID}]]/[[${mockedMessageDto.mockedResponseId}]]</div>
|
||||
</div>
|
||||
<div id="msgBody">
|
||||
<div id="typeSelection">
|
||||
<p class="label">Content Type</p>
|
||||
<select id="typeSelector" class="fieldDefault borderStyle">
|
||||
<option value="text/xml">text/xml</option>
|
||||
<option value="application/json">application/json</option>
|
||||
</select>
|
||||
<form action="#" th:action="@{/mock/__${mockedMessageDto.clientUUID}__}"
|
||||
th:object="${mockedMessageDto}" method="post">
|
||||
<div id="itemDataHead" class="articleHead">Your message</div>
|
||||
<div id="link">
|
||||
<p class="label">Your link</p>
|
||||
<div id="messageLink" class="borderStyle">http://<span id="pubhost">localhost</span>:8097/klaus/v1/get/[[${mockedMessageDto.clientUUID}]]/[[${mockedMessageDto.mockedResponseId}]]</div>
|
||||
</div>
|
||||
<div id="bodyEdition">
|
||||
<p class="label">Body:</p>
|
||||
<textarea type="text" id="bodyEditor" class="fieldText borderStyle"><Hello>There!</Hello>
|
||||
</textarea>
|
||||
<div id="msgBody">
|
||||
<div id="typeSelection">
|
||||
|
||||
<p class="label">Content Type</p>
|
||||
<select id="typeSelector" th:field="*{mediaType}" class="fieldDefault borderStyle">
|
||||
<option value="application/xml">application/xml</option>
|
||||
<option value="application/json">application/json</option>
|
||||
<option value="text/xml">text/xml</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="bodyEdition">
|
||||
<p class="label">Body:</p>
|
||||
<textarea type="text" id="bodyEditor" th:field="*{messageBody}" class="fieldText borderStyle"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="optional">> show/hide advanced settings</div>
|
||||
<div id="advanced" style="display: none;">
|
||||
<div id="advancedMenu">
|
||||
<div class="advancedMenuTabSelected">Headers</div>
|
||||
<div class="advancedMenuTab">History</div>
|
||||
<div id="optional">> show/hide advanced settings</div>
|
||||
<div id="advanced" style="display: none;">
|
||||
<div id="advancedMenu">
|
||||
<div class="advancedMenuTabSelected">Headers</div>
|
||||
<div class="advancedMenuTab">History</div>
|
||||
</div>
|
||||
<div id="headers">
|
||||
<table id="headerTable">
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Value</td>
|
||||
</tr>
|
||||
<tr th:each="entry, stats : *{httpHeaders}">
|
||||
<td><input type="text" name="value" th:value="${entry.key}"
|
||||
disabled="disabled"/></td>
|
||||
<td>
|
||||
	
|
||||
<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>
|
||||
</table>
|
||||
</div>
|
||||
<div id="history" style="display:none;"></div>
|
||||
</div>
|
||||
<div id="headers" style="display:none;"></div>
|
||||
<div id="history" style="display:none;"></div>
|
||||
</div>
|
||||
<div id="functionBar">
|
||||
<button type="submit" class="functionBarButton">Save</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<div id="functionBar">
|
||||
<button type="submit" class="functionBarButton">Save</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
|
||||
|
||||
@@ -1,212 +1,212 @@
|
||||
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 {
|
||||
//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", "aaaa")
|
||||
// .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(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 {
|
||||
// .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("addHeader", "addHeader")
|
||||
// .param("headerKey", "myKey")
|
||||
// .param("headerValue", "myValue")
|
||||
// .param("clientUUID", "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, times(0)).getAllMockedResponses(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void removeHeader() throws Exception {
|
||||
// when(klausService.getAllMockedResponses(any()))
|
||||
// .thenReturn(mockedMessageDtoList);
|
||||
// verify(klausService).getAllMockedResponses(any());
|
||||
// verify(klausService).deleteMockedResponse(any(), anyInt());
|
||||
// }
|
||||
//
|
||||
// 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"));
|
||||
// @Test
|
||||
// void localhost() {
|
||||
// assert klausMvcController.localhost() != null;
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
|
||||
}
|
||||
// @Test
|
||||
// void clientUUID() {
|
||||
// assert klausMvcController.clientUUID() != null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @AfterEach
|
||||
// void afterEach() {
|
||||
// reset(klausService);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
//package com.release11.klaus.service;
|
||||
//
|
||||
//import com.release11.klaus.model.Event;
|
||||
//import com.release11.klaus.model.EventRequestDto;
|
||||
//import com.release11.klaus.repository.EventRepository;
|
||||
//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 java.time.LocalDateTime;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.UUID;
|
||||
//
|
||||
//import static org.hamcrest.Matchers.hasSize;
|
||||
//
|
||||
//import static org.hamcrest.MatcherAssert.assertThat;
|
||||
//import static org.mockito.ArgumentMatchers.any;
|
||||
//import static org.mockito.Mockito.*;
|
||||
//
|
||||
//@ExtendWith(MockitoExtension.class)
|
||||
//class EtrackServiceImplTest {
|
||||
//
|
||||
// @Mock
|
||||
// EventRepository eventRepository;
|
||||
//
|
||||
// @InjectMocks
|
||||
// EtrackServiceImpl etrackServiceImpl;
|
||||
//
|
||||
// EventRequestDto eventRequestDto;
|
||||
// List<Event> eventList = new ArrayList<>();
|
||||
//
|
||||
// @BeforeEach
|
||||
// void setUp() {
|
||||
// UUID uuid1 = UUID.randomUUID();
|
||||
// UUID uuid2 = UUID.randomUUID();
|
||||
//
|
||||
// Event event1 = Event.builder()
|
||||
// .dateTimeStamp(LocalDateTime.of(2018, 9, 9, 0, 0))
|
||||
// .interfaceName("getMockedResponse")
|
||||
// .clientUUID(String.valueOf(uuid1))
|
||||
// .messageId(323)
|
||||
// .thread("superThread")
|
||||
// .level("INFO")
|
||||
// .message("Log message!")
|
||||
// .build();
|
||||
//
|
||||
// Event event2 = Event.builder()
|
||||
// .dateTimeStamp(LocalDateTime.of(2020, 5, 2, 13, 22))
|
||||
// .interfaceName("getAllMockedResponse")
|
||||
// .clientUUID(String.valueOf(uuid2))
|
||||
// .thread("superThread")
|
||||
// .level("INFO")
|
||||
// .message("Log message!")
|
||||
// .build();
|
||||
//
|
||||
// Event event3 = Event.builder()
|
||||
// .dateTimeStamp(LocalDateTime.of(2020, 3, 2, 16, 12))
|
||||
// .interfaceName("setMockedResponse")
|
||||
// .clientUUID(String.valueOf(uuid1))
|
||||
// .messageId(323)
|
||||
// .thread("superThread")
|
||||
// .level("INFO")
|
||||
// .message("MockedResponse has been setup successfully!")
|
||||
// .build();
|
||||
//
|
||||
// Event event4 = Event.builder()
|
||||
// .dateTimeStamp(LocalDateTime.of(2020, 1, 2, 3,4,5))
|
||||
// .interfaceName("deleteMockedResponse")
|
||||
// .clientUUID(String.valueOf(uuid1))
|
||||
// .messageId(22)
|
||||
// .thread("superThread")
|
||||
// .level("INFO")
|
||||
// .message("Message 22 has been removed.")
|
||||
// .build();
|
||||
//
|
||||
// eventList.add(event1);
|
||||
// eventList.add(event2);
|
||||
// eventList.add(event3);
|
||||
// eventList.add(event4);
|
||||
//
|
||||
// eventRequestDto = EventRequestDto.builder()
|
||||
// .clientUUID(uuid1)
|
||||
// .localDateTimeTo(LocalDateTime.now())
|
||||
// .localDateTimeFrom(LocalDateTime.of(2010, 2, 3, 4, 5,6 ))
|
||||
// .mockedResponseId(323)
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// void getEventsByDateTimeAndBusinessKeys() {
|
||||
// when(eventRepository.findEvents(any(), any(), any()))
|
||||
// .thenReturn(eventList);
|
||||
//
|
||||
// List<Event> responseList = etrackServiceImpl.getEventsByDateTimeAndBusinessKeys(eventRequestDto);
|
||||
// assertThat(responseList, hasSize(4));
|
||||
//
|
||||
// verify(eventRepository).findEvents(any(), any(), any());
|
||||
// }
|
||||
//
|
||||
// @AfterEach
|
||||
// void tearDown() { reset(eventRepository); }
|
||||
//}
|
||||
@@ -1,117 +1,117 @@
|
||||
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);
|
||||
//package com.release11.klaus.service;
|
||||
//
|
||||
// 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);
|
||||
//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;
|
||||
//
|
||||
// verify(mockedResponseRepository).save(any());
|
||||
}
|
||||
|
||||
|
||||
@AfterEach
|
||||
void tearDown() { reset(mockedResponseRepository); }
|
||||
|
||||
}
|
||||
//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); }
|
||||
//
|
||||
//}
|
||||
Reference in New Issue
Block a user