fixed checkstyle in tests
This commit is contained in:
@ -226,7 +226,6 @@
|
||||
<property name="lineWrappingIndentation" value="8"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
<module name="MethodParamPad">
|
||||
<property name="tokens"
|
||||
|
@ -48,7 +48,7 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
@Scope(scopeName = WebApplicationContext.SCOPE_REQUEST,
|
||||
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public AccessToken getAccessToken() {
|
||||
HttpServletRequest request =
|
||||
((ServletRequestAttributes) RequestContextHolder
|
||||
@ -61,10 +61,10 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
super.configure(http);
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/actuator/**")
|
||||
.hasRole("monitoring")
|
||||
.anyRequest()
|
||||
.permitAll();
|
||||
.antMatchers("/actuator/**")
|
||||
.hasRole("monitoring")
|
||||
.anyRequest()
|
||||
.permitAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,9 @@ public class InviteService {
|
||||
|
||||
private final InviteRepository inviteRepository;
|
||||
|
||||
public InviteService(InviteRepository inviteRepository) {this.inviteRepository = inviteRepository;}
|
||||
public InviteService(InviteRepository inviteRepository) {
|
||||
this.inviteRepository = inviteRepository;
|
||||
}
|
||||
|
||||
public void createLink(UUID groupId) {
|
||||
inviteRepository.save(new InviteLinkDTO(null, groupId.toString(), UUID.randomUUID().toString()));
|
||||
|
@ -29,11 +29,11 @@ public class TestBuilder {
|
||||
|
||||
public static Account account(String name) {
|
||||
return new Account(name,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
null);
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
null);
|
||||
}
|
||||
|
||||
public static Group apply(Group group, Event... events) {
|
||||
@ -56,8 +56,8 @@ public class TestBuilder {
|
||||
*/
|
||||
public static UUID uuidFromInt(int id) {
|
||||
return UUID.fromString("00000000-0000-0000-0000-"
|
||||
+ "0".repeat(11 - String.valueOf(id).length())
|
||||
+ id);
|
||||
+ "0".repeat(11 - String.valueOf(id).length())
|
||||
+ id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,18 +69,18 @@ public class TestBuilder {
|
||||
*/
|
||||
public static List<Event> completePublicGroups(int count, int membercount) {
|
||||
return IntStream.range(0, count)
|
||||
.parallel()
|
||||
.mapToObj(i -> completePublicGroup(membercount))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
.parallel()
|
||||
.mapToObj(i -> completePublicGroup(membercount))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<Event> completePrivateGroups(int count, int membercount) {
|
||||
return IntStream.range(0, count)
|
||||
.parallel()
|
||||
.mapToObj(i -> completePrivateGroup(membercount))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
.parallel()
|
||||
.mapToObj(i -> completePrivateGroup(membercount))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<Event> completePublicGroup(int membercount) {
|
||||
@ -123,25 +123,25 @@ public class TestBuilder {
|
||||
*/
|
||||
public static List<Event> createPublicGroupEvents(int count) {
|
||||
return IntStream.range(0, count)
|
||||
.parallel()
|
||||
.mapToObj(i -> createPublicGroupEvent())
|
||||
.collect(Collectors.toList());
|
||||
.parallel()
|
||||
.mapToObj(i -> createPublicGroupEvent())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<Event> createPrivateGroupEvents(int count) {
|
||||
return IntStream.range(0, count)
|
||||
.parallel()
|
||||
.mapToObj(i -> createPublicGroupEvent())
|
||||
.collect(Collectors.toList());
|
||||
.parallel()
|
||||
.mapToObj(i -> createPublicGroupEvent())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<Event> createMixedGroupEvents(int count) {
|
||||
return IntStream.range(0, count)
|
||||
.parallel()
|
||||
.mapToObj(i -> faker.random().nextInt(0, 1) > 0.5
|
||||
? createPublicGroupEvent()
|
||||
: createPrivateGroupEvent())
|
||||
.collect(Collectors.toList());
|
||||
.parallel()
|
||||
.mapToObj(i -> faker.random().nextInt(0, 1) > 0.5
|
||||
? createPublicGroupEvent()
|
||||
: createPrivateGroupEvent())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static Event createPrivateGroupEvent(UUID groupId) {
|
||||
@ -195,9 +195,9 @@ public class TestBuilder {
|
||||
*/
|
||||
public static List<Event> addUserEvents(int count, UUID groupId) {
|
||||
return IntStream.range(0, count)
|
||||
.parallel()
|
||||
.mapToObj(i -> addUserEvent(groupId, String.valueOf(i)))
|
||||
.collect(Collectors.toList());
|
||||
.parallel()
|
||||
.mapToObj(i -> addUserEvent(groupId, String.valueOf(i)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static Event addUserEvent(UUID groupId, String userId) {
|
||||
@ -221,8 +221,8 @@ public class TestBuilder {
|
||||
public static List<Event> deleteUserEvents(int count, List<Event> eventList) {
|
||||
List<Event> removeEvents = new ArrayList<>();
|
||||
List<Event> shuffle = eventList.parallelStream()
|
||||
.filter(event -> event instanceof AddUserEvent)
|
||||
.collect(Collectors.toList());
|
||||
.filter(event -> event instanceof AddUserEvent)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Collections.shuffle(shuffle);
|
||||
|
||||
@ -245,8 +245,8 @@ public class TestBuilder {
|
||||
*/
|
||||
public static List<Event> deleteUserEvents(Group group) {
|
||||
return group.getMembers().parallelStream()
|
||||
.map(user -> deleteUserEvent(group.getId(), user.getId()))
|
||||
.collect(Collectors.toList());
|
||||
.map(user -> deleteUserEvent(group.getId(), user.getId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static Event deleteUserEvent(UUID groupId, String userId) {
|
||||
|
@ -87,12 +87,12 @@ class GroupServiceTest {
|
||||
|
||||
@Test
|
||||
void getGroupEvents() {
|
||||
// CreateGroupEvent test1 = new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L);
|
||||
// CreateGroupEvent test2 = new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.SIMPLE, Visibility.PUBLIC, 10L);
|
||||
//CreateGroupEvent test1 = new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L);
|
||||
//CreateGroupEvent test2 = new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.SIMPLE, Visibility.PUBLIC, 10L);
|
||||
|
||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||
createPublicGroupEvent(uuidFromInt(1)),
|
||||
createPrivateGroupEvent(uuidFromInt(2)));
|
||||
createPublicGroupEvent(uuidFromInt(1)),
|
||||
createPrivateGroupEvent(uuidFromInt(2)));
|
||||
|
||||
List<UUID> groupIds = Arrays.asList(uuidFromInt(0), uuidFromInt(1));
|
||||
|
||||
@ -121,47 +121,47 @@ class GroupServiceTest {
|
||||
|
||||
@Test
|
||||
void getAllGroupWithVisibilityPublicTestGroupPublic() {
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
// eventService.saveEvent(new DeleteGroupEvent(uuidFromInt(0), "test1"));
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
// eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); //Wofür ist das
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
//eventService.saveEvent(new DeleteGroupEvent(uuidFromInt(0), "test1"));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); //Wofür ist das
|
||||
|
||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||
deleteGroupEvent(uuidFromInt(0)),
|
||||
createPublicGroupEvent());
|
||||
deleteGroupEvent(uuidFromInt(0)),
|
||||
createPublicGroupEvent());
|
||||
|
||||
assertThat(groupService.getAllGroupWithVisibilityPublic("test1").size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllGroupWithVisibilityPublicTestAddSomeEvents() {
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
// eventService.saveEvent(new DeleteGroupEvent(uuidFromInt(0), "test1"));
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
// eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); // Wofür?
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(2), "test3", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
//eventService.saveEvent(new DeleteGroupEvent(uuidFromInt(0), "test1"));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); // Wofür?
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(2), "test3", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
|
||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||
deleteGroupEvent(uuidFromInt(0)),
|
||||
createPublicGroupEvent(),
|
||||
createPublicGroupEvent(),
|
||||
createPublicGroupEvent(),
|
||||
createPrivateGroupEvent());
|
||||
deleteGroupEvent(uuidFromInt(0)),
|
||||
createPublicGroupEvent(),
|
||||
createPublicGroupEvent(),
|
||||
createPublicGroupEvent(),
|
||||
createPrivateGroupEvent());
|
||||
|
||||
assertThat(groupService.getAllGroupWithVisibilityPublic("test1").size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllGroupWithVisibilityPublic_UserInGroup() {
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
// eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test"));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
//eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test"));
|
||||
|
||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||
addUserEvent(uuidFromInt(0), "kobold"),
|
||||
createPrivateGroupEvent(),
|
||||
createPublicGroupEvent());
|
||||
addUserEvent(uuidFromInt(0), "kobold"),
|
||||
createPrivateGroupEvent(),
|
||||
createPublicGroupEvent());
|
||||
|
||||
//Das kommt glaube ich eher in einen Test für die Projektion
|
||||
//assertThat(groupService.getAllGroupWithVisibilityPublic("test2").get(0).getMembers().size()).isEqualTo(1);
|
||||
@ -172,34 +172,34 @@ class GroupServiceTest {
|
||||
|
||||
@Test
|
||||
void getAllLecturesWithVisibilityPublic() {
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
// eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); // Hä
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(2), "test3", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); // Hä
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(2), "test3", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L));
|
||||
|
||||
eventService.saveAll(createLectureEvent(),
|
||||
createPublicGroupEvent(),
|
||||
createLectureEvent(),
|
||||
createLectureEvent(),
|
||||
createLectureEvent());
|
||||
createPublicGroupEvent(),
|
||||
createLectureEvent(),
|
||||
createLectureEvent(),
|
||||
createLectureEvent());
|
||||
|
||||
assertThat(groupService.getAllLecturesWithVisibilityPublic().size()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
void findGroupWith_UserMember_AllGroups() {
|
||||
// eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
// eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test"));
|
||||
// eventService.saveEvent(new UpdateGroupTitleEvent(uuidFromInt(0), "test1", "TestGroup"));
|
||||
// eventService.saveEvent(new UpdateGroupDescriptionEvent(uuidFromInt(0), "test1", "TestDescription"));
|
||||
// eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(0), "test1", Role.MEMBER));
|
||||
//eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L));
|
||||
//eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test"));
|
||||
//eventService.saveEvent(new UpdateGroupTitleEvent(uuidFromInt(0), "test1", "TestGroup"));
|
||||
//eventService.saveEvent(new UpdateGroupDescriptionEvent(uuidFromInt(0), "test1", "TestDescription"));
|
||||
//eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(0), "test1", Role.MEMBER));
|
||||
|
||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||
addUserEvent(uuidFromInt(0), "jens"),
|
||||
updateGroupTitleEvent(uuidFromInt(0)),
|
||||
updateGroupDescriptionEvent(uuidFromInt(0)));
|
||||
addUserEvent(uuidFromInt(0), "jens"),
|
||||
updateGroupTitleEvent(uuidFromInt(0)),
|
||||
updateGroupDescriptionEvent(uuidFromInt(0)));
|
||||
|
||||
//assertThat(groupService.findGroupWith("T", new Account("jens", "a@A", "test", "peter", "mueller", null)).size()).isEqualTo(1);
|
||||
assertThat(groupService.findGroupWith("", account("jens"))).isEmpty();
|
||||
@ -208,7 +208,7 @@ class GroupServiceTest {
|
||||
@Test
|
||||
void findGroupWith_UserNoMember_AllGroups() {
|
||||
eventService.saveAll(completePublicGroups(10, 0),
|
||||
completePrivateGroups(10, 0));
|
||||
completePrivateGroups(10, 0));
|
||||
|
||||
assertThat(groupService.findGroupWith("", account("jens"))).hasSize(10);
|
||||
}
|
||||
@ -216,12 +216,12 @@ class GroupServiceTest {
|
||||
@Test
|
||||
void findGroupWith_FilterGroups() {
|
||||
eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)),
|
||||
updateGroupTitleEvent(uuidFromInt(0), "KK"),
|
||||
updateGroupDescriptionEvent(uuidFromInt(0), "ABCDE"),
|
||||
createPublicGroupEvent(uuidFromInt(1)),
|
||||
updateGroupTitleEvent(uuidFromInt(1), "ABCDEFG"),
|
||||
updateGroupDescriptionEvent(uuidFromInt(1), "KK"),
|
||||
createPrivateGroupEvent());
|
||||
updateGroupTitleEvent(uuidFromInt(0), "KK"),
|
||||
updateGroupDescriptionEvent(uuidFromInt(0), "ABCDE"),
|
||||
createPublicGroupEvent(uuidFromInt(1)),
|
||||
updateGroupTitleEvent(uuidFromInt(1), "ABCDEFG"),
|
||||
updateGroupDescriptionEvent(uuidFromInt(1), "KK"),
|
||||
createPrivateGroupEvent());
|
||||
|
||||
assertThat(groupService.findGroupWith("A", account("jesus"))).hasSize(2);
|
||||
assertThat(groupService.findGroupWith("F", account("jesus"))).hasSize(1);
|
||||
|
Reference in New Issue
Block a user