1

Merge branch 'master' into details-templates

This commit is contained in:
kasch309
2020-03-16 14:53:19 +01:00
committed by GitHub
6 changed files with 87 additions and 50 deletions

View File

@ -79,6 +79,7 @@ dependencies {
} }
testImplementation 'org.springframework.security:spring-security-test' testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'com.tngtech.archunit:archunit-junit5:0.13.1' testImplementation 'com.tngtech.archunit:archunit-junit5:0.13.1'
implementation 'junit:junit:4.12'
} }
test { test {

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Getter
@ -23,6 +24,7 @@ import lombok.NoArgsConstructor;
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"), @JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"), @JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
}) })
@Setter
public class Event { public class Event {
Long event_id; Long event_id;
Long group_id; Long group_id;

View File

@ -26,8 +26,10 @@
</nav> </nav>
</header> </header>
<main th:fragment="bodycontent"> <main th:fragment="bodycontent">
<h1>Gruppenerstellung</h1>
<div class="container-fluid"> <div class="container-fluid">
<div class="row">
<div class="col-10">
<h1>Gruppenerstellung</h1>
<form method="post" action="/gruppen2/createGroup"> <form method="post" action="/gruppen2/createGroup">
<div class="shadow p-2" style=" border: 10px solid aliceblue; background: aliceblue"> <div class="shadow p-2" style=" border: 10px solid aliceblue; background: aliceblue">
<div class="form-group"> <div class="form-group">
@ -58,6 +60,8 @@
</div> </div>
</form> </form>
</div> </div>
</div>
</div>
</main> </main>
</body> </body>
</html> </html>

View File

@ -31,7 +31,7 @@
<h1>Meine Gruppen</h1> <h1>Meine Gruppen</h1>
<form action="/" method="get"> <form action="/" method="get">
<div th:each="gruppe: ${gruppen}"> <div th:each="gruppe: ${gruppen}">
<div style="border: 10px solid aliceblue; background: aliceblue"> <div class="shadow" style="border: 10px solid aliceblue; background: aliceblue">
<h3> <h3>
<a th:href="@{/gruppen2/details(id=${gruppe.getId()})}" style="color: dodgerblue; font-weight: bold" th:text="${gruppe.getTitle()}"></a> <a th:href="@{/gruppen2/details(id=${gruppe.getId()})}" style="color: dodgerblue; font-weight: bold" th:text="${gruppe.getTitle()}"></a>
</h3> </h3>

View File

@ -27,16 +27,14 @@
<main th:fragment="bodycontent"> <main th:fragment="bodycontent">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-10">
<h1>Gruppensuche</h1> <h1>Gruppensuche</h1>
<div class="container-fluid">
<form action="/gruppen2/findGroup" method="get"> <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"> <div class="form-group">
<label for="suchleiste">Suchbegriff:</label> <label for="suchleiste">Suchbegriff:</label>
<input id="suchleiste" class="form-control" placeholder="z.B. Programmieren, Lerngruppe, ..." th:name="suchbegriff" type="text"> <input id="suchleiste" class="form-control" placeholder="z.B. Programmieren, Lerngruppe, ..." th:name="suchbegriff" type="text">
</div> </div>
<button type="submit" class="btn btn-primary" style="background: #52a1eb; border-style: none">Suchen</button>
</div>
</form> </form>
<br> <br>
<table class="table"> <table class="table">
@ -61,6 +59,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</main> </main>

View File

@ -8,15 +8,17 @@ import mops.gruppen2.domain.event.CreateGroupEvent;
import mops.gruppen2.repository.EventRepository; import mops.gruppen2.repository.EventRepository;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
class EventServiceTest { class EventServiceTest {
EventService eventService; EventService eventService;
EventRepository eventRepositoryMock = mock(EventRepository.class); EventRepository eventRepositoryMock = mock(EventRepository.class);
@ -41,6 +43,35 @@ class EventServiceTest {
assertEquals(eventDTO1.getGroup_id() + 1, eventService.checkGroup()); assertEquals(eventDTO1.getGroup_id() + 1, eventService.checkGroup());
} }
@Test
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 @Test
void getDTOOffentlichTest() { void getDTOOffentlichTest() {
CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "test", null, GroupType.LECTURE, Visibility.PUBLIC); CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "test", null, GroupType.LECTURE, Visibility.PUBLIC);