added test for anonymize function
This commit is contained in:
@@ -3,11 +3,44 @@ package de.anxietyprime.swajodel;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@SpringBootTest
|
||||
class SwaJodelApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
void anonymousTest() {
|
||||
JodelPost post = new JodelPost(1000);
|
||||
post.comments.add(new JodelPost(1001));
|
||||
post.comments.add(new JodelPost(1002));
|
||||
post.comments.get(0).comments.add(new JodelPost(1000));
|
||||
post.comments.get(0).comments.add(new JodelPost(1001));
|
||||
post.comments.get(0).comments.add(new JodelPost(1000));
|
||||
post.comments.add(new JodelPost(1003));
|
||||
post.comments.get(2).comments.add(new JodelPost(1001));
|
||||
post.comments.get(2).comments.add(new JodelPost(1002));
|
||||
post.comments.get(2).comments.add(new JodelPost(1003));
|
||||
post.comments.get(2).comments.add(new JodelPost(1000));
|
||||
post.comments.add(new JodelPost(1000));
|
||||
post.comments.add(new JodelPost(1001));
|
||||
post.comments.add(new JodelPost(1001));
|
||||
|
||||
post.anonymize(Optional.empty());
|
||||
|
||||
assert (post.anonymousID == 0);
|
||||
assert (post.comments.get(0).anonymousID == 1);
|
||||
assert (post.comments.get(1).anonymousID == 2);
|
||||
assert (post.comments.get(2).anonymousID == 3);
|
||||
assert (post.comments.get(3).anonymousID == 0);
|
||||
assert (post.comments.get(4).anonymousID == 1);
|
||||
assert (post.comments.get(5).anonymousID == 1);
|
||||
assert (post.comments.get(0).comments.get(0).anonymousID == 0);
|
||||
assert (post.comments.get(0).comments.get(1).anonymousID == 1);
|
||||
assert (post.comments.get(0).comments.get(2).anonymousID == 0);
|
||||
assert (post.comments.get(2).comments.get(0).anonymousID == 1);
|
||||
assert (post.comments.get(2).comments.get(1).anonymousID == 2);
|
||||
assert (post.comments.get(2).comments.get(2).anonymousID == 3);
|
||||
assert (post.comments.get(2).comments.get(3).anonymousID == 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user