Search in sources :

Example 36 with Audit

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);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommandFactory(org.asqatasun.service.command.factory.AuditCommandFactory) Parameter(org.asqatasun.entity.parameterization.Parameter) AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 37 with Audit

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);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommandFactory(org.asqatasun.service.command.factory.AuditCommandFactory) Parameter(org.asqatasun.entity.parameterization.Parameter) AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 38 with Audit

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);
}
Also used : Audit(org.asqatasun.entity.audit.Audit)

Example 39 with Audit

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);
}
Also used : Audit(org.asqatasun.entity.audit.Audit)

Example 40 with Audit

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());
}
Also used : Audit(org.asqatasun.entity.audit.Audit)

Aggregations

Audit (org.asqatasun.entity.audit.Audit)47 WebResource (org.asqatasun.entity.subject.WebResource)11 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)10 Parameter (org.asqatasun.entity.parameterization.Parameter)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Site (org.asqatasun.entity.subject.Site)7 AuditCommand (org.asqatasun.service.command.AuditCommand)7 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)6 Secured (org.springframework.security.access.annotation.Secured)6 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)5 Contract (org.asqatasun.webapp.entity.contract.Contract)5 Content (org.asqatasun.entity.audit.Content)4 ProcessResult (org.asqatasun.entity.audit.ProcessResult)4 Page (org.asqatasun.entity.subject.Page)4 AuditImpl (org.asqatasun.entity.audit.AuditImpl)3 SSP (org.asqatasun.entity.audit.SSP)2 Test (org.asqatasun.entity.reference.Test)2 ScenarioLoader (org.asqatasun.scenarioloader.ScenarioLoader)2 Act (org.asqatasun.webapp.entity.contract.Act)2 IOException (java.io.IOException)1