Use AssertJ in spring-boot-samples
See gh-5083
This commit is contained in:
@@ -33,10 +33,7 @@ import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(SampleHateoasApplication.class)
|
||||
@@ -50,10 +47,10 @@ public class SampleHateoasApplicationTests {
|
||||
public void hasHalLinks() throws Exception {
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.port + "/customers/1", String.class);
|
||||
assertThat(entity.getStatusCode(), equalTo(HttpStatus.OK));
|
||||
assertThat(entity.getBody(), startsWith(
|
||||
"{\"id\":1,\"firstName\":\"Oliver\"" + ",\"lastName\":\"Gierke\""));
|
||||
assertThat(entity.getBody(), containsString("_links\":{\"self\":{\"href\""));
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).startsWith(
|
||||
"{\"id\":1,\"firstName\":\"Oliver\"" + ",\"lastName\":\"Gierke\"");
|
||||
assertThat(entity.getBody()).contains("_links\":{\"self\":{\"href\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,9 +61,9 @@ public class SampleHateoasApplicationTests {
|
||||
URI.create("http://localhost:" + this.port + "/customers/1"));
|
||||
ResponseEntity<String> response = new TestRestTemplate().exchange(request,
|
||||
String.class);
|
||||
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
|
||||
assertThat(response.getHeaders().getContentType(),
|
||||
equalTo(MediaType.parseMediaType("application/json;charset=UTF-8")));
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(response.getHeaders().getContentType())
|
||||
.isEqualTo(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user