@Test public void testAudit() { SecurityEvent securityEvent = new SecurityEvent(); securityEvent.setClassName(this.getClass().getName()); securityEvent.setLogMessage("Test Message"); securityEvent.setLogLevel(LogLevelType.TYPE_TRACE); audit(securityEvent); Mockito.verify(mockedEntityRepository, times(1)).create(any(String.class), any(Map.class), any(Map.class), any(String.class)); }
public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } }
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } } }
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } } @Autowired  LogUtil(@Qualifier("secondaryRepo") Repository<Entity> repo); }
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } } @Autowired  LogUtil(@Qualifier("secondaryRepo") Repository<Entity> repo); static void audit(SecurityEvent event); static Repository<Entity> getEntityRepository(); static void setEntityRepository(Repository<Entity> entityRepository); }
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } } @Autowired  LogUtil(@Qualifier("secondaryRepo") Repository<Entity> repo); static void audit(SecurityEvent event); static Repository<Entity> getEntityRepository(); static void setEntityRepository(Repository<Entity> entityRepository);  }