Search in sources :

Example 1 with VXTrxLog

use of org.apache.ranger.view.VXTrxLog in project ranger by apache.

the class TestAssetREST method testGetTransactionReport.

@Test
public void testGetTransactionReport() {
    List<VXTrxLog> vXTrxLogs = new ArrayList<VXTrxLog>();
    VXTrxLogList vXTrxLogList = new VXTrxLogList();
    vXTrxLogList.setVXTrxLogs(vXTrxLogs);
    String transactionId = "123456";
    Mockito.when(assetMgr.getTransactionReport(transactionId)).thenReturn(vXTrxLogList);
    VXTrxLogList expectedVXTrxLogListt = assetREST.getTransactionReport(request, transactionId);
    Assert.assertEquals(vXTrxLogList, expectedVXTrxLogListt);
    Mockito.verify(assetMgr).getTransactionReport(transactionId);
}
Also used : VXTrxLog(org.apache.ranger.view.VXTrxLog) VXTrxLogList(org.apache.ranger.view.VXTrxLogList) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with VXTrxLog

use of org.apache.ranger.view.VXTrxLog in project ranger by apache.

the class TestAssetREST method testGetReportLogs.

@Test
public void testGetReportLogs() {
    SearchCriteria searchCriteria = new SearchCriteria();
    List<SortField> sortFields = null;
    List<VXTrxLog> vXTrxLogs = new ArrayList<VXTrxLog>();
    VXTrxLogList vXTrxLogList = new VXTrxLogList();
    vXTrxLogList.setVXTrxLogs(vXTrxLogs);
    Mockito.when(searchUtil.extractCommonCriterias(request, sortFields)).thenReturn(searchCriteria);
    Mockito.when(searchUtil.extractString((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn("test");
    Mockito.when(searchUtil.extractInt((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString())).thenReturn((Integer) 8);
    Mockito.when(searchUtil.extractDate((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(new Date());
    Mockito.when(assetMgr.getReportLogs(searchCriteria)).thenReturn(vXTrxLogList);
    VXTrxLogList expectedVXTrxLogListt = assetREST.getReportLogs(request);
    Assert.assertEquals(vXTrxLogList, expectedVXTrxLogListt);
    Mockito.verify(searchUtil, Mockito.times(4)).extractString((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
    Mockito.verify(searchUtil).extractInt((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString());
    Mockito.verify(searchUtil, Mockito.times(2)).extractDate((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
    Mockito.verify(assetMgr).getReportLogs(searchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias(request, sortFields);
}
Also used : VXTrxLog(org.apache.ranger.view.VXTrxLog) VXTrxLogList(org.apache.ranger.view.VXTrxLogList) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Date(java.util.Date) Test(org.junit.Test)

Example 3 with VXTrxLog

use of org.apache.ranger.view.VXTrxLog in project ranger by apache.

the class TestXAuditREST method Test3updateXTrxLog.

@Test
public void Test3updateXTrxLog() {
    VXTrxLog vxPrev = new VXTrxLog();
    vxPrev.setId(id);
    vxPrev.setObjectName(name);
    VXTrxLog vxExp = new VXTrxLog();
    vxExp.setId(id);
    vxExp.setObjectName("test1");
    Mockito.when(xAuditMgr.updateXTrxLog(vxPrev)).thenReturn(vxExp);
    VXTrxLog vxAct = auditREST.updateXTrxLog(vxPrev);
    Assert.assertNotNull(vxAct);
    Assert.assertEquals(vxExp, vxAct);
    Assert.assertEquals(vxExp.getObjectName(), vxAct.getObjectName());
    Mockito.verify(xAuditMgr).updateXTrxLog(vxPrev);
}
Also used : VXTrxLog(org.apache.ranger.view.VXTrxLog) Test(org.junit.Test)

Example 4 with VXTrxLog

use of org.apache.ranger.view.VXTrxLog in project ranger by apache.

the class XTrxLogService method mapCustomViewToViewObj.

private VXTrxLog mapCustomViewToViewObj(VXXTrxLog vXXTrxLog) {
    VXTrxLog vXTrxLog = new VXTrxLog();
    vXTrxLog.setId(vXXTrxLog.getId());
    vXTrxLog.setAction(vXXTrxLog.getAction());
    vXTrxLog.setAttributeName(vXXTrxLog.getAttributeName());
    vXTrxLog.setCreateDate(vXXTrxLog.getCreateTime());
    vXTrxLog.setNewValue(vXXTrxLog.getNewValue());
    vXTrxLog.setPreviousValue(vXXTrxLog.getPreviousValue());
    vXTrxLog.setSessionId(vXXTrxLog.getSessionId());
    if (vXXTrxLog.getUpdatedByUserId() == null || vXXTrxLog.getUpdatedByUserId() == 0) {
        vXTrxLog.setUpdatedBy(null);
    } else {
        vXTrxLog.setUpdatedBy(String.valueOf(vXXTrxLog.getUpdatedByUserId()));
    }
    // We will have to get this from XXUser
    // vXTrxLog.setOwner(vXXTrxLog.getAddedByUserName());
    vXTrxLog.setParentObjectId(vXXTrxLog.getParentObjectId());
    vXTrxLog.setParentObjectClassType(vXXTrxLog.getParentObjectClassType());
    vXTrxLog.setParentObjectName(vXXTrxLog.getParentObjectName());
    vXTrxLog.setObjectClassType(vXXTrxLog.getObjectClassType());
    vXTrxLog.setObjectId(vXXTrxLog.getObjectId());
    vXTrxLog.setObjectName(vXXTrxLog.getObjectName());
    vXTrxLog.setTransactionId(vXXTrxLog.getTransactionId());
    return vXTrxLog;
}
Also used : VXTrxLog(org.apache.ranger.view.VXTrxLog)

Example 5 with VXTrxLog

use of org.apache.ranger.view.VXTrxLog in project ranger by apache.

the class TestXAuditREST method Test1getXTrxLog.

@Test
public void Test1getXTrxLog() {
    VXTrxLog vxExp = new VXTrxLog();
    vxExp.setId(id);
    vxExp.setObjectName(name);
    Mockito.when(xAuditMgr.getXTrxLog(id)).thenReturn(vxExp);
    VXTrxLog vxAct = auditREST.getXTrxLog(id);
    Assert.assertNotNull(vxAct);
    Assert.assertEquals(vxExp, vxAct);
    Assert.assertEquals(vxExp.getId(), vxAct.getId());
    Assert.assertEquals(vxExp.getObjectName(), vxAct.getObjectName());
    Mockito.verify(xAuditMgr).getXTrxLog(id);
}
Also used : VXTrxLog(org.apache.ranger.view.VXTrxLog) Test(org.junit.Test)

Aggregations

VXTrxLog (org.apache.ranger.view.VXTrxLog)8 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 VXTrxLogList (org.apache.ranger.view.VXTrxLogList)4 Date (java.util.Date)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1 SearchCriteria (org.apache.ranger.common.SearchCriteria)1 SortField (org.apache.ranger.common.SortField)1 UserSessionBase (org.apache.ranger.common.UserSessionBase)1 XXPortalUser (org.apache.ranger.entity.XXPortalUser)1 XXPortalUserRole (org.apache.ranger.entity.XXPortalUserRole)1 XXServiceDef (org.apache.ranger.entity.XXServiceDef)1 VXXTrxLog (org.apache.ranger.entity.view.VXXTrxLog)1