20
20
21
21
import java .util .Arrays ;
22
22
23
+ import org .hamcrest .Matchers ;
23
24
import org .junit .Test ;
24
25
25
26
/**
@@ -36,6 +37,7 @@ public void setsUpWithEmptyLinkList() {
36
37
assertThat (support .hasLinks (), is (false ));
37
38
assertThat (support .hasLink (Link .REL_SELF ), is (false ));
38
39
assertThat (support .getLinks ().isEmpty (), is (true ));
40
+ assertThat (support .getLinks (Link .REL_SELF ).isEmpty (), is (true ));
39
41
}
40
42
41
43
@ Test
@@ -49,6 +51,21 @@ public void addsLinkCorrectly() {
49
51
assertThat (support .hasLinks (), is (true ));
50
52
assertThat (support .hasLink (link .getRel ()), is (true ));
51
53
assertThat (support .getLink (link .getRel ()), is (link ));
54
+ assertThat (support .getLinks (Link .REL_NEXT ), contains (link ));
55
+ }
56
+
57
+ @ Test
58
+ public void addsMultipleLinkRelationsCorrectly () {
59
+
60
+ Link link = new Link ("/customers/1" , "customers" );
61
+ Link link2 = new Link ("/orders/1/customer" , "customers" );
62
+ ResourceSupport support = new ResourceSupport ();
63
+ support .add (link , link2 );
64
+
65
+ assertThat (support .getLinks ("customers" ).size (), is (2 ));
66
+ assertThat (support .getLinks ("customers" ), contains (link , link2 ));
67
+ assertThat (support .getLinks ("non-existent" ).size (), is (0 ));
68
+ assertThat (support .getLinks ("non-existent" ), is (Matchers .<Link >empty ()));
52
69
}
53
70
54
71
@ Test
@@ -64,6 +81,8 @@ public void addsLinksCorrectly() {
64
81
assertThat (support .hasLinks (), is (true ));
65
82
assertThat (support .getLinks (), hasItems (first , second ));
66
83
assertThat (support .getLinks ().size (), is (2 ));
84
+ assertThat (support .getLinks (Link .REL_PREVIOUS ), contains (first ));
85
+ assertThat (support .getLinks (Link .REL_NEXT ), contains (second ));
67
86
}
68
87
69
88
@ Test
0 commit comments