generated from pagopa/pn-template-ms-be
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* PN-10715: Removed redundant log. Moved cloudwatch log level from debug to info Aligned MetricCollector with indications from the documentation. * PN-10715: set imap cache to true * PN-10715: Updated pn-ec-namirial-pec version to 1.2.0-SNAPSHOT * PN-10715-bis: added cache related properties to PnPecProvidersConf * PN-10715-bis: added properties to namirial.properties * PN-10715: added jedis 5.1.2 dependency * PN-10715: Fixed JUnit test failure issue. --------- Co-authored-by: mottone-dgs <[email protected]> Co-authored-by: damiano.lozzi <[email protected]> Co-authored-by: Mario Ottone <[email protected]>
- Loading branch information
1 parent
bf15147
commit 8db618a
Showing
12 changed files
with
101 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
src/test/java/it/pagopa/pn/ec/testutils/configuration/CloudWatchTestConfiguration.java
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
src/test/java/it/pagopa/pn/ec/testutils/configuration/PnEcTestWatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package it.pagopa.pn.ec.testutils.configuration; | ||
|
||
import lombok.CustomLog; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.TestWatcher; | ||
import software.amazon.awssdk.metrics.internal.DefaultSdkMetric; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.Optional; | ||
|
||
/** | ||
* PnEcTestWatcher is a custom implementation of the TestWatcher interface. | ||
* It is used to take actions before and after a test is executed. | ||
*/ | ||
@CustomLog | ||
public class PnEcTestWatcher implements TestWatcher { | ||
|
||
/** | ||
* This method is invoked after a test has been skipped due to being disabled. | ||
* | ||
* @param context provides information about the current test execution | ||
* @param reason provides the reason why the test was disabled | ||
*/ | ||
@Override | ||
public void testDisabled(ExtensionContext context, Optional<String> reason) { | ||
clearDeclaredMetrics(); | ||
} | ||
|
||
/** | ||
* This method is invoked after a test has completed successfully. | ||
* | ||
* @param context provides information about the current test execution | ||
*/ | ||
@Override | ||
public void testSuccessful(ExtensionContext context) { | ||
clearDeclaredMetrics(); | ||
} | ||
|
||
/** | ||
* This method is invoked after a test has been aborted. | ||
* | ||
* @param context provides information about the current test execution | ||
* @param cause provides the exception that caused the test to be aborted | ||
*/ | ||
@Override | ||
public void testAborted(ExtensionContext context, Throwable cause) { | ||
clearDeclaredMetrics(); | ||
} | ||
|
||
/** | ||
* This method is invoked after a test has failed. | ||
* | ||
* @param context provides information about the current test execution | ||
* @param cause provides the exception that caused the test to fail | ||
*/ | ||
@Override | ||
public void testFailed(ExtensionContext context, Throwable cause) { | ||
clearDeclaredMetrics(); | ||
} | ||
|
||
/** | ||
* This method clears the declared metrics. | ||
* It uses reflection to access the clearDeclaredMetrics method of the DefaultSdkMetric class. | ||
* If an error occurs during the process, it logs the error and throws a RuntimeException. | ||
*/ | ||
public void clearDeclaredMetrics() { | ||
try { | ||
// Use reflection to get the clearDeclaredMetrics method and invoke it. | ||
Class<?> cls = DefaultSdkMetric.class; | ||
Method method = cls.getDeclaredMethod("clearDeclaredMetrics"); | ||
method.setAccessible(true); // Set the method access. | ||
method.invoke(null); // Invoked the static method. | ||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { | ||
log.error("Error while clearing declared metrics", e); | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters