-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62f031f
commit 6fae563
Showing
6 changed files
with
95 additions
and
28 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
5 changes: 5 additions & 0 deletions
5
batch/src/main/resources/application-test-configuration.properties
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,5 @@ | ||
spring.batch.job.enabled=false | ||
spring.main.banner-mode=off | ||
logging.level.org.springframework=ERROR | ||
logging.level.org.hibernate=ERROR | ||
logging.level.com.zaxxer.hikari=ERROR |
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
38 changes: 37 additions & 1 deletion
38
batch/src/test/java/fr/abes/item/service/logging/DemandeLoggerServiceTest.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 |
---|---|---|
@@ -1,14 +1,50 @@ | ||
package fr.abes.item.service.logging; | ||
|
||
import fr.abes.item.entities.item.Demande; | ||
import fr.abes.item.entities.item.DemandeExemp; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Modifier; | ||
import java.lang.reflect.Parameter; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
@Slf4j | ||
@SpringBootTest | ||
@ActiveProfiles("test") | ||
@TestPropertySource(locations = { | ||
"classpath:application-test-configuration.properties", | ||
"classpath:application-localhost.properties" | ||
}) | ||
class DemandeLoggerServiceTest { | ||
|
||
private Demande demande; | ||
@Test | ||
void testLombokAccessors(){ | ||
DemandeLoggerService demandeLoggerService = new DemandeLoggerService(); | ||
//log.info(demandeLoggerService.setObjetDeTraitementEnCours("Obtention de la demande à traiter").setDemande(this.demande).logInfo()); | ||
log.info(demandeLoggerService.setFonction(this.getClass().getSimpleName() + "->" + getMethodeEnCours()).setOperation("Obtention de la demande à traiter").logInfo()); | ||
} | ||
|
||
@Test | ||
void testLombokAccessorsWithArguments(){ | ||
DemandeLoggerService demandeLoggerService = new DemandeLoggerService(); | ||
this.methodWithArguments(demandeLoggerService, null, "terre"); | ||
demande = new DemandeExemp(); | ||
this.methodWithArguments(demandeLoggerService, demande, "feu"); | ||
} | ||
|
||
private void methodWithArguments(DemandeLoggerService logger, Demande demande, String argument){ | ||
log.info(logger.setFonction(this.getClass().getSimpleName() + "->" + getMethodeEnCours()).setOperation("Obtention de la demande à traiter").logInfo()); | ||
} | ||
|
||
private static String getMethodeEnCours() { | ||
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); | ||
return stackTrace[2].getMethodName(); | ||
} | ||
} |