forked from mosip/esignet
-
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.
Signed-off-by: Venkata Saidurga Polamraju <[email protected]>
- Loading branch information
1 parent
412995f
commit c217db7
Showing
4 changed files
with
137 additions
and
5 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
69 changes: 69 additions & 0 deletions
69
esignet-core/src/test/java/io/mosip/esignet/core/LoggerAuditServiceTest.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,69 @@ | ||
package io.mosip.esignet.core; | ||
|
||
import io.mosip.esignet.api.dto.AuditDTO; | ||
import io.mosip.esignet.api.util.Action; | ||
import io.mosip.esignet.api.util.ActionStatus; | ||
import io.mosip.esignet.core.util.LoggerAuditService; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class LoggerAuditServiceTest { | ||
|
||
@Mock | ||
private AuditDTO mockAuditDTO; | ||
|
||
@InjectMocks | ||
private LoggerAuditService loggerAuditService; | ||
|
||
@Test | ||
public void logAudit_withThrowable() { | ||
Action action = Action.SEND_OTP; | ||
ActionStatus status = ActionStatus.ERROR; | ||
Throwable throwable = new RuntimeException("Test Exception"); | ||
try { | ||
loggerAuditService.logAudit(action, status, mockAuditDTO, throwable); | ||
Assert.assertTrue(true); | ||
}catch(Exception e){ | ||
Assert.fail(); | ||
} | ||
} | ||
|
||
@Test(expected = NullPointerException.class) | ||
public void logAudit_withNullAction_throwsError() { | ||
ActionStatus status = ActionStatus.ERROR; | ||
Throwable throwable = new RuntimeException("Test Exception"); | ||
loggerAuditService.logAudit(null, status, mockAuditDTO, throwable); | ||
} | ||
|
||
@Test | ||
public void logAudit_withDefaultStatus() { | ||
Action action = Action.SEND_OTP; | ||
ActionStatus status = ActionStatus.SUCCESS; | ||
String username = "testUser"; | ||
try { | ||
loggerAuditService.logAudit(username, action, status, mockAuditDTO, null); | ||
Assert.assertTrue(true); | ||
}catch(Exception e){ | ||
Assert.fail(); | ||
} | ||
} | ||
|
||
@Test | ||
public void logAudit_withErrorStatus() { | ||
Action action = Action.SEND_OTP; | ||
ActionStatus status = ActionStatus.ERROR; | ||
String username = "testUser"; | ||
try { | ||
loggerAuditService.logAudit(username, action, status, mockAuditDTO, null); | ||
Assert.assertTrue(true); | ||
}catch(Exception e){ | ||
Assert.fail(); | ||
} | ||
} | ||
|
||
} |
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