1
|
package eu.dnetlib.pace.model.gt;
|
2
|
|
3
|
import com.google.common.collect.Sets;
|
4
|
import org.junit.Test;
|
5
|
|
6
|
import java.util.Set;
|
7
|
|
8
|
import static org.junit.Assert.assertTrue;
|
9
|
|
10
|
public class AuthorTest {
|
11
|
|
12
|
@Test
|
13
|
public void test() {
|
14
|
final Set<Author> s1 = getAuthors(3);
|
15
|
final Set<Author> s2 = getAuthors(3);
|
16
|
|
17
|
final Set<Author> i = Sets.intersection(s1, s2);
|
18
|
|
19
|
System.out.println(i);
|
20
|
|
21
|
assertTrue(i.size() == 3);
|
22
|
|
23
|
}
|
24
|
|
25
|
@Test
|
26
|
public void test1() {
|
27
|
final Authors a1 = new Authors(a("1", "Wang, M."));
|
28
|
final Authors a2 = new Authors(a("1", "Wang, M."));
|
29
|
|
30
|
final Set<Author> i = Sets.intersection(a1, a2);
|
31
|
|
32
|
assertTrue(i.size() == 1);
|
33
|
|
34
|
}
|
35
|
|
36
|
private Set<Author> getAuthors(final int n) {
|
37
|
final Set<Author> s = Sets.newHashSet();
|
38
|
|
39
|
for (int i = 0; i < n; i++) {
|
40
|
s.add(a(i + "", "name" + i));
|
41
|
}
|
42
|
return s;
|
43
|
}
|
44
|
|
45
|
private Author a(final String id, final String fullname) {
|
46
|
final Author a = new Author();
|
47
|
a.setId(id);
|
48
|
a.setFullname(fullname);
|
49
|
return a;
|
50
|
}
|
51
|
|
52
|
}
|