Skip to content

Commit

Permalink
chore: refine test clarity to accurately reflect logged information
Browse files Browse the repository at this point in the history
  • Loading branch information
sfarralorenzo committed Feb 3, 2025
1 parent 4d96e1e commit b6400ba
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/test/java/it/pagopa/transactions/utils/LogFormatterTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package it.pagopa.transactions.utils;

import it.pagopa.ecommerce.commons.domain.RptId;
import it.pagopa.ecommerce.commons.domain.TransactionId;
import it.pagopa.ecommerce.commons.v2.TransactionTestUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -37,15 +40,17 @@ public static void restoreStreams() {
}

@Test
void testSimpleLog() {
String mail = "[email protected]";
log.info(mail);
String pan16 = "pan: 1234567890123456";
log.info(pan16);
log.info(pan16);
void testShouldNotMaskValues() {
// pre-conditions
TransactionId transactionId = new TransactionId(TransactionTestUtils.TRANSACTION_ID);
RptId rptId = new RptId(TransactionTestUtils.RPT_ID);
// test
log.info("TransactionId: [{}]", transactionId.value());
log.info("RPT ID: [{}]", rptId.value());
// assertions
String outcontentString = outContent.toString(StandardCharsets.UTF_8);
assertTrue(outcontentString.contains(mail));
assertTrue(outcontentString.contains(pan16));
assertTrue(outcontentString.contains("TransactionId: [" + transactionId.value() + "]"));
assertTrue(outcontentString.contains("RPT ID: [" + rptId.value() + "]"));
// We expect some additional data in the log string
assertTrue(outcontentString.contains("@timestamp"));
}
Expand Down

0 comments on commit b6400ba

Please sign in to comment.