generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DMP-4376 Add ARM RPO logs for Dynatrace
Added dynatrace logging for ARM RPO Search and Polling
- Loading branch information
1 parent
47c2459
commit 355249a
Showing
2 changed files
with
143 additions
and
11 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
132 changes: 132 additions & 0 deletions
132
src/test/java/uk/gov/hmcts/darts/log/service/impl/ArmLoggerServiceImplTest.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,132 @@ | ||
package uk.gov.hmcts.darts.log.service.impl; | ||
|
||
import nl.altindag.log.LogCaptor; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@ExtendWith({MockitoExtension.class}) | ||
class ArmLoggerServiceImplTest { | ||
|
||
private static final Integer EOD_ID = 1; | ||
private static final Integer EXECUTION_ID = 2; | ||
private ArmLoggerServiceImpl armLoggerService; | ||
private static LogCaptor logCaptor; | ||
|
||
@BeforeAll | ||
public static void setupLogCaptor() { | ||
logCaptor = LogCaptor.forClass(ArmLoggerServiceImpl.class); | ||
logCaptor.setLogLevelToInfo(); | ||
} | ||
|
||
@AfterEach | ||
public void clearLogs() { | ||
logCaptor.clearLogs(); | ||
} | ||
|
||
@AfterAll | ||
public static void tearDown() { | ||
logCaptor.close(); | ||
} | ||
|
||
@BeforeEach | ||
void setUp() { | ||
armLoggerService = new ArmLoggerServiceImpl(); | ||
} | ||
|
||
@Test | ||
void armPushSuccessful_shouldLogInfoWithEodId_whenProvidedWithEodId() { | ||
armLoggerService.armPushSuccessful(EOD_ID); | ||
|
||
var logEntry = String.format("Successfully pushed object to ARM dropzone: eod_id=%s", EOD_ID); | ||
|
||
List<String> infoLogs = logCaptor.getInfoLogs(); | ||
assertEquals(1, infoLogs.size()); | ||
assertEquals(logEntry, infoLogs.get(0)); | ||
} | ||
|
||
@Test | ||
void armPushFailed_shouldLogErrorWithEodId_whenProvidedWithEodId() { | ||
armLoggerService.armPushFailed(EOD_ID); | ||
|
||
var logEntry = String.format("Failed to push object to ARM dropzone: eod_id=%s", EOD_ID); | ||
|
||
List<String> errorLogs = logCaptor.getErrorLogs(); | ||
assertEquals(1, errorLogs.size()); | ||
assertEquals(logEntry, errorLogs.get(0)); | ||
} | ||
|
||
@Test | ||
void archiveToArmSuccessful_shouldLogInfoWithEodId_whenProvidedWithEodId() { | ||
armLoggerService.archiveToArmSuccessful(EOD_ID); | ||
|
||
var logEntry = String.format("Successfully archived object to ARM: eod_id=%s", EOD_ID); | ||
|
||
List<String> infoLogs = logCaptor.getInfoLogs(); | ||
assertEquals(1, infoLogs.size()); | ||
assertEquals(logEntry, infoLogs.get(0)); | ||
} | ||
|
||
@Test | ||
void archiveToArmFailed_shouldLogErrorWithEodId_whenProvidedWithEodId() { | ||
armLoggerService.archiveToArmFailed(EOD_ID); | ||
|
||
var logEntry = String.format("Failed to archive object to ARM: eod_id=%s", EOD_ID); | ||
|
||
List<String> errorLogs = logCaptor.getErrorLogs(); | ||
assertEquals(1, errorLogs.size()); | ||
assertEquals(logEntry, errorLogs.get(0)); | ||
} | ||
|
||
@Test | ||
void armRpoSearchSuccessful_shouldLogInfoWithEodId_whenProvidedWithExecutionId() { | ||
armLoggerService.armRpoSearchSuccessful(EXECUTION_ID); | ||
|
||
var logEntry = String.format("ARM RPO Search - Successfully completed for execution Id = %s", EXECUTION_ID); | ||
|
||
List<String> infoLogs = logCaptor.getInfoLogs(); | ||
assertEquals(1, infoLogs.size()); | ||
assertEquals(logEntry, infoLogs.get(0)); | ||
} | ||
|
||
@Test | ||
void armRpoSearchFailed_shouldLogErrorWithEodId_whenProvidedWithExecutionId() { | ||
armLoggerService.armRpoSearchFailed(EXECUTION_ID); | ||
|
||
var logEntry = String.format("ARM RPO Search - Failed for execution Id = %s", EXECUTION_ID); | ||
|
||
List<String> errorLogs = logCaptor.getErrorLogs(); | ||
assertEquals(1, errorLogs.size()); | ||
assertEquals(logEntry, errorLogs.get(0)); | ||
} | ||
|
||
@Test | ||
void armRpoPollingSuccessful_shouldLogInfoWithEodId_whenProvidedWithExecutionId() { | ||
armLoggerService.armRpoPollingSuccessful(EXECUTION_ID); | ||
|
||
var logEntry = String.format("ARM RPO Polling - Successfully completed for execution Id = %s", EXECUTION_ID); | ||
|
||
List<String> infoLogs = logCaptor.getInfoLogs(); | ||
assertEquals(1, infoLogs.size()); | ||
assertEquals(logEntry, infoLogs.get(0)); | ||
} | ||
|
||
@Test | ||
void armRpoPollingFailed_shouldLogErrorWithEodId_whenProvidedWithExecutionId() { | ||
armLoggerService.armRpoPollingFailed(EXECUTION_ID); | ||
|
||
var logEntry = String.format("ARM RPO Polling - Failed for execution Id = %s", EXECUTION_ID); | ||
|
||
List<String> errorLogs = logCaptor.getErrorLogs(); | ||
assertEquals(1, errorLogs.size()); | ||
assertEquals(logEntry, errorLogs.get(0)); | ||
} | ||
} |