2020
2121import java .util .Arrays ;
2222
23+ import org .hamcrest .Matchers ;
2324import org .junit .Test ;
2425
2526/**
@@ -36,6 +37,7 @@ public void setsUpWithEmptyLinkList() {
3637 assertThat (support .hasLinks (), is (false ));
3738 assertThat (support .hasLink (Link .REL_SELF ), is (false ));
3839 assertThat (support .getLinks ().isEmpty (), is (true ));
40+ assertThat (support .getLinks (Link .REL_SELF ).isEmpty (), is (true ));
3941 }
4042
4143 @ Test
@@ -49,6 +51,21 @@ public void addsLinkCorrectly() {
4951 assertThat (support .hasLinks (), is (true ));
5052 assertThat (support .hasLink (link .getRel ()), is (true ));
5153 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 ()));
5269 }
5370
5471 @ Test
@@ -64,6 +81,8 @@ public void addsLinksCorrectly() {
6481 assertThat (support .hasLinks (), is (true ));
6582 assertThat (support .getLinks (), hasItems (first , second ));
6683 assertThat (support .getLinks ().size (), is (2 ));
84+ assertThat (support .getLinks (Link .REL_PREVIOUS ), contains (first ));
85+ assertThat (support .getLinks (Link .REL_NEXT ), contains (second ));
6786 }
6887
6988 @ Test
0 commit comments