Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/brenoepics/at4j
Browse files Browse the repository at this point in the history
brenoepics committed Jan 16, 2024
2 parents 7ef9fb8 + 320b8aa commit 3f29a71
Showing 1 changed file with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.brenoepics.at4j.util.logging;

import com.github.brenoepics.at4j.core.exceptions.AzureException;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.message.SimpleMessage;
@@ -14,30 +13,31 @@
import static org.mockito.Mockito.when;

class PrivacyProtectionLoggerTest {
private AbstractLogger delegate;
private PrivacyProtectionLogger privacyProtectionLogger;
private AbstractLogger delegate;
private PrivacyProtectionLogger privacyProtectionLogger;

@BeforeEach
public void setup() {
delegate = Mockito.mock(AbstractLogger.class);
privacyProtectionLogger = new PrivacyProtectionLogger(delegate);
}
@BeforeEach
public void setup() {
delegate = Mockito.mock(AbstractLogger.class);
privacyProtectionLogger = new PrivacyProtectionLogger(delegate);
}

@Test
void shouldLogMessageWithPrivateDataReplaced() {
Marker marker = Mockito.mock(Marker.class);
String privateData = "privateData";
String message = "This is a test message with " + privateData;
Exception throwable = new NullPointerException("");
PrivacyProtectionLogger.addPrivateData(privateData);
privacyProtectionLogger.logMessage(null, Level.INFO, marker, new SimpleMessage(message), throwable);
verify(delegate).log(Level.INFO, marker, "This is a test message with **********", throwable);
}
@Test
void shouldLogMessageWithPrivateDataReplaced() {
Marker marker = Mockito.mock(Marker.class);
String privateData = "privateData";
String message = "This is a test message with " + privateData;
Exception throwable = new NullPointerException("");
PrivacyProtectionLogger.addPrivateData(privateData);
privacyProtectionLogger.logMessage(
null, Level.INFO, marker, new SimpleMessage(message), throwable);
verify(delegate).log(Level.INFO, marker, "This is a test message with **********", throwable);
}

@Test
void shouldDelegateIsEnabledCalls() {
Marker marker = Mockito.mock(Marker.class);
when(delegate.isEnabled(Level.INFO, marker)).thenReturn(true);
assertTrue(privacyProtectionLogger.isEnabled(Level.INFO, marker, "message"));
}
}
@Test
void shouldDelegateIsEnabledCalls() {
Marker marker = Mockito.mock(Marker.class);
when(delegate.isEnabled(Level.INFO, marker)).thenReturn(true);
assertTrue(privacyProtectionLogger.isEnabled(Level.INFO, marker, "message"));
}
}

0 comments on commit 3f29a71

Please sign in to comment.