general style improvements + javadoc
This commit is contained in:
@ -229,13 +229,6 @@
|
|||||||
<property name="lineWrappingIndentation" value="8"/>
|
<property name="lineWrappingIndentation" value="8"/>
|
||||||
<property name="arrayInitIndent" value="4"/>
|
<property name="arrayInitIndent" value="4"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="AbbreviationAsWordInName">
|
|
||||||
<property name="ignoreFinal" value="false"/>
|
|
||||||
<property name="allowedAbbreviationLength" value="1"/>
|
|
||||||
<property name="tokens"
|
|
||||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
|
|
||||||
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/>
|
|
||||||
</module>
|
|
||||||
<module name="OverloadMethodsDeclarationOrder"/>
|
<module name="OverloadMethodsDeclarationOrder"/>
|
||||||
<module name="VariableDeclarationUsageDistance"/>
|
<module name="VariableDeclarationUsageDistance"/>
|
||||||
<module name="MethodParamPad">
|
<module name="MethodParamPad">
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public class Gruppen2Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket productAPI(){
|
public Docket productAPI() {
|
||||||
return new Docket(DocumentationType.SWAGGER_2).select()
|
return new Docket(DocumentationType.SWAGGER_2).select()
|
||||||
.apis(RequestHandlerSelectors.basePackage("mops.gruppen2")).build();
|
.apis(RequestHandlerSelectors.basePackage("mops.gruppen2")).build();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,13 +10,20 @@ import java.util.List;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class SwaggerAPIController {
|
public class SwaggerAPIController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Beispiel für eine API mit Swagger.
|
||||||
|
*
|
||||||
|
* @return Eine Liste von Produkten, repräsentiert durch Strings
|
||||||
|
*/
|
||||||
@RequestMapping(value = "/products", method = RequestMethod.GET)
|
@RequestMapping(value = "/products", method = RequestMethod.GET)
|
||||||
public List<String> getProducts(){
|
public List<String> getProducts() {
|
||||||
List<String> productList = new ArrayList<>();
|
List<String> productList = new ArrayList<>();
|
||||||
productList.add("Honey");
|
productList.add("Honey");
|
||||||
productList.add("Almond");
|
productList.add("Almond");
|
||||||
return productList;
|
return productList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/products", method = RequestMethod.POST)
|
@RequestMapping(value = "/products", method = RequestMethod.POST)
|
||||||
public String createProduct() {
|
public String createProduct() {
|
||||||
return "Product is saved successfully";
|
return "Product is saved successfully";
|
||||||
|
|||||||
@ -5,6 +5,9 @@ import mops.gruppen2.domain.event.Event;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repräsentiert viele Events als aggregiertes Objekt.
|
||||||
|
*/
|
||||||
public abstract class Aggregate {
|
public abstract class Aggregate {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -17,7 +20,7 @@ public abstract class Aggregate {
|
|||||||
/**
|
/**
|
||||||
* Ruft die spezifische applyEvent-Methode im entsprechenden Aggregat auf.
|
* Ruft die spezifische applyEvent-Methode im entsprechenden Aggregat auf.
|
||||||
*
|
*
|
||||||
* @param event Einzelne Änderung an dem Aggregat
|
* @param event Event, welches aggregiert wird
|
||||||
*/
|
*/
|
||||||
public void applyEvent(Event event) {
|
public void applyEvent(Event event) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
package mops.gruppen2.domain;
|
package mops.gruppen2.domain;
|
||||||
|
|
||||||
public enum Role {
|
public enum Role {
|
||||||
ORGA, ADMIN
|
ORGA, ADMIN, STUDENT
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
String user_id;
|
String user_id;
|
||||||
String givenname;
|
String givenname;
|
||||||
String familyname;
|
String familyname;
|
||||||
|
|||||||
@ -4,10 +4,15 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
import mops.gruppen2.domain.User;
|
import mops.gruppen2.domain.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fügt einen einzelnen Nutzer einer Gruppe hinzu.
|
||||||
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Value
|
@Value
|
||||||
public class AddUserEvent extends Event{
|
public class AddUserEvent extends Event {
|
||||||
String givenname, familyname, email;
|
String givenname;
|
||||||
|
String familyname;
|
||||||
|
String email;
|
||||||
|
|
||||||
public AddUserEvent(long event_id, long group_id, String user_id, String givenname, String familyname, String email) {
|
public AddUserEvent(long event_id, long group_id, String user_id, String givenname, String familyname, String email) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
|
|||||||
@ -6,7 +6,8 @@ import lombok.Value;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Value
|
@Value
|
||||||
public class CreateGroupEvent extends Event {
|
public class CreateGroupEvent extends Event {
|
||||||
String groupTitle, groupDescription;
|
String groupTitle;
|
||||||
|
String groupDescription;
|
||||||
|
|
||||||
public CreateGroupEvent(long event_id, long group_id, String user_id, String groupTitle, String groupDescription) {
|
public CreateGroupEvent(long event_id, long group_id, String user_id, String groupTitle, String groupDescription) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
|
|||||||
@ -3,9 +3,12 @@ package mops.gruppen2.domain.event;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entfernt ein einzelnes Mitglied einer Gruppe.
|
||||||
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Value
|
@Value
|
||||||
public class DeleteUserEvent extends Event{
|
public class DeleteUserEvent extends Event {
|
||||||
|
|
||||||
public DeleteUserEvent(long event_id, long group_id, String user_id) {
|
public DeleteUserEvent(long event_id, long group_id, String user_id) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
|
|||||||
@ -3,6 +3,9 @@ package mops.gruppen2.domain.event;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ändert nur die Gruppenbeschreibung.
|
||||||
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Value
|
@Value
|
||||||
public class UpdateGroupDescriptionEvent extends Event {
|
public class UpdateGroupDescriptionEvent extends Event {
|
||||||
|
|||||||
@ -3,6 +3,9 @@ package mops.gruppen2.domain.event;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ändert nur den Gruppentitel.
|
||||||
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Value
|
@Value
|
||||||
public class UpdateGroupTitleEvent extends Event {
|
public class UpdateGroupTitleEvent extends Event {
|
||||||
|
|||||||
@ -4,6 +4,9 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
import mops.gruppen2.domain.Role;
|
import mops.gruppen2.domain.Role;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualisiert die Gruppenrolle eines Teilnehmers.
|
||||||
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Value
|
@Value
|
||||||
public class UpdateRoleEvent extends Event {
|
public class UpdateRoleEvent extends Event {
|
||||||
|
|||||||
@ -6,7 +6,11 @@ import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticatio
|
|||||||
import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter;
|
import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter;
|
||||||
import org.keycloak.representations.AccessToken;
|
import org.keycloak.representations.AccessToken;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.*;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.context.annotation.ScopedProxyMode;
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||||
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
|
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public class GroupService {
|
|||||||
* @param eventList Die restlichen Events für diese Gruppe
|
* @param eventList Die restlichen Events für diese Gruppe
|
||||||
* @return Gruppe auf aktuellem Stand
|
* @return Gruppe auf aktuellem Stand
|
||||||
*/
|
*/
|
||||||
Group buildGroupFromEvents(CreateGroupEvent event, List<Event> eventList){
|
Group buildGroupFromEvents(CreateGroupEvent event, List<Event> eventList) {
|
||||||
Group newGroup = new Group(event);
|
Group newGroup = new Group(event);
|
||||||
|
|
||||||
eventList.forEach(newGroup::applyEvent);
|
eventList.forEach(newGroup::applyEvent);
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package mops.gruppen2.service;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Übersetzt und baut
|
* Übersetzt JSON-Event-Payloads zu Java-Event-Repräsentationen und zurück.
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SerializationService {
|
public class SerializationService {
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package mops.gruppen2.domain;
|
|||||||
|
|
||||||
import mops.gruppen2.domain.event.AddUserEvent;
|
import mops.gruppen2.domain.event.AddUserEvent;
|
||||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||||
import mops.gruppen2.domain.event.Event;
|
|
||||||
import mops.gruppen2.domain.event.UpdateRoleEvent;
|
import mops.gruppen2.domain.event.UpdateRoleEvent;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
@ -35,7 +34,7 @@ class GroupTest {
|
|||||||
|
|
||||||
// Verwendet CreateGroupEvent
|
// Verwendet CreateGroupEvent
|
||||||
@Test
|
@Test
|
||||||
void addSingleUser(){
|
void addSingleUser() {
|
||||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L,1L,"prof1", "hi", "foo");
|
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L,1L,"prof1", "hi", "foo");
|
||||||
Group group = new Group(createGroupEvent);
|
Group group = new Group(createGroupEvent);
|
||||||
|
|
||||||
@ -51,13 +50,15 @@ class GroupTest {
|
|||||||
void updateRoleForExistingUser() {
|
void updateRoleForExistingUser() {
|
||||||
// Arrange
|
// Arrange
|
||||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L, 1L, "1L", "gruppe1", "Eine Testgruppe");
|
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L, 1L, "1L", "gruppe1", "Eine Testgruppe");
|
||||||
Event addUserEvent = new AddUserEvent(1L, 1L, "5L", "Peter", "Pan", "123@mail.de");
|
AddUserEvent addUserEvent = new AddUserEvent(1L, 1L, "5L", "Peter", "Pan", "123@mail.de");
|
||||||
|
|
||||||
Group group = new Group(createGroupEvent);
|
Group group = new Group(createGroupEvent);
|
||||||
group.applyEvent(addUserEvent);
|
group.applyEvent(addUserEvent);
|
||||||
|
|
||||||
|
UpdateRoleEvent updateRoleEvent = new UpdateRoleEvent(1L, 1L, "5L", Role.ORGA);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
group.applyEvent(new UpdateRoleEvent(1L, 1L, "5L", Role.ORGA));
|
group.applyEvent(updateRoleEvent);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertThat(group.getRoles())
|
assertThat(group.getRoles())
|
||||||
@ -65,4 +66,10 @@ class GroupTest {
|
|||||||
.containsValue(Role.ORGA);
|
.containsValue(Role.ORGA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Disabled
|
||||||
|
@Test
|
||||||
|
void updateRoleForNonExistingUser() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user