Skip to content

Commit

Permalink
EPA-171: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrichner-oviva committed Dec 5, 2024
1 parent a6ab26d commit f9191c5
Showing 1 changed file with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
import com.github.mustachejava.util.HtmlEscaper;
import com.oviva.ehealthid.relyingparty.svc.AuthenticationException;
import com.oviva.ehealthid.relyingparty.svc.ValidationException;
import com.oviva.ehealthid.relyingparty.ws.ThrowableExceptionMapper.Problem;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.ServerErrorException;
import jakarta.ws.rs.core.*;
import java.io.StringWriter;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -145,7 +143,6 @@ void toResponse_authentication() {
void toResponse_withBody() {

when(uriInfo.getRequestUri()).thenReturn(REQUEST_URI);
when(headers.getAcceptableMediaTypes()).thenReturn(List.of(MediaType.WILDCARD_TYPE));
mockHeaders("de-DE");

// when
Expand All @@ -157,27 +154,6 @@ void toResponse_withBody() {
assertNotNull(res.getEntity());
}

@Test
void toResponse_withJson() {

when(headers.getAcceptableMediaTypes())
.thenReturn(
List.of(
MediaType.APPLICATION_JSON_TYPE,
MediaType.TEXT_HTML_TYPE,
MediaType.WILDCARD_TYPE));

var msg = "Ooops! An error :/";

// when
var res = mapper.toResponse(new ValidationException(new Message(msg)));

// then
assertEquals(400, res.getStatus());
assertEquals(MediaType.APPLICATION_JSON_TYPE, res.getMediaType());
assertEquals(new Problem("/server_error", msg), res.getEntity());
}

@Test
void toResponse_withBody_Unauthorized() {
// when
Expand All @@ -203,7 +179,6 @@ void toResponse_withBody_seeOthers() {
@Test
void toResponse_withBody_withValidationExc() {

when(headers.getAcceptableMediaTypes()).thenReturn(List.of(MediaType.WILDCARD_TYPE));
doReturn("de-DE").when(headers).getHeaderString("Accept-Language");

// when
Expand All @@ -221,7 +196,6 @@ void toResponse_withBody_withValidationExc() {
void toResponse_withBody_withValidationExceptionAndDynamicContent(
String language, String messageKey, String message) {

when(headers.getAcceptableMediaTypes()).thenReturn(List.of(MediaType.WILDCARD_TYPE));
doReturn(language).when(headers).getHeaderString("Accept-Language");

// when
Expand Down

0 comments on commit f9191c5

Please sign in to comment.