@Test public void exceptionLoggingTest() { PreparedStatementHook hook = new PreparedStatementHook(timer, platformManager, statementStorage, connectionMetaDataStorage, statementReflectionCache, parameter); hook.log = log; hook.afterConstructor(null, 1, 10, "someObject", null, null); hook.afterConstructor(null, 1, 10, "someObject", null, null); hook.afterConstructor(null, 1, 10, "someObject", null, null); hook.afterConstructor(null, 1, 10, "someObject", null, null); hook.afterConstructor(null, 1, 10, "someObject", null, null); hook.afterConstructor(null, 1, 10, "someObject", null, null); Mockito.verify(log, Mockito.times(1)).info(Matchers.anyString(), Matchers.eq(myNoSuchElementException)); hook.afterConstructor(null, 2, 10, "someObject", null, null); hook.afterConstructor(null, 2, 10, "someObject", null, null); hook.afterConstructor(null, 2, 10, "someObject", null, null); hook.afterConstructor(null, 2, 10, "someObject", null, null); hook.afterConstructor(null, 2, 10, "someObject", null, null); Mockito.verify(log, Mockito.times(2)).info(Matchers.anyString(), Matchers.eq(myNoSuchElementException)); }
@Override public void afterConstructor(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc) { try { statementStorage.addPreparedStatement(object); } catch (NoSuchElementException e) { Long methodIdLong = Long.valueOf(methodId); if (preparedStatementsWithExceptions.contains(methodIdLong)) { return; } log.info("Could not add prepared statement, no sql available! Method ID(local): " + methodId); log.info( "This is not an inspectIT issue, but you forgot to integrate the Connection creating the SQL statement in the configuration, please consult the management of inspectIT and send the following stacktrace!", e); List<Long> clonedList = new ArrayList<Long>(preparedStatementsWithExceptions); clonedList.add(methodIdLong); preparedStatementsWithExceptions = clonedList; } }
PreparedStatementHook implements IMethodHook, IConstructorHook { @Override public void afterConstructor(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc) { try { statementStorage.addPreparedStatement(object); } catch (NoSuchElementException e) { Long methodIdLong = Long.valueOf(methodId); if (preparedStatementsWithExceptions.contains(methodIdLong)) { return; } log.info("Could not add prepared statement, no sql available! Method ID(local): " + methodId); log.info( "This is not an inspectIT issue, but you forgot to integrate the Connection creating the SQL statement in the configuration, please consult the management of inspectIT and send the following stacktrace!", e); List<Long> clonedList = new ArrayList<Long>(preparedStatementsWithExceptions); clonedList.add(methodIdLong); preparedStatementsWithExceptions = clonedList; } } }
PreparedStatementHook implements IMethodHook, IConstructorHook { @Override public void afterConstructor(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc) { try { statementStorage.addPreparedStatement(object); } catch (NoSuchElementException e) { Long methodIdLong = Long.valueOf(methodId); if (preparedStatementsWithExceptions.contains(methodIdLong)) { return; } log.info("Could not add prepared statement, no sql available! Method ID(local): " + methodId); log.info( "This is not an inspectIT issue, but you forgot to integrate the Connection creating the SQL statement in the configuration, please consult the management of inspectIT and send the following stacktrace!", e); List<Long> clonedList = new ArrayList<Long>(preparedStatementsWithExceptions); clonedList.add(methodIdLong); preparedStatementsWithExceptions = clonedList; } } PreparedStatementHook(Timer timer, IPlatformManager platformManager, StatementStorage statementStorage, ConnectionMetaDataStorage connectionMetaDataStorage,
			StatementReflectionCache statementReflectionCache, Map<String, Object> parameter); }
PreparedStatementHook implements IMethodHook, IConstructorHook { @Override public void afterConstructor(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc) { try { statementStorage.addPreparedStatement(object); } catch (NoSuchElementException e) { Long methodIdLong = Long.valueOf(methodId); if (preparedStatementsWithExceptions.contains(methodIdLong)) { return; } log.info("Could not add prepared statement, no sql available! Method ID(local): " + methodId); log.info( "This is not an inspectIT issue, but you forgot to integrate the Connection creating the SQL statement in the configuration, please consult the management of inspectIT and send the following stacktrace!", e); List<Long> clonedList = new ArrayList<Long>(preparedStatementsWithExceptions); clonedList.add(methodIdLong); preparedStatementsWithExceptions = clonedList; } } PreparedStatementHook(Timer timer, IPlatformManager platformManager, StatementStorage statementStorage, ConnectionMetaDataStorage connectionMetaDataStorage,
			StatementReflectionCache statementReflectionCache, Map<String, Object> parameter); @Override void beforeBody(long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc); @Override void firstAfterBody(long methodId, long sensorTypeId, Object object, Object[] parameters, Object result, boolean exception, RegisteredSensorConfig rsc); @Override void secondAfterBody(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, Object result, boolean exception, RegisteredSensorConfig rsc); @Override void beforeConstructor(long methodId, long sensorTypeId, Object[] parameters, RegisteredSensorConfig rsc); @Override void afterConstructor(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc); }
PreparedStatementHook implements IMethodHook, IConstructorHook { @Override public void afterConstructor(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc) { try { statementStorage.addPreparedStatement(object); } catch (NoSuchElementException e) { Long methodIdLong = Long.valueOf(methodId); if (preparedStatementsWithExceptions.contains(methodIdLong)) { return; } log.info("Could not add prepared statement, no sql available! Method ID(local): " + methodId); log.info( "This is not an inspectIT issue, but you forgot to integrate the Connection creating the SQL statement in the configuration, please consult the management of inspectIT and send the following stacktrace!", e); List<Long> clonedList = new ArrayList<Long>(preparedStatementsWithExceptions); clonedList.add(methodIdLong); preparedStatementsWithExceptions = clonedList; } } PreparedStatementHook(Timer timer, IPlatformManager platformManager, StatementStorage statementStorage, ConnectionMetaDataStorage connectionMetaDataStorage,
			StatementReflectionCache statementReflectionCache, Map<String, Object> parameter); @Override void beforeBody(long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc); @Override void firstAfterBody(long methodId, long sensorTypeId, Object object, Object[] parameters, Object result, boolean exception, RegisteredSensorConfig rsc); @Override void secondAfterBody(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, Object result, boolean exception, RegisteredSensorConfig rsc); @Override void beforeConstructor(long methodId, long sensorTypeId, Object[] parameters, RegisteredSensorConfig rsc); @Override void afterConstructor(ICoreService coreService, long methodId, long sensorTypeId, Object object, Object[] parameters, RegisteredSensorConfig rsc);  }