1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package io.earcam.instrumental.module.jpms;
20
21 import static io.earcam.instrumental.module.jpms.Access.ACC_MANDATED;
22 import static io.earcam.instrumental.module.jpms.Access.ACC_SYNTHETIC;
23 import static io.earcam.instrumental.module.jpms.ExportModifier.SYNTHETIC;
24 import static org.hamcrest.MatcherAssert.assertThat;
25 import static org.hamcrest.Matchers.contains;
26 import static org.hamcrest.Matchers.equalTo;
27 import static org.hamcrest.Matchers.is;
28 import static org.hamcrest.Matchers.not;
29 import static org.junit.jupiter.api.Assertions.assertFalse;
30
31 import org.junit.jupiter.api.Test;
32
33 public class ExportTest {
34
35 private static final String PACKAGE = "com.acme.paquet";
36 private static final String[] MODULES = { "mod.a", "mod.b", "mod.c" };
37
38 private final Export export = new Export(PACKAGE, ACC_MANDATED, MODULES);
39
40
41 @Test
42 public void notEqualWhenPackageDiffers()
43 {
44 assertThat(export, is(not(equalTo(new Export("org.acme", ACC_MANDATED, MODULES)))));
45 }
46
47
48 @Test
49 public void notEqualWhenAccessDiffers()
50 {
51 assertThat(export, is(not(equalTo(new Export(PACKAGE, 0, MODULES)))));
52 }
53
54
55 @Test
56 public void notEqualWhenModulesDiffer()
57 {
58 assertThat(export, is(not(equalTo(new Export(PACKAGE, ACC_MANDATED, "mod.x", "mod.y", "mod.z")))));
59 }
60
61
62 @Test
63 public void notEqualToNullType()
64 {
65 assertFalse(export.equals((Export) null));
66 }
67
68
69 @Test
70 public void notEqualToNullObject()
71 {
72 assertFalse(export.equals((Object) null));
73 }
74
75
76 @Test
77 public void modifierIsMappedFromAccess()
78 {
79 Export e = new Export(PACKAGE, ACC_SYNTHETIC, MODULES);
80
81 assertThat(e.modifiers(), contains(SYNTHETIC));
82 }
83
84
85 @Test
86 public void equal()
87 {
88 Export identical = new Export(PACKAGE, ACC_MANDATED, MODULES);
89 assertThat(export, is(equalTo(identical)));
90 assertThat(export.hashCode(), is(equalTo(identical.hashCode())));
91 }
92 }