general style improvements + javadoc
This commit is contained in:
@ -229,13 +229,6 @@
|
||||
<property name="lineWrappingIndentation" value="8"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
</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="VariableDeclarationUsageDistance"/>
|
||||
<module name="MethodParamPad">
|
||||
|
@ -16,7 +16,7 @@ public class Gruppen2Application {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket productAPI(){
|
||||
public Docket productAPI() {
|
||||
return new Docket(DocumentationType.SWAGGER_2).select()
|
||||
.apis(RequestHandlerSelectors.basePackage("mops.gruppen2")).build();
|
||||
}
|
||||
|
@ -10,15 +10,22 @@ import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class SwaggerAPIController {
|
||||
@RequestMapping(value = "/products", method = RequestMethod.GET)
|
||||
public List<String> getProducts(){
|
||||
List<String> productList = new ArrayList<>();
|
||||
productList.add("Honey");
|
||||
productList.add("Almond");
|
||||
return productList;
|
||||
}
|
||||
@RequestMapping(value = "/products", method = RequestMethod.POST)
|
||||
public String createProduct() {
|
||||
return "Product is saved successfully";
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Beispiel für eine API mit Swagger.
|
||||
*
|
||||
* @return Eine Liste von Produkten, repräsentiert durch Strings
|
||||
*/
|
||||
@RequestMapping(value = "/products", method = RequestMethod.GET)
|
||||
public List<String> getProducts() {
|
||||
List<String> productList = new ArrayList<>();
|
||||
productList.add("Honey");
|
||||
productList.add("Almond");
|
||||
return productList;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/products", method = RequestMethod.POST)
|
||||
public String createProduct() {
|
||||
return "Product is saved successfully";
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ import mops.gruppen2.domain.event.Event;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Repräsentiert viele Events als aggregiertes Objekt.
|
||||
*/
|
||||
public abstract class Aggregate {
|
||||
|
||||
@Getter
|
||||
@ -17,7 +20,7 @@ public abstract class Aggregate {
|
||||
/**
|
||||
* 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) {
|
||||
try {
|
||||
|
@ -1,5 +1,5 @@
|
||||
package mops.gruppen2.domain;
|
||||
|
||||
public enum Role {
|
||||
ORGA, ADMIN
|
||||
ORGA, ADMIN, STUDENT
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ import lombok.Data;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class User {
|
||||
String user_id;
|
||||
String givenname;
|
||||
String familyname;
|
||||
String email;
|
||||
|
||||
String user_id;
|
||||
String givenname;
|
||||
String familyname;
|
||||
String email;
|
||||
}
|
||||
|
@ -4,22 +4,27 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
import mops.gruppen2.domain.User;
|
||||
|
||||
/**
|
||||
* Fügt einen einzelnen Nutzer einer Gruppe hinzu.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public class AddUserEvent extends Event{
|
||||
String givenname, familyname, email;
|
||||
public class AddUserEvent extends Event {
|
||||
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);
|
||||
this.givenname = givenname;
|
||||
this.familyname = familyname;
|
||||
this.email = 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);
|
||||
this.givenname = givenname;
|
||||
this.familyname = familyname;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public AddUserEvent(long event_id, long group_id, User user) {
|
||||
super(event_id, group_id, user.getUser_id());
|
||||
this.givenname = user.getGivenname();
|
||||
this.familyname = user.getFamilyname();
|
||||
this.email = user.getEmail();
|
||||
}
|
||||
public AddUserEvent(long event_id, long group_id, User user) {
|
||||
super(event_id, group_id, user.getUser_id());
|
||||
this.givenname = user.getGivenname();
|
||||
this.familyname = user.getFamilyname();
|
||||
this.email = user.getEmail();
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,12 @@ import lombok.Value;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
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) {
|
||||
super(event_id, group_id, user_id);
|
||||
this.groupTitle = groupTitle;
|
||||
this.groupDescription = groupDescription;
|
||||
}
|
||||
public CreateGroupEvent(long event_id, long group_id, String user_id, String groupTitle, String groupDescription) {
|
||||
super(event_id, group_id, user_id);
|
||||
this.groupTitle = groupTitle;
|
||||
this.groupDescription = groupDescription;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,12 @@ package mops.gruppen2.domain.event;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
/**
|
||||
* Entfernt ein einzelnes Mitglied einer Gruppe.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public class DeleteUserEvent extends Event{
|
||||
public class DeleteUserEvent extends Event {
|
||||
|
||||
public DeleteUserEvent(long event_id, long group_id, String user_id) {
|
||||
super(event_id, group_id, user_id);
|
||||
|
@ -6,7 +6,7 @@ import lombok.experimental.NonFinal;
|
||||
@Value
|
||||
@NonFinal
|
||||
public class Event {
|
||||
long event_id;
|
||||
long group_id;
|
||||
String user_id;
|
||||
long event_id;
|
||||
long group_id;
|
||||
String user_id;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package mops.gruppen2.domain.event;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
/**
|
||||
* Ändert nur die Gruppenbeschreibung.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public class UpdateGroupDescriptionEvent extends Event {
|
||||
|
@ -3,6 +3,9 @@ package mops.gruppen2.domain.event;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
/**
|
||||
* Ändert nur den Gruppentitel.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public class UpdateGroupTitleEvent extends Event {
|
||||
|
@ -4,6 +4,9 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
import mops.gruppen2.domain.Role;
|
||||
|
||||
/**
|
||||
* Aktualisiert die Gruppenrolle eines Teilnehmers.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
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.representations.AccessToken;
|
||||
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.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
|
||||
|
@ -9,18 +9,18 @@ import java.util.List;
|
||||
@Service
|
||||
public class GroupService {
|
||||
|
||||
/**
|
||||
* Konstruiert eine vollständige Gruppe aus Events, welche dieselbe Gruppe betreffen.
|
||||
*
|
||||
* @param event Initiales CreateGroup-Event
|
||||
* @param eventList Die restlichen Events für diese Gruppe
|
||||
* @return Gruppe auf aktuellem Stand
|
||||
*/
|
||||
Group buildGroupFromEvents(CreateGroupEvent event, List<Event> eventList){
|
||||
Group newGroup = new Group(event);
|
||||
/**
|
||||
* Konstruiert eine vollständige Gruppe aus Events, welche dieselbe Gruppe betreffen.
|
||||
*
|
||||
* @param event Initiales CreateGroup-Event
|
||||
* @param eventList Die restlichen Events für diese Gruppe
|
||||
* @return Gruppe auf aktuellem Stand
|
||||
*/
|
||||
Group buildGroupFromEvents(CreateGroupEvent event, List<Event> eventList) {
|
||||
Group newGroup = new Group(event);
|
||||
|
||||
eventList.forEach(newGroup::applyEvent);
|
||||
eventList.forEach(newGroup::applyEvent);
|
||||
|
||||
return newGroup;
|
||||
}
|
||||
return newGroup;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package mops.gruppen2.service;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Übersetzt und baut
|
||||
* Übersetzt JSON-Event-Payloads zu Java-Event-Repräsentationen und zurück.
|
||||
*/
|
||||
@Service
|
||||
public class SerializationService {
|
||||
|
@ -6,8 +6,8 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
@SpringBootTest
|
||||
class Gruppen2ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package mops.gruppen2.domain;
|
||||
|
||||
import mops.gruppen2.domain.event.AddUserEvent;
|
||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.domain.event.UpdateRoleEvent;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
@ -35,7 +34,7 @@ class GroupTest {
|
||||
|
||||
// Verwendet CreateGroupEvent
|
||||
@Test
|
||||
void addSingleUser(){
|
||||
void addSingleUser() {
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L,1L,"prof1", "hi", "foo");
|
||||
Group group = new Group(createGroupEvent);
|
||||
|
||||
@ -51,13 +50,15 @@ class GroupTest {
|
||||
void updateRoleForExistingUser() {
|
||||
// Arrange
|
||||
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.applyEvent(addUserEvent);
|
||||
|
||||
UpdateRoleEvent updateRoleEvent = new UpdateRoleEvent(1L, 1L, "5L", Role.ORGA);
|
||||
|
||||
// Act
|
||||
group.applyEvent(new UpdateRoleEvent(1L, 1L, "5L", Role.ORGA));
|
||||
group.applyEvent(updateRoleEvent);
|
||||
|
||||
// Assert
|
||||
assertThat(group.getRoles())
|
||||
@ -65,4 +66,10 @@ class GroupTest {
|
||||
.containsValue(Role.ORGA);
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void updateRoleForNonExistingUser() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user