Replace use of Test.expected with AssertJ

See gh-1032
This commit is contained in:
Vedran Pavic
2018-05-04 17:57:56 +02:00
parent bb1c099094
commit 941fdb46f2
8 changed files with 83 additions and 42 deletions

View File

@@ -32,6 +32,7 @@ import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* @author Pool Dolorier
@@ -52,13 +53,14 @@ public class RestTests {
this.restTemplate = new RestTemplate();
}
@Test(expected = HttpClientErrorException.class)
@Test
public void unauthenticatedUserSentToLogInPage() {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> entity = getForUser(this.baseUrl + "/",
headers, String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
assertThatThrownBy(() -> getForUser(this.baseUrl + "/", headers, String.class))
.isInstanceOf(HttpClientErrorException.class)
.satisfies(e -> assertThat(((HttpClientErrorException) e).getStatusCode())
.isEqualTo(HttpStatus.UNAUTHORIZED));
}
@Test