use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceImplTest method testAuditPage.
/**
* Test of auditPage method, of class AuditServiceImpl.
*/
public void testAuditPage() {
System.out.println("auditPage");
String pageUrl = "http://My.testUrl.org";
Set<Parameter> paramSet = null;
AuditServiceImpl instance = initialiseAuditService();
Audit auditCreateByAuditCommand = EasyMock.createMock(Audit.class);
AuditCommand mockAuditCommand = EasyMock.createMock(AuditCommand.class);
EasyMock.expect(mockAuditCommand.getAudit()).andReturn(auditCreateByAuditCommand).anyTimes();
EasyMock.replay(mockAuditCommand);
AuditCommandFactory mockAuditCommandFactory = EasyMock.createMock(AuditCommandFactory.class);
EasyMock.expect(mockAuditCommandFactory.create(pageUrl, paramSet, false)).andReturn(mockAuditCommand).anyTimes();
EasyMock.replay(mockAuditCommandFactory);
instance.setAuditCommandFactory(mockAuditCommandFactory);
// anyTimes the audit is created and set-up, the auditServiceThreadQueue is
// called to effectively launch the page audit
AuditServiceThreadQueue mockAuditServiceThreadQueue = EasyMock.createMock(AuditServiceThreadQueue.class);
mockAuditServiceThreadQueue.add(instance);
EasyMock.expectLastCall().anyTimes();
mockAuditServiceThreadQueue.addPageAudit(mockAuditCommand);
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(mockAuditServiceThreadQueue);
instance.setAuditServiceThreadQueue(mockAuditServiceThreadQueue);
Audit result = instance.auditPage(pageUrl, paramSet);
assertEquals(auditCreateByAuditCommand, result);
EasyMock.verify(mockAuditServiceThreadQueue);
EasyMock.verify(mockAuditCommand);
EasyMock.verify(mockAuditCommandFactory);
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceImplTest method testAuditPageUploadWithOneFile.
/**
* Test of auditPageUpload method, of class AuditServiceImpl.
*/
public void testAuditPageUploadWithOneFile() {
System.out.println("auditPageUploadWithOneFile");
Set<Parameter> paramSet = null;
// test we only one file is passed as argument to be tested
String file1Name = "file://test1";
Map<String, String> fileMap = new HashMap<>();
fileMap.put(file1Name, "");
AuditServiceImpl instance = initialiseAuditService();
Audit auditCreateByAuditCommand = EasyMock.createMock(Audit.class);
AuditCommand mockAuditCommand = EasyMock.createMock(AuditCommand.class);
EasyMock.expect(mockAuditCommand.getAudit()).andReturn(auditCreateByAuditCommand).anyTimes();
EasyMock.replay(mockAuditCommand);
AuditCommandFactory mockAuditCommandFactory = EasyMock.createMock(AuditCommandFactory.class);
EasyMock.expect(mockAuditCommandFactory.create(fileMap, paramSet)).andReturn(mockAuditCommand).anyTimes();
EasyMock.replay(mockAuditCommandFactory);
instance.setAuditCommandFactory(mockAuditCommandFactory);
// anyTimes the audit is created and set-up, the auditServiceThreadQueue is
// called to effectively launch the pageUpload audit
AuditServiceThreadQueue mockAuditServiceThreadQueue = EasyMock.createMock(AuditServiceThreadQueue.class);
mockAuditServiceThreadQueue.add(instance);
EasyMock.expectLastCall().anyTimes();
mockAuditServiceThreadQueue.addPageUploadAudit(mockAuditCommand);
EasyMock.replay(mockAuditServiceThreadQueue);
instance.setAuditServiceThreadQueue(mockAuditServiceThreadQueue);
Audit result = instance.auditPageUpload(fileMap, paramSet);
assertEquals(auditCreateByAuditCommand, result);
EasyMock.verify(mockAuditServiceThreadQueue);
EasyMock.verify(mockAuditCommand);
EasyMock.verify(mockAuditCommandFactory);
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceImplTest method testAuditCrashed.
/**
* Test of auditCompleted method, of class AuditServiceImpl.
*/
public void testAuditCrashed() {
AuditServiceImpl instance = initialiseAuditService();
Audit mockAudit = EasyMock.createMock(Audit.class);
Exception mockException = EasyMock.createMock(Exception.class);
AuditServiceListener mockAuditServiceListener = EasyMock.createMock(AuditServiceListener.class);
mockAuditServiceListener.auditCrashed(mockAudit, mockException);
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(mockAuditServiceListener);
EasyMock.replay(mockAudit);
EasyMock.replay(mockException);
instance.add(mockAuditServiceListener);
instance.auditCrashed(mockAudit, mockException);
EasyMock.verify(mockAudit);
EasyMock.verify(mockAuditServiceListener);
EasyMock.verify(mockException);
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceImplTest method testAudit.
/**
* Test of audit method, of class AuditServiceImpl.
*/
public void testAudit() {
AuditServiceImpl instance = initialiseAuditService();
Audit audit = EasyMock.createMock(Audit.class);
Audit auditReturnedByAuditMethodOfAuditServiceThread = EasyMock.createMock(Audit.class);
AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
mockAuditServiceThread.run();
EasyMock.expectLastCall();
EasyMock.expect(mockAuditServiceThread.getAudit()).andReturn(auditReturnedByAuditMethodOfAuditServiceThread).anyTimes();
EasyMock.replay(mockAuditServiceThread);
EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).andReturn(mockAuditServiceThread).anyTimes();
EasyMock.replay(mockAuditServiceThreadFactory);
assertEquals(auditReturnedByAuditMethodOfAuditServiceThread, instance.audit(audit));
EasyMock.verify(mockAuditServiceThread);
EasyMock.verify(mockAuditServiceThreadFactory);
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceThreadFactoryImplTest method testCreate1.
/**
* Test of create method, of class AuditServiceThreadFactoryImpl.
*/
public void testCreate1() {
System.out.println("create from Audit");
Audit audit = EasyMock.createMock(Audit.class);
AuditServiceThreadFactoryImpl instance = initiliseAuditServiceThreadFactory();
// AuditServiceThread result = instance.create(audit);
// the create method returns a result AuditServiceThreadImpl instance
// set-up with all the services and data-services
// assertTrue(result instanceof AuditServiceThreadImpl);
// assertEquals(audit, result.getAudit());
}
Aggregations