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,37 +26,41 @@
</nav> </nav>
</header> </header>
<main th:fragment="bodycontent"> <main th:fragment="bodycontent">
<h1>Gruppenerstellung</h1>
<div class="container-fluid"> <div class="container-fluid">
<form method="post" action="/gruppen2/createGroup"> <div class="row">
<div class="shadow p-2" style=" border: 10px solid aliceblue; background: aliceblue"> <div class="col-10">
<div class="form-group"> <h1>Gruppenerstellung</h1>
<label for="titel">Titel</label> <form method="post" action="/gruppen2/createGroup">
<input type="text" class="form-control" id="titel" th:name="title" required> <div class="shadow p-2" style=" border: 10px solid aliceblue; background: aliceblue">
</div> <div class="form-group">
<div class="form-group"> <label for="titel">Titel</label>
<label for="beschreibung">Beschreibung</label> <input type="text" class="form-control" id="titel" th:name="title" required>
<textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3" required></textarea> </div>
</div> <div class="form-group">
<div class="custom-control custom-checkbox"> <label for="beschreibung">Beschreibung</label>
<input type="checkbox" id="visibility" class="custom-control-input" th:name="visibility"> <textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3" required></textarea>
<label class="custom-control-label" for="visibility">Private Gruppe</label> </div>
</div> <div class="custom-control custom-checkbox">
<div class="form-group"> <input type="checkbox" id="visibility" class="custom-control-input" th:name="visibility">
<label for="sel1"></label> <label class="custom-control-label" for="visibility">Private Gruppe</label>
<select class="form-control" id="sel1"> </div>
<option selected="true" disabled>--Bitte Veranstaltung auswählen--</option> <div class="form-group">
<option>1</option> <label for="sel1"></label>
<option>2</option> <select class="form-control" id="sel1">
<option>3</option> <option selected="true" disabled>--Bitte Veranstaltung auswählen--</option>
<option>4</option> <option>1</option>
</select> <option>2</option>
</div> <option>3</option>
<div class="form-group pt-4"> <option>4</option>
<button class="btn btn-primary" type="submit" style="background: #52a1eb; border-style: none">Erstellen</button> </select>
</div> </div>
<div class="form-group pt-4">
<button class="btn btn-primary" type="submit" style="background: #52a1eb; border-style: none">Erstellen</button>
</div>
</div>
</form>
</div> </div>
</form> </div>
</div> </div>
</main> </main>
</body> </body>

View File

@ -26,12 +26,12 @@
</header> </header>
<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"> <div class="col-10">
<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>
@ -41,7 +41,7 @@
</div> </div>
</form> </form>
</div> </div>
<div class="col-2" > <div class="col-2">
<div class="card" style="background: lightgrey"> <div class="card" style="background: lightgrey">
<div class="card-body"> <div class="card-body">
<h2 class="card-title" th:text="${user.getUser_id()}" style="text-align: center">user_id</h2> <h2 class="card-title" th:text="${user.getUser_id()}" style="text-align: center">user_id</h2>

View File

@ -27,15 +27,13 @@
<main th:fragment="bodycontent"> <main th:fragment="bodycontent">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<h1>Gruppensuche</h1> <div class="col-10">
<div class="container-fluid"> <h1>Gruppensuche</h1>
<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>
<button type="submit" class="btn btn-primary" style="background: #52a1eb; border-style: none">Suchen</button>
</div> </div>
</form> </form>
<br> <br>
@ -61,6 +59,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</main> </main>

View File

@ -8,26 +8,28 @@ 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);
@BeforeEach @BeforeEach
void setUp(){ void setUp() {
eventService = new EventService(mock(SerializationService.class),eventRepositoryMock); eventService = new EventService(mock(SerializationService.class), eventRepositoryMock);
} }
@Test @Test
void checkGroupTest(){ void checkGroupTest() {
EventDTO eventDTO = new EventDTO(); EventDTO eventDTO = new EventDTO();
EventDTO eventDTO1 = new EventDTO(); EventDTO eventDTO1 = new EventDTO();
eventDTO1.setGroup_id(1L); eventDTO1.setGroup_id(1L);
@ -38,19 +40,48 @@ class EventServiceTest {
eventDTOS.add(eventDTO); eventDTOS.add(eventDTO);
eventDTOS.add(eventDTO1); eventDTOS.add(eventDTO1);
when(eventRepositoryMock.findAll()).thenReturn(eventDTOS); when(eventRepositoryMock.findAll()).thenReturn(eventDTOS);
assertEquals(eventDTO1.getGroup_id()+1, eventService.checkGroup()); assertEquals(eventDTO1.getGroup_id() + 1, eventService.checkGroup());
} }
@Test @Test
void getDTOOffentlichTest(){ void getMaxID() {
CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "test", null , GroupType.LECTURE, Visibility.PUBLIC); 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); EventDTO eventDTO = eventService.getDTO(createGroupEvent);
assertEquals(eventDTO.isVisibility(), true); assertEquals(eventDTO.isVisibility(), true);
} }
@Test @Test
void getDTOPrivatTest(){ void getDTOPrivatTest() {
AddUserEvent addUserEvent = new AddUserEvent(eventService.checkGroup(), "test","franz","mueller","a@a"); AddUserEvent addUserEvent = new AddUserEvent(eventService.checkGroup(), "test", "franz", "mueller", "a@a");
EventDTO eventDTO = eventService.getDTO(addUserEvent); EventDTO eventDTO = eventService.getDTO(addUserEvent);
assertEquals(eventDTO.isVisibility(), false); assertEquals(eventDTO.isVisibility(), false);
} }