Search in sources :

Example 6 with AuditLogView

use of org.mifos.framework.components.audit.util.helpers.AuditLogView in project head by mifos.

the class AuditBusinessServiceIntegrationTest method testGetAuditLogRecordsPasswordChange.

@Test
public void testGetAuditLogRecordsPasswordChange() throws Exception {
    AuditLog auditLog = new AuditLog(1, (short) 2, "Mifos", new Date(System.currentTimeMillis()), (short) 3);
    Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
    AuditLogRecord auditLogRecord = new AuditLogRecord("Password", "test_1", "new_test_1", auditLog);
    auditLogRecords.add(auditLogRecord);
    auditLog.addAuditLogRecords(auditLogRecords);
    legacyAuditDao.save(auditLog);
    AuditBusinessService auditBusinessService = new AuditBusinessService();
    List<AuditLogView> auditLogViewList = auditBusinessService.getAuditLogRecords((short) 2, 1);
    Assert.assertEquals(1, auditLogViewList.size());
    AuditLogView auditLogView = auditLogViewList.get(0);
    Assert.assertEquals(AuditConstants.HIDDEN_PASSWORD, auditLogView.getOldValue());
    Assert.assertEquals(AuditConstants.HIDDEN_PASSWORD, auditLogView.getNewValue());
    auditLog = getAuditLog(1, (short) 2);
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Date(java.sql.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with AuditLogView

use of org.mifos.framework.components.audit.util.helpers.AuditLogView in project head by mifos.

the class AuditInterceptorIntegrationTest method testAuditLogView.

@Test
public void testAuditLogView() {
    AuditLogView auditLogView = new AuditLogView();
    long currentTime = System.currentTimeMillis();
    Date date = new Date(currentTime);
    auditLogView.setDate(date.toString());
    auditLogView.setField("field");
    // auditLogView.setMfiLocale(new Locale("1"));
    auditLogView.setNewValue("new value");
    auditLogView.setOldValue("old value");
    auditLogView.setUser("user");
    Assert.assertEquals("value of date", new Date(currentTime).toString(), auditLogView.getDate());
    Assert.assertEquals("value of field", "field", auditLogView.getField());
    //Assert.assertEquals("value of Locale", new Locale("1"), auditLogView
    // .getMfiLocale());
    Assert.assertEquals("value of new value", "new value", auditLogView.getNewValue());
    Assert.assertEquals("value of old value", "old value", auditLogView.getOldValue());
    Assert.assertEquals("value of user", "user", auditLogView.getUser());
}
Also used : AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) Date(java.util.Date) Test(org.junit.Test)

Example 8 with AuditLogView

use of org.mifos.framework.components.audit.util.helpers.AuditLogView in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveSavingsAccountAuditLogs.

@Override
public List<AuditLogDto> retrieveSavingsAccountAuditLogs(Long savingsId) {
    List<AuditLogDto> auditLogDtos = new ArrayList<AuditLogDto>();
    AuditBusinessService auditBusinessService = new AuditBusinessService();
    try {
        List<AuditLogView> auditLogs = auditBusinessService.getAuditLogRecords(EntityType.SAVINGS.getValue(), savingsId.intValue());
        for (AuditLogView auditLogView : auditLogs) {
            auditLogDtos.add(auditLogView.toDto());
        }
        return auditLogDtos;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AuditBusinessService(org.mifos.framework.components.audit.business.service.AuditBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLogDto(org.mifos.dto.domain.AuditLogDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

AuditLogView (org.mifos.framework.components.audit.util.helpers.AuditLogView)8 ArrayList (java.util.ArrayList)5 ServiceException (org.mifos.framework.exceptions.ServiceException)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 AuditLogDto (org.mifos.dto.domain.AuditLogDto)4 AuditBusinessService (org.mifos.framework.components.audit.business.service.AuditBusinessService)4 Test (org.junit.Test)3 AuditLog (org.mifos.framework.components.audit.business.AuditLog)3 AuditLogRecord (org.mifos.framework.components.audit.business.AuditLogRecord)3 Date (java.sql.Date)2 HashSet (java.util.HashSet)2 Date (java.util.Date)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)1 LegacyAuditDao (org.mifos.framework.components.audit.persistence.LegacyAuditDao)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1