Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJuge committed Dec 12, 2023
1 parent 30af43b commit 6fbab2d
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
package co.elastic.apm.agent.springwebmvc.exception;

import co.elastic.apm.agent.AbstractInstrumentationTest;
import co.elastic.apm.agent.impl.error.ErrorCapture;
import co.elastic.apm.agent.impl.transaction.Transaction;
import co.elastic.apm.agent.tracer.EagerThrowable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -68,10 +70,16 @@ protected void assertExceptionCapture(Class exceptionClazz, MockHttpServletRespo

assertThat(reporter.getErrors())
.hasSize(1)
.first().satisfies(error -> {
.first()
.satisfies(error -> {
assertThat(error.getException())
.hasMessageContaining(exceptionMessageContains)
.isInstanceOf(exceptionClazz);
.isNotNull();
assertThat(error.getException())
.hasMessageContaining(exceptionMessageContains);

// original type won't be the one we expect when exception is "eager"
assertThat(EagerThrowable.getOriginalClass(error.getException()))
.isEqualTo(exceptionClazz);
});
assertThat(response.getStatus()).isEqualTo(statusCode);
assertThat(transaction.getContext().getResponse().getStatusCode()).isEqualTo(statusCode);
Expand Down

0 comments on commit 6fbab2d

Please sign in to comment.