Search in sources :

Example 1 with MultiProviderAuditor

use of org.nhindirect.common.audit.impl.MultiProviderAuditor in project nhin-d by DirectProject.

the class AuditorFactoryTest method testCreateAuditor_MultiSPIImplementation_AssertCreatedSPIAuditor.

@Test
public void testCreateAuditor_MultiSPIImplementation_AssertCreatedSPIAuditor() throws Exception {
    setupSPIImplementation(NoOpAuditor.class);
    setupSPIImplementation(LoggingAuditor.class);
    Auditor auditor = AuditorFactory.createAuditor();
    assertNotNull(auditor);
    assertTrue(auditor instanceof MultiProviderAuditor);
}
Also used : LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) Test(org.junit.Test)

Example 2 with MultiProviderAuditor

use of org.nhindirect.common.audit.impl.MultiProviderAuditor in project nhin-d by DirectProject.

the class SPIAuditorProviderTest method testCreateSingleAuditorFromSPI_NonNullConstructor_AssertMutliProviderAuditorCreated.

@Test
public void testCreateSingleAuditorFromSPI_NonNullConstructor_AssertMutliProviderAuditorCreated() throws Exception {
    setupSPIImplementation(LoggingAuditor.class);
    setupSPIImplementation(NoOpAuditor.class);
    SPIAuditorProvider prov = new SPIAuditorProvider(Auditor.class.getClassLoader());
    assertTrue(prov.isImplementationAvailable());
    assertNotNull(prov.get());
    assertTrue(prov.get() instanceof MultiProviderAuditor);
}
Also used : LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Auditor(org.nhindirect.common.audit.Auditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) SPIAuditorProvider(org.nhindirect.common.audit.provider.SPIAuditorProvider) Test(org.junit.Test)

Example 3 with MultiProviderAuditor

use of org.nhindirect.common.audit.impl.MultiProviderAuditor in project nhin-d by DirectProject.

the class MultiProviderAuditorTest method testAuditEvent.

@Test
public void testAuditEvent() {
    Auditor auditor = new MultiProviderAuditor(Arrays.asList(new LoggingAuditor(), new NoOpAuditor()));
    auditor.audit(PRINCIPAL, UNIT_TEST_EVENT);
}
Also used : LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Auditor(org.nhindirect.common.audit.Auditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Test(org.junit.Test)

Example 4 with MultiProviderAuditor

use of org.nhindirect.common.audit.impl.MultiProviderAuditor in project nhin-d by DirectProject.

the class MultiProviderAuditorTest method testAuditCategoryAndMessage_EmptyPrincipal_AssertExeption.

@Test
public void testAuditCategoryAndMessage_EmptyPrincipal_AssertExeption() {
    Auditor auditor = new MultiProviderAuditor(Arrays.asList(new LoggingAuditor(), new NoOpAuditor()));
    boolean exceptionOccured = false;
    try {
        auditor.audit("", UNIT_TEST_EVENT);
    } catch (IllegalArgumentException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Auditor(org.nhindirect.common.audit.Auditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Test(org.junit.Test)

Example 5 with MultiProviderAuditor

use of org.nhindirect.common.audit.impl.MultiProviderAuditor in project nhin-d by DirectProject.

the class MultiProviderAuditorTest method testAudit_NullPrincipal_AssertExeption.

@Test
public void testAudit_NullPrincipal_AssertExeption() {
    Auditor auditor = new MultiProviderAuditor(Arrays.asList(new LoggingAuditor(), new NoOpAuditor()));
    boolean exceptionOccured = false;
    try {
        auditor.audit(null, UNIT_TEST_EVENT);
    } catch (IllegalArgumentException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Auditor(org.nhindirect.common.audit.Auditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 MultiProviderAuditor (org.nhindirect.common.audit.impl.MultiProviderAuditor)12 LoggingAuditor (org.nhindirect.common.audit.impl.LoggingAuditor)9 NoOpAuditor (org.nhindirect.common.audit.impl.NoOpAuditor)9 Auditor (org.nhindirect.common.audit.Auditor)7 SPIAuditorProvider (org.nhindirect.common.audit.provider.SPIAuditorProvider)3 MultiProviderAuditorProvider (org.nhindirect.common.audit.provider.MultiProviderAuditorProvider)2 Provider (com.google.inject.Provider)1 DefaultAuditContext (org.nhindirect.common.audit.DefaultAuditContext)1 LoggingAuditorProvider (org.nhindirect.common.audit.provider.LoggingAuditorProvider)1 NoOpAuditorProvider (org.nhindirect.common.audit.provider.NoOpAuditorProvider)1