/** * Alias for {@link #expectBetween(int, int, Threads, Query)} with arguments 0, {@code allowedStatements}, {@link Threads#CURRENT}, {@code queryType} * @since 2.2 */ @Deprecated public C expectAtMost(int allowedStatements, Query query) { return expect(SqlQueries.maxQueries(allowedStatements).type(adapter(query))); }
/** * @param threadMatcher chooses {@link Thread}s for calculating the number of executed queries * @return number of SQL statements executed since some fixed moment of time * @since 2.2 */ @Deprecated public int executedStatements(Threads threadMatcher, Query query) { checkOpened(); int count = 0; SqlStatement sqlStatement = adapter(query); Map<StatementMetaData, SqlStats> executedStatements = getExecutedStatements(threadMatcher, false); if (null != executedStatements) for (Map.Entry<StatementMetaData, SqlStats> entry : executedStatements.entrySet()) { StatementMetaData statementMetaData = entry.getKey(); SqlStats sqlStats = entry.getValue(); if ((sqlStatement == SqlStatement.ANY && statementMetaData.query != SqlStatement.SYSTEM) || sqlStatement == statementMetaData.query) { count += sqlStats.queries.intValue(); } } return count; }
/** * Executes the {@link Sniffer.Executable#execute()} method on provided argument and verifies the expectations * @throws SniffyAssertionError if wrong number of queries was executed * @since 2.0 */ @Deprecated public C execute(Sniffer.Executable executable) throws SniffyAssertionError { return execute((io.sniffy.Executable) executable); }
/** * Alias for {@link #verifyBetween(int, int, Threads, Query)} with arguments 0, {@code allowedStatements}, {@link Threads#CURRENT}, {@code queryType} * @since 2.2 */ @Deprecated public C verifyAtMost(int allowedStatements, Query query) throws WrongNumberOfQueriesError { return verify(SqlQueries.maxQueries(allowedStatements).type(adapter(query))); }
/** * Alias for {@link #verifyBetween(int, int, Threads, Query)} with arguments 0, 1, {@link Threads#CURRENT}, {@link Query#ANY} * @since 2.0 */ @Deprecated public C verifyAtMostOnce() throws WrongNumberOfQueriesError { return verify(SqlQueries.atMostOneQuery()); }
/** * Alias for {@link #expectBetween(int, int, Threads, Query)} with arguments 0, 1, {@link Threads#CURRENT}, {@link Query#ANY} * @since 2.0 */ @Deprecated public C expectAtMostOnce() { return expect(SqlQueries.atMostOneQuery()); }
/** * @return number of SQL statements executed by current thread since some fixed moment of time * @since 2.0 */ @Deprecated public int executedStatements() { return executedStatements(CURRENT); }
/** * Wrapper for {@link Sniffy#spy()} method; useful for chaining * @return a new {@link Spy} instance * @since 2.0 */ public C reset() { checkOpened(); super.reset(); expectations.clear(); return self(); }
/** * @return WrongNumberOfQueriesError or null if there are no errors * @since 2.1 */ @Deprecated public WrongNumberOfQueriesError getWrongNumberOfQueriesError() { WrongNumberOfQueriesError wrongNumberOfQueriesError = null; Throwable throwable = getSniffyAssertionError(); while (null != throwable) { if (throwable instanceof WrongNumberOfQueriesError) { if (null != wrongNumberOfQueriesError) { wrongNumberOfQueriesError.initCause(throwable); } wrongNumberOfQueriesError = (WrongNumberOfQueriesError) throwable; } throwable = throwable.getCause(); } return wrongNumberOfQueriesError; }
/** * Verifies that at least {@code minAllowedStatements} and at most * {@code maxAllowedStatements} were called between the creation of the current instance * and a call to {@link #verify()} method * @throws WrongNumberOfQueriesError if wrong number of queries was executed * @since 2.2 */ @Deprecated public C verifyBetween(int minAllowedStatements, int maxAllowedStatements, Query query) throws WrongNumberOfQueriesError { return verify(SqlQueries.queriesBetween(minAllowedStatements, maxAllowedStatements).type(adapter(query))); }
/** * Alias for {@link #verifyBetween(int, int, Threads, Query)} with arguments {@code allowedStatements}, {@link Integer#MAX_VALUE}, {@link Threads#CURRENT}, {@link Query#ANY} * @since 2.0 */ @Deprecated public C verifyAtLeast(int allowedStatements) throws WrongNumberOfQueriesError { return verify(SqlQueries.minQueries(allowedStatements)); }
/** * Alias for {@link #expectBetween(int, int, Threads, Query)} with arguments 0, {@code allowedStatements}, {@link Threads#CURRENT}, {@link Query#ANY} * @since 2.0 */ @Deprecated public C expectAtMost(int allowedStatements) { return expect(SqlQueries.maxQueries(allowedStatements)); }
/** * @return number of SQL statements executed by current thread since some fixed moment of time * @since 2.0 */ @Deprecated public int executedStatements() { return executedStatements(CURRENT); }
/** * Wrapper for {@link Sniffy#spy()} method; useful for chaining * @return a new {@link Spy} instance * @since 2.0 */ public C reset() { checkOpened(); super.reset(); expectations.clear(); return self(); }
/** * @return WrongNumberOfQueriesError or null if there are no errors * @since 2.1 */ @Deprecated public WrongNumberOfQueriesError getWrongNumberOfQueriesError() { WrongNumberOfQueriesError wrongNumberOfQueriesError = null; Throwable throwable = getSniffyAssertionError(); while (null != throwable) { if (throwable instanceof WrongNumberOfQueriesError) { if (null != wrongNumberOfQueriesError) { wrongNumberOfQueriesError.initCause(throwable); } wrongNumberOfQueriesError = (WrongNumberOfQueriesError) throwable; } throwable = throwable.getCause(); } return wrongNumberOfQueriesError; }
/** * Adds an expectation to the current instance that at least {@code minAllowedStatements} and at most * {@code maxAllowedStatements} were called between the creation of the current instance * and a call to {@link #verify()} method * @since 2.2 */ @Deprecated public C expectBetween(int minAllowedStatements, int maxAllowedStatements, Query query) { return expect(SqlQueries.queriesBetween(minAllowedStatements, maxAllowedStatements).type(adapter(query))); }
/** * Verifies that at least {@code minAllowedStatements} and at most * {@code maxAllowedStatements} were called between the creation of the current instance * and a call to {@link #verify()} method * @throws WrongNumberOfQueriesError if wrong number of queries was executed * @since 2.2 */ @Deprecated public C verifyBetween(int minAllowedStatements, int maxAllowedStatements, Query query) throws WrongNumberOfQueriesError { return verify(SqlQueries.queriesBetween(minAllowedStatements, maxAllowedStatements).type(adapter(query))); }
/** * @param threadMatcher chooses {@link Thread}s for calculating the number of executed queries * @return number of SQL statements executed since some fixed moment of time * @since 2.2 */ @Deprecated public int executedStatements(Threads threadMatcher, Query query) { checkOpened(); int count = 0; SqlStatement sqlStatement = adapter(query); Map<StatementMetaData, SqlStats> executedStatements = getExecutedStatements(threadMatcher, false); if (null != executedStatements) for (Map.Entry<StatementMetaData, SqlStats> entry : executedStatements.entrySet()) { StatementMetaData statementMetaData = entry.getKey(); SqlStats sqlStats = entry.getValue(); if ((sqlStatement == SqlStatement.ANY && statementMetaData.query != SqlStatement.SYSTEM) || sqlStatement == statementMetaData.query) { count += sqlStats.queries.intValue(); } } return count; }
/** * Alias for {@link #verifyBetween(int, int, Threads, Query)} with arguments {@code allowedStatements}, {@code allowedStatements}, {@link Threads#CURRENT}, {@link Query#ANY} * @since 2.0 */ @Deprecated public C verify(int allowedStatements) throws WrongNumberOfQueriesError { return verify(SqlQueries.exactQueries(allowedStatements)); }
/** * Alias for {@link #expectBetween(int, int, Threads, Query)} with arguments {@code minAllowedStatements}, {@code maxAllowedStatements}, {@link Threads#CURRENT}, {@link Query#ANY} * @since 2.0 */ @Deprecated public C expectBetween(int minAllowedStatements, int maxAllowedStatements) { return expect(SqlQueries.queriesBetween(minAllowedStatements, maxAllowedStatements)); }