Merge branch 'master' into details-templates
This commit is contained in:
@ -79,6 +79,7 @@ dependencies {
|
||||
}
|
||||
testImplementation 'org.springframework.security:spring-security-test'
|
||||
testImplementation 'com.tngtech.archunit:archunit-junit5:0.13.1'
|
||||
implementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@Getter
|
||||
@ -23,6 +24,7 @@ import lombok.NoArgsConstructor;
|
||||
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
|
||||
})
|
||||
@Setter
|
||||
public class Event {
|
||||
Long event_id;
|
||||
Long group_id;
|
||||
|
||||
@ -26,8 +26,10 @@
|
||||
</nav>
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
<h1>Gruppenerstellung</h1>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-10">
|
||||
<h1>Gruppenerstellung</h1>
|
||||
<form method="post" action="/gruppen2/createGroup">
|
||||
<div class="shadow p-2" style=" border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="form-group">
|
||||
@ -58,6 +60,8 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@ -26,12 +26,12 @@
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
<div class="container-fluid">
|
||||
<div class="row" >
|
||||
<div class="row">
|
||||
<div class="col-10">
|
||||
<h1>Meine Gruppen</h1>
|
||||
<form action="/" method="get">
|
||||
<div th:each="gruppe: ${gruppen}">
|
||||
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="shadow" style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<h3>
|
||||
<a th:href="@{/gruppen2/details(id=${gruppe.getId()})}" style="color: dodgerblue; font-weight: bold" th:text="${gruppe.getTitle()}"></a>
|
||||
</h3>
|
||||
@ -41,7 +41,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-2" >
|
||||
<div class="col-2">
|
||||
<div class="card" style="background: lightgrey">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title" th:text="${user.getUser_id()}" style="text-align: center">user_id</h2>
|
||||
|
||||
@ -27,16 +27,14 @@
|
||||
<main th:fragment="bodycontent">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-10">
|
||||
<h1>Gruppensuche</h1>
|
||||
<div class="container-fluid">
|
||||
<form action="/gruppen2/findGroup" method="get">
|
||||
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="shadow" style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="form-group">
|
||||
<label for="suchleiste">Suchbegriff:</label>
|
||||
<input id="suchleiste" class="form-control" placeholder="z.B. Programmieren, Lerngruppe, ..." th:name="suchbegriff" type="text">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" style="background: #52a1eb; border-style: none">Suchen</button>
|
||||
</div>
|
||||
</form>
|
||||
<br>
|
||||
<table class="table">
|
||||
@ -61,6 +59,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@ -8,26 +8,28 @@ import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.repository.EventRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
class EventServiceTest {
|
||||
EventService eventService;
|
||||
EventRepository eventRepositoryMock = mock(EventRepository.class);
|
||||
|
||||
@BeforeEach
|
||||
void setUp(){
|
||||
eventService = new EventService(mock(SerializationService.class),eventRepositoryMock);
|
||||
void setUp() {
|
||||
eventService = new EventService(mock(SerializationService.class), eventRepositoryMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkGroupTest(){
|
||||
void checkGroupTest() {
|
||||
EventDTO eventDTO = new EventDTO();
|
||||
EventDTO eventDTO1 = new EventDTO();
|
||||
eventDTO1.setGroup_id(1L);
|
||||
@ -38,19 +40,48 @@ class EventServiceTest {
|
||||
eventDTOS.add(eventDTO);
|
||||
eventDTOS.add(eventDTO1);
|
||||
when(eventRepositoryMock.findAll()).thenReturn(eventDTOS);
|
||||
assertEquals(eventDTO1.getGroup_id()+1, eventService.checkGroup());
|
||||
assertEquals(eventDTO1.getGroup_id() + 1, eventService.checkGroup());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDTOOffentlichTest(){
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "test", null , GroupType.LECTURE, Visibility.PUBLIC);
|
||||
void getMaxID() {
|
||||
when(eventRepositoryMock.getHighesEvent_ID()).thenReturn(42L);
|
||||
|
||||
assertEquals(eventService.getMaxEvent_id(), 42L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkGroupReturnNextValue() {
|
||||
List<EventDTO> eventDTOS = new ArrayList<>();
|
||||
EventDTO eventDTO1 = new EventDTO();
|
||||
EventDTO eventDTO2 = new EventDTO();
|
||||
eventDTO1.setGroup_id(1L);
|
||||
eventDTO2.setGroup_id(2L);
|
||||
eventDTOS.add(eventDTO1);
|
||||
eventDTOS.add(eventDTO2);
|
||||
when(eventRepositoryMock.findAll()).thenReturn(eventDTOS);
|
||||
|
||||
assertEquals(eventService.checkGroup(), 3L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkGroupReturnOneIfDBIsEmpty() {
|
||||
List<EventDTO> eventDTOS = new ArrayList<>();
|
||||
when(eventRepositoryMock.findAll()).thenReturn(eventDTOS);
|
||||
|
||||
assertEquals(eventService.checkGroup(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDTOOffentlichTest() {
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "test", null, GroupType.LECTURE, Visibility.PUBLIC);
|
||||
EventDTO eventDTO = eventService.getDTO(createGroupEvent);
|
||||
assertEquals(eventDTO.isVisibility(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDTOPrivatTest(){
|
||||
AddUserEvent addUserEvent = new AddUserEvent(eventService.checkGroup(), "test","franz","mueller","a@a");
|
||||
void getDTOPrivatTest() {
|
||||
AddUserEvent addUserEvent = new AddUserEvent(eventService.checkGroup(), "test", "franz", "mueller", "a@a");
|
||||
EventDTO eventDTO = eventService.getDTO(addUserEvent);
|
||||
assertEquals(eventDTO.isVisibility(), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user