AuditRepositoryOrchImpl { public AcknowledgementType logAudit(LogEventSecureRequestType mess, AssertionType assertion) { AcknowledgementType response = new AcknowledgementType(); StringBuilder builder = new StringBuilder(); if (isLoggingToDatabaseOn()) { builder.append(logToDatabase(mess, assertion)); } if (isLoggingToAuditFileOn()) { builder.append(logToAuditFile(mess, assertion)); } response.setMessage(builder.toString()); return response; } AuditRepositoryOrchImpl(); AcknowledgementType logAudit(LogEventSecureRequestType mess, AssertionType assertion); FindCommunitiesAndAuditEventsResponseType findAudit(FindAuditEventsType query);  }
@Test public void testLogAudit() { AuditRepositoryOrchImpl auditRepo = new AuditRepositoryOrchImpl() { @Override protected boolean isLoggingToDatabaseOn() { return false; } @Override protected boolean isLoggingToAuditFileOn() { return true; } }; AuditFileStoreImpl mockFileStore = mock(AuditFileStoreImpl.class); when(mockFileStore.saveAuditRecord(any(LogEventSecureRequestType.class), any(AssertionType.class))) .thenReturn(Boolean.TRUE); AcknowledgementType ack = auditRepo.logAudit(new LogEventSecureRequestType(), new AssertionType()); assertEquals("AcknowledgementType message mismatch", ack.getMessage(), "Created Log Message in Audit File..."); }