### Question:
SqlQueryMaxExecutionTimeVerifier implements VerifiablePerformanceIssue<ExpectMaxQueryExecutionTime, ExecutionTime> { @Override public PerfIssue verifyPerfIssue(ExpectMaxQueryExecutionTime annotation, ExecutionTime measure) { ExecutionTime maxExpectedSqlExecutionTime = new ExecutionTime(annotation.thresholdInMilliSeconds(), TimeUnit.MILLISECONDS); if(measure.isGreaterThan(maxExpectedSqlExecutionTime)) { return buildPerfIssue(measure, maxExpectedSqlExecutionTime); } return PerfIssue.NONE; } private  SqlQueryMaxExecutionTimeVerifier(); @Override PerfIssue verifyPerfIssue(ExpectMaxQueryExecutionTime annotation, ExecutionTime measure); static final SqlQueryMaxExecutionTimeVerifier INSTANCE; }### Answer:
@Test public void should_return_a_perf_issue_if_query_execution_time_is_greater_than_expected() { VerifiablePerformanceIssue<ExpectMaxQueryExecutionTime, ExecutionTime> verifier = SqlQueryMaxExecutionTimeVerifier.INSTANCE; ExpectMaxQueryExecutionTime expectedMaxExecutionTime = SqlAnnotationBuilder.expectMaxQueryExecutionTime(1); ExecutionTime sqlExecTime = new ExecutionTime(5, TimeUnit.MILLISECONDS); PerfIssue perfIssue = verifier.verifyPerfIssue(expectedMaxExecutionTime, sqlExecTime); Assertions.assertThat(PerfIssue.NONE).isNotEqualTo(perfIssue); Assertions.assertThat(PerfIssue.NONE.getDescription()).isNotEqualTo(perfIssue.getDescription()); Assertions.assertThat(perfIssue.getDescription()) .contains("Query execution time expected to be less than <1 ms>") .contains("At least one query has a greater execution time. The greater query execution time is <5 ms>"); }
@Test public void should_return_no_perf_issue_if_query_execution_time_is_less_than_expected() { VerifiablePerformanceIssue<ExpectMaxQueryExecutionTime, ExecutionTime> verifier = SqlQueryMaxExecutionTimeVerifier.INSTANCE; ExpectMaxQueryExecutionTime expectedMaxExecutionTime = SqlAnnotationBuilder.expectMaxQueryExecutionTime(5); ExecutionTime sqlExecTime = new ExecutionTime(1, TimeUnit.MILLISECONDS); PerfIssue perfIssue = verifier.verifyPerfIssue(expectedMaxExecutionTime, sqlExecTime); Assertions.assertThat(PerfIssue.NONE).isEqualTo(perfIssue); Assertions.assertThat(PerfIssue.NONE.getDescription()).isEqualTo(perfIssue.getDescription()); }
@Test public void should_return_no_perf_issue_if_query_execution_time_is_same_as_expected() { VerifiablePerformanceIssue<ExpectMaxQueryExecutionTime, ExecutionTime> verifier = SqlQueryMaxExecutionTimeVerifier.INSTANCE; ExpectMaxQueryExecutionTime expectedMaxExecutionTime = SqlAnnotationBuilder.expectMaxQueryExecutionTime(1); ExecutionTime sqlExecTime = new ExecutionTime(1, TimeUnit.MILLISECONDS); PerfIssue perfIssue = verifier.verifyPerfIssue(expectedMaxExecutionTime, sqlExecTime); Assertions.assertThat(PerfIssue.NONE).isEqualTo(perfIssue); Assertions.assertThat(PerfIssue.NONE.getDescription()).isEqualTo(perfIssue.getDescription()); }