Skip to content

Commit

Permalink
fix(exception-handling): [eclipse-tractusx#841] improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmf committed Aug 2, 2024
1 parent 03a20d2 commit 5ed2f89
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,25 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;

class EdcRetrieverExceptionTest {

@Test
void test() throws EdcRetrieverException {
void testBuildEdcRetrieverException() {

final EdcRetrieverException build = new EdcRetrieverException.Builder(
new IllegalArgumentException("my illegal arg")).withEdcUrl("my url").withBpn("my bpn").build();
final String causeMessage = "my illegal arg";
final IllegalArgumentException cause = new IllegalArgumentException(causeMessage);
final String expectedUrl = "my url";
final String expectedBpn = "my bpn";

assertThat(build.getBpn()).isEqualTo("my bpn");
assertThat(build.getEdcUrl()).isEqualTo("my url");
final EdcRetrieverException builtException = new EdcRetrieverException.Builder(cause).withEdcUrl(expectedUrl)
.withBpn(expectedBpn)
.build();

Assertions.assertThatThrownBy(() -> {
throw build;
}).hasMessageContaining("my illegal arg");
assertThat(builtException.getBpn()).isEqualTo(expectedBpn);
assertThat(builtException.getEdcUrl()).isEqualTo(expectedUrl);
assertThat(builtException).hasMessageContaining(causeMessage);

}
}

0 comments on commit 5ed2f89

Please sign in to comment.