Skip to content

Commit

Permalink
extending test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioT90 committed Feb 14, 2025
1 parent 2c43797 commit 27a913b
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,42 @@ void givenExceptionInPayloadBuilderWhenThenLogExceptionInfo(){
assertPerformanceLogMessage(APPENDER_NAME, CONTEXT_DATA, "Payload builder thrown Exception class java.lang.RuntimeException: PayloadBuilder is receiving the expected parameter? true", memoryAppender);
}

@Test
void givenNoPayloadBuilderWhenThenLogExceptionInfo(){
// Given
Object expectedResult = new Object();

// When
Object result = PerformanceLogger.execute(APPENDER_NAME, CONTEXT_DATA, () -> expectedResult, null, null);

//Then
Assertions.assertSame(expectedResult, result);
assertPerformanceLogMessage(APPENDER_NAME, CONTEXT_DATA, "", memoryAppender);
}

@Test
void givenPayloadBuilderReturningNullWhenThenLogExceptionInfo(){
// Given
Object expectedResult = new Object();

// When
Object result = PerformanceLogger.execute(APPENDER_NAME, CONTEXT_DATA, () -> expectedResult, x -> null, null);

//Then
Assertions.assertSame(expectedResult, result);
assertPerformanceLogMessage(APPENDER_NAME, CONTEXT_DATA, "null", memoryAppender);
}

@Test
void givenPayloadBuilderAndNullOutputReturningNullWhenThenLogExceptionInfo(){
// When
Object result = PerformanceLogger.execute(APPENDER_NAME, CONTEXT_DATA, () -> null, x -> null, null);

//Then
Assertions.assertNull(result);
assertPerformanceLogMessage(APPENDER_NAME, CONTEXT_DATA, "Returned null", memoryAppender);
}

@Test
void testThresholdLevelTranscoding(){
PerformanceLoggerThresholdLevels thresholdLevels = new PerformanceLoggerThresholdLevels(1, 2);
Expand Down

0 comments on commit 27a913b

Please sign in to comment.