11package com .baeldung .relationships ;
22
3+ import com .baeldung .SpringDataRestApplication ;
4+ import com .baeldung .models .Address ;
5+ import com .baeldung .models .Author ;
6+ import com .baeldung .models .Book ;
7+ import com .baeldung .models .Library ;
8+ import org .json .JSONArray ;
9+ import org .json .JSONObject ;
10+ import org .junit .Test ;
311import org .junit .runner .RunWith ;
412import org .springframework .beans .factory .annotation .Autowired ;
513import org .springframework .boot .test .context .SpringBootTest ;
1119import org .springframework .http .ResponseEntity ;
1220import org .springframework .test .context .junit4 .SpringRunner ;
1321
14- import com .baeldung .SpringDataRestApplication ;
15- import com .baeldung .models .Address ;
16- import com .baeldung .models .Author ;
17- import com .baeldung .models .Book ;
18- import com .baeldung .models .Library ;
19-
20- import org .junit .Test ;
21- import static org .junit .Assert .*;
22-
23- import org .json .JSONArray ;
24- import org .json .JSONObject ;
22+ import static org .junit .Assert .assertEquals ;
2523
2624@ RunWith (SpringRunner .class )
2725@ SpringBootTest (classes = SpringDataRestApplication .class , webEnvironment = WebEnvironment .DEFINED_PORT )
@@ -48,7 +46,7 @@ public void whenSaveOneToOneRelationship_thenCorrect() {
4846
4947 HttpHeaders requestHeaders = new HttpHeaders ();
5048 requestHeaders .add ("Content-type" , "text/uri-list" );
51- HttpEntity <String > httpEntity = new HttpEntity <String >(ADDRESS_ENDPOINT + "/1" , requestHeaders );
49+ HttpEntity <String > httpEntity = new HttpEntity <>(ADDRESS_ENDPOINT + "/1" , requestHeaders );
5250 template .exchange (LIBRARY_ENDPOINT + "/1/libraryAddress" , HttpMethod .PUT , httpEntity , String .class );
5351
5452 ResponseEntity <Library > libraryGetResponse = template .getForEntity (ADDRESS_ENDPOINT + "/1/library" , Library .class );
@@ -69,7 +67,7 @@ public void whenSaveOneToManyRelationship_thenCorrect() {
6967
7068 HttpHeaders requestHeaders = new HttpHeaders ();
7169 requestHeaders .add ("Content-type" , "text/uri-list" );
72- HttpEntity <String > bookHttpEntity = new HttpEntity <String >(LIBRARY_ENDPOINT + "/1" , requestHeaders );
70+ HttpEntity <String > bookHttpEntity = new HttpEntity <>(LIBRARY_ENDPOINT + "/1" , requestHeaders );
7371 template .exchange (BOOK_ENDPOINT + "/1/library" , HttpMethod .PUT , bookHttpEntity , String .class );
7472 template .exchange (BOOK_ENDPOINT + "/2/library" , HttpMethod .PUT , bookHttpEntity , String .class );
7573
@@ -91,7 +89,7 @@ public void whenSaveManyToManyRelationship_thenCorrect() {
9189
9290 HttpHeaders requestHeaders = new HttpHeaders ();
9391 requestHeaders .add ("Content-type" , "text/uri-list" );
94- HttpEntity <String > httpEntity = new HttpEntity <String >(BOOK_ENDPOINT + "/1\n " + BOOK_ENDPOINT + "/2" , requestHeaders );
92+ HttpEntity <String > httpEntity = new HttpEntity <>(BOOK_ENDPOINT + "/1\n " + BOOK_ENDPOINT + "/2" , requestHeaders );
9593 template .exchange (AUTHOR_ENDPOINT + "/1/books" , HttpMethod .PUT , httpEntity , String .class );
9694
9795 String jsonResponse = template .getForObject (BOOK_ENDPOINT + "/1/authors" , String .class );
0 commit comments