SQLLogger { public static void logSQL(final LogicSQL logicSQL, final boolean showSimple, final ExecutionContext executionContext) { log("Logic SQL: {}", logicSQL.getSql()); log("SQLStatement: {}", logicSQL.getSqlStatementContext()); if (showSimple) { logSimpleMode(executionContext.getExecutionUnits()); } else { logNormalMode(executionContext.getExecutionUnits()); } }  static void logSQL(final LogicSQL logicSQL, final boolean showSimple, final ExecutionContext executionContext);  }
@Test public void assertLogNormalSQLWithoutParameter() { SQLLogger.logSQL(logicSQL, false, new ExecutionContext(null, executionUnits, mock(RouteContext.class))); InOrder inOrder = inOrder(logger); inOrder.verify(logger).info("Logic SQL: {}", new Object[]{SQL}); inOrder.verify(logger).info("SQLStatement: {}", new Object[]{null}); inOrder.verify(logger).info("Actual SQL: {} ::: {}", new Object[]{"db1", SQL}); inOrder.verify(logger).info("Actual SQL: {} ::: {}", new Object[]{"db2", SQL}); inOrder.verify(logger).info("Actual SQL: {} ::: {}", new Object[]{"db3", SQL}); }
@Test public void assertLogNormalSQLWithParameters() { List<Object> parameters = executionUnits.iterator().next().getSqlUnit().getParameters(); parameters.add("parameter"); SQLLogger.logSQL(logicSQL, false, new ExecutionContext(null, executionUnits, mock(RouteContext.class))); InOrder inOrder = inOrder(logger); inOrder.verify(logger).info("Logic SQL: {}", new Object[]{SQL}); inOrder.verify(logger).info("SQLStatement: {}", new Object[]{null}); inOrder.verify(logger).info("Actual SQL: {} ::: {} ::: {}", "db1", SQL, parameters); inOrder.verify(logger).info("Actual SQL: {} ::: {}", new Object[]{"db2", SQL}); inOrder.verify(logger).info("Actual SQL: {} ::: {}", new Object[]{"db3", SQL}); }
@Test public void assertLogSimpleSQL() { SQLLogger.logSQL(logicSQL, true, new ExecutionContext(null, executionUnits, mock(RouteContext.class))); InOrder inOrder = inOrder(logger); inOrder.verify(logger).info("Logic SQL: {}", new Object[]{SQL}); inOrder.verify(logger).info("SQLStatement: {}", new Object[]{null}); inOrder.verify(logger).info("Actual SQL(simple): {} ::: {}", new Object[]{buildDataSourceNames(), executionUnits.size()}); }