Search in sources :

Example 21 with AuditCommand

use of org.asqatasun.service.command.AuditCommand in project Asqatasun by Asqatasun.

the class AuditServiceImpl method adaptContent.

@Override
public Audit adaptContent(Audit audit) {
    AuditCommand auditCommand = auditCommandFactory.create(null, null, true);
    auditCommand.setAudit(audit);
    auditCommand.adaptContent();
    return audit;
}
Also used : AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 22 with AuditCommand

use of org.asqatasun.service.command.AuditCommand in project Asqatasun by Asqatasun.

the class AuditServiceImplTest method testAuditSite.

/**
     * Test of auditPage method, of class AuditServiceImpl.
     */
public void testAuditSite() {
    System.out.println("auditSite");
    String siteUrl = "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(siteUrl, paramSet, true)).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 site audit
    AuditServiceThreadQueue mockAuditServiceThreadQueue = EasyMock.createMock(AuditServiceThreadQueue.class);
    mockAuditServiceThreadQueue.add(instance);
    EasyMock.expectLastCall().anyTimes();
    mockAuditServiceThreadQueue.addSiteAudit(mockAuditCommand);
    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(mockAuditServiceThreadQueue);
    instance.setAuditServiceThreadQueue(mockAuditServiceThreadQueue);
    Audit result = instance.auditSite(siteUrl, 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 23 with AuditCommand

use of org.asqatasun.service.command.AuditCommand 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 24 with AuditCommand

use of org.asqatasun.service.command.AuditCommand 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 25 with AuditCommand

use of org.asqatasun.service.command.AuditCommand in project Asqatasun by Asqatasun.

the class AuditServiceThreadQueueImplTest method testAddPageAudit.

/**
     * Test of addPageAudit method, of class AuditServiceThreadQueueImpl.
     */
public void testAddPageAudit() {
    System.out.println("addPageAudit");
    // the tested instance
    AuditServiceThreadQueueImpl instance = new AuditServiceThreadQueueImpl();
    AuditCommand auditCommand = EasyMock.createMock(AuditCommand.class);
    // Create the mock instance
    AuditServiceThread auditServiceThread = createMockAuditServiceThread(instance);
    // Create the mock instance
    AuditServiceThreadFactory auditServiceThreadFactory = createMockAuditServiceThreadFactory(auditCommand, auditServiceThread);
    instance.setAuditServiceThreadFactory(auditServiceThreadFactory);
    instance.addPageAudit(auditCommand);
    // an unexpected error
    try {
        Thread.sleep(500);
    } catch (InterruptedException ex) {
        Logger.getLogger(AuditServiceThreadQueueImplTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    // Verify behavior.
    EasyMock.verify(auditServiceThreadFactory);
    EasyMock.verify(auditServiceThread);
}
Also used : AuditCommand(org.asqatasun.service.command.AuditCommand)

Aggregations

AuditCommand (org.asqatasun.service.command.AuditCommand)31 Audit (org.asqatasun.entity.audit.Audit)7 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)5 Parameter (org.asqatasun.entity.parameterization.Parameter)4 ArrayList (java.util.ArrayList)1