Search in sources :

Example 6 with AuditCommand

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

the class AuditServiceThreadImplTest method testGetAudit.

/**
     * Test of getAudit method, of class AuditServiceThreadImpl.
     */
public void testGetAudit() {
    System.out.println("getAudit");
    Audit audit = createMock(Audit.class);
    Audit auditReturnedByAuditCommand = createMock(Audit.class);
    AuditCommand mockAuditCommand = createMock(AuditCommand.class);
    expect(mockAuditCommand.getAudit()).andReturn(auditReturnedByAuditCommand);
    replay(mockAuditCommand);
    AuditServiceThreadImpl instance = initialiseAuditServiceThread(audit);
    assertEquals(audit, instance.getAudit());
    instance = initialiseAuditServiceThread(mockAuditCommand);
    assertEquals(auditReturnedByAuditCommand, instance.getAudit());
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 7 with AuditCommand

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

the class AuditServiceThreadImplTest method testRun.

/**
     * Test of run method, of class AuditServiceThreadImpl.
     */
public void testRun() {
    System.out.println("run");
    Audit mockAudit = createMock(Audit.class);
    expect(mockAudit.getId()).andReturn(1l).anyTimes();
    AuditCommand mockAuditCommand = createMock(AuditCommand.class);
    mockAuditCommand.init();
    expectLastCall().once();
    mockAuditCommand.loadContent();
    expectLastCall().once();
    mockAuditCommand.adaptContent();
    expectLastCall().once();
    mockAuditCommand.process();
    expectLastCall().once();
    mockAuditCommand.consolidate();
    expectLastCall().once();
    mockAuditCommand.analyse();
    expectLastCall().once();
    expect(mockAuditCommand.getAudit()).andReturn(mockAudit).anyTimes();
    replay(mockAudit);
    replay(mockAuditCommand);
    AuditServiceThreadImpl instance = initialiseAuditServiceThread(mockAuditCommand);
    AuditServiceThreadListener auditServiceThreadListener = createMock(AuditServiceThreadListener.class);
    auditServiceThreadListener.auditCompleted(instance);
    expectLastCall().once();
    replay(auditServiceThreadListener);
    instance.add(auditServiceThreadListener);
    instance.run();
    verify(mockAudit);
    verify(mockAuditCommand);
    verify(auditServiceThreadListener);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 8 with AuditCommand

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

the class AuditServiceThreadQueueImplTest method createMockAuditServiceThreadFactoryWithMultipleCommand.

/**
     * 
     * @param audit
     * @param auditServiceThread
     * @return 
     */
private AuditServiceThreadFactory createMockAuditServiceThreadFactoryWithMultipleCommand(Collection<AuditCommand> auditCommands, AuditServiceThread auditServiceThread) {
    // Create the mock instance
    AuditServiceThreadFactory auditServiceThreadFactory = EasyMock.createMock(AuditServiceThreadFactory.class);
    for (AuditCommand auditCommand : auditCommands) {
        // an auditServiceThread instance is create by the factory with the 
        // audit passed as argument. This thread is then launched
        EasyMock.expect(auditServiceThreadFactory.create(auditCommand)).andReturn(auditServiceThread).once();
    }
    // Set mock AuditServiceThreadFactory into testing mode.
    EasyMock.replay(auditServiceThreadFactory);
    return auditServiceThreadFactory;
}
Also used : AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 9 with AuditCommand

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

the class AuditServiceThreadImplTest method testInit.

public void testInit() {
    System.out.println("init");
    AuditCommand mockAuditCommand = createMock(AuditCommand.class);
    mockAuditCommand.init();
    expectLastCall().once();
    replay(mockAuditCommand);
    AuditServiceThreadImpl instance = initialiseAuditServiceThread(mockAuditCommand);
    instance.init();
    verify(mockAuditCommand);
}
Also used : AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 10 with AuditCommand

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

the class AuditServiceThreadImplTest method testAnalyse.

/**
     * Test of analyse method, of class AuditServiceThreadImpl.
     */
public void testAnalyse() {
    System.out.println("analyse");
    AuditCommand mockAuditCommand = createMock(AuditCommand.class);
    mockAuditCommand.analyse();
    expectLastCall().once();
    replay(mockAuditCommand);
    AuditServiceThreadImpl instance = initialiseAuditServiceThread(mockAuditCommand);
    instance.analyse();
    verify(mockAuditCommand);
}
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