SelectStatementHandler implements SQLStatementHandler { public static Optional<LimitSegment> getLimitSegment(final SelectStatement selectStatement) { if (selectStatement instanceof MySQLStatement) { return ((MySQLSelectStatement) selectStatement).getLimit(); } if (selectStatement instanceof PostgreSQLStatement) { return ((PostgreSQLSelectStatement) selectStatement).getLimit(); } if (selectStatement instanceof SQL92Statement) { return ((SQL92SelectStatement) selectStatement).getLimit(); } if (selectStatement instanceof SQLServerStatement) { return ((SQLServerSelectStatement) selectStatement).getLimit(); } return Optional.empty(); }  static Optional<LimitSegment> getLimitSegment(final SelectStatement selectStatement); static Optional<LockSegment> getLockSegment(final SelectStatement selectStatement);  }
@Test public void assertGetLimitSegmentWithLimitSegmentForMySQL() { MySQLSelectStatement selectStatement = new MySQLSelectStatement(); selectStatement.setLimit(new LimitSegment(0, 0, null, null)); Optional<LimitSegment> limitSegment = SelectStatementHandler.getLimitSegment(selectStatement); assertTrue(limitSegment.isPresent()); }
@Test public void assertGetLimitSegmentWithoutLimitSegmentForMySQL() { MySQLSelectStatement selectStatement = new MySQLSelectStatement(); Optional<LimitSegment> limitSegment = SelectStatementHandler.getLimitSegment(selectStatement); assertFalse(limitSegment.isPresent()); }
@Test public void assertGetLimitSegmentWithLimitSegmentForPostgreSQL() { PostgreSQLSelectStatement selectStatement = new PostgreSQLSelectStatement(); selectStatement.setLimit(new LimitSegment(0, 0, null, null)); Optional<LimitSegment> limitSegment = SelectStatementHandler.getLimitSegment(selectStatement); assertTrue(limitSegment.isPresent()); }
@Test public void assertGetLimitSegmentWithoutLimitSegmentForPostgreSQL() { PostgreSQLSelectStatement selectStatement = new PostgreSQLSelectStatement(); Optional<LimitSegment> limitSegment = SelectStatementHandler.getLimitSegment(selectStatement); assertFalse(limitSegment.isPresent()); }
@Test public void assertGetLimitSegmentWithLimitSegmentForSQL92() { SQL92SelectStatement selectStatement = new SQL92SelectStatement(); selectStatement.setLimit(new LimitSegment(0, 0, null, null)); Optional<LimitSegment> limitSegment = SelectStatementHandler.getLimitSegment(selectStatement); assertTrue(limitSegment.isPresent()); }
@Test public void assertGetLimitSegmentWithoutLimitSegmentForSQL92() { SQL92SelectStatement selectStatement = new SQL92SelectStatement(); Optional<LimitSegment> limitSegment = SelectStatementHandler.getLimitSegment(selectStatement); assertFalse(limitSegment.isPresent()); }
@Test public void assertGetLimitSegmentWithLimitSegmentForSQLServer() { SQLServerSelectStatement selectStatement = new SQLServerSelectStatement(); selectStatement.setLimit(new LimitSegment(0, 0, null, null)); Optional<LimitSegment> limitSegment = SelectStatementHandler.getLimitSegment(selectStatement); assertTrue(limitSegment.isPresent()); }
@Test public void assertGetLimitSegmentWithoutLimitSegmentForSQLServer() { SQLServerSelectStatement selectStatement = new SQLServerSelectStatement(); Optional<LimitSegment> limitSegment = SelectStatementHandler.getLimitSegment(selectStatement); assertFalse(limitSegment.isPresent()); }