Skip to content

Commit

Permalink
feat:mdc errorKey test
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsomora committed Oct 23, 2023
1 parent 65c6377 commit d392ef4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ public class ErrorDataServiceTest extends AbstractTest {
public void error1Test() {
Assertions.assertThrows(RuntimeException.class, () -> service.error1("Error"));
assertLogs()
/*.assertLines(91)*/
.assertContains(0,
"ERROR [org.tki.qua.log.cdi.tes.app.ErrorDataService] (main) error1(Error) throw java.lang.RuntimeException: Error")
.assertLines(91);
}

@Test
public void error2Test() {
Assertions.assertThrows(RuntimeException.class, () -> service.error2());
assertLogs().assertLines(91)
.assertContains(0,
"ERROR [org.tki.qua.log.cdi.tes.app.ErrorDataService] (main) error1(Error) throw java.lang.RuntimeException: Error");
}
Expand All @@ -44,7 +52,7 @@ public void noStacktraceTest() {
@Test
public void wrapperTest() {
Assertions.assertThrows(RuntimeException.class, () -> wrapper.wrapperMethod("WrapperError"));
assertLogs()/*.assertLines(104)*/
assertLogs().assertLines(104)
.assertContains(0,
"ERROR [org.tki.qua.log.cdi.tes.app.ErrorDataService] (main) error1(WrapperError) throw java.lang.RuntimeException: WrapperError");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.tkit.quarkus.log.cdi.test.app;

import org.tkit.quarkus.log.cdi.LogFriendlyException;

public class DummyLogFriendlyException extends RuntimeException implements LogFriendlyException {
@Override
public String getErrorNumber() {
return "DummyErrorNUmber";
}

@Override
public boolean shouldLogStacktrace() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public void error1(String error) {
throw new RuntimeException(error);
}

public void error2() {
throw new DummyLogFriendlyException();
}

@LogService(stacktrace = false)
public void noStacktrace() {
throw new RuntimeException("Error1");
Expand Down

0 comments on commit d392ef4

Please sign in to comment.