changed the way anonymization works
This commit is contained in:
@@ -119,9 +119,9 @@ public class Routes {
|
||||
}
|
||||
|
||||
// calculate anonymous IDs for the posts
|
||||
Vector<Long> anonymousIDs = new Vector<Long>();
|
||||
anonymousIDs.add(userID);
|
||||
posts.forEach(post -> {
|
||||
Vector<Long> anonymousIDs = new Vector<Long>();
|
||||
anonymousIDs.add(userID);
|
||||
post.anonymize(anonymousIDs);
|
||||
});
|
||||
|
||||
|
||||
@@ -8,39 +8,4 @@ import java.util.Vector;
|
||||
@SpringBootTest
|
||||
class SwaJodelApplicationTests {
|
||||
|
||||
@Test
|
||||
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(new Vector<Long>());
|
||||
|
||||
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