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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations