DropIndexStatementHandler implements SQLStatementHandler { public static Optional<SimpleTableSegment> getSimpleTableSegment(final DropIndexStatement dropIndexStatement) { if (dropIndexStatement instanceof MySQLStatement) { return ((MySQLDropIndexStatement) dropIndexStatement).getTable(); } if (dropIndexStatement instanceof SQLServerStatement) { return ((SQLServerDropIndexStatement) dropIndexStatement).getTable(); } return Optional.empty(); }  static Optional<SimpleTableSegment> getSimpleTableSegment(final DropIndexStatement dropIndexStatement);  }
@Test public void assertGetSimpleTableSegmentWithSimpleTableSegmentForMySQL() { MySQLDropIndexStatement dropIndexStatement = new MySQLDropIndexStatement(); dropIndexStatement.setTable(new SimpleTableSegment(0, 0, new IdentifierValue(""))); Optional<SimpleTableSegment> simpleTableSegment = DropIndexStatementHandler.getSimpleTableSegment(dropIndexStatement); assertTrue(simpleTableSegment.isPresent()); }
@Test public void assertGetSimpleTableSegmentWithoutSimpleTableSegmentForMySQL() { MySQLDropIndexStatement dropIndexStatement = new MySQLDropIndexStatement(); Optional<SimpleTableSegment> simpleTableSegment = DropIndexStatementHandler.getSimpleTableSegment(dropIndexStatement); assertFalse(simpleTableSegment.isPresent()); }
@Test public void assertGetSimpleTableSegmentWithSimpleTableSegmentForSQLServer() { SQLServerDropIndexStatement dropIndexStatement = new SQLServerDropIndexStatement(); dropIndexStatement.setTable(new SimpleTableSegment(0, 0, new IdentifierValue(""))); Optional<SimpleTableSegment> simpleTableSegment = DropIndexStatementHandler.getSimpleTableSegment(dropIndexStatement); assertTrue(simpleTableSegment.isPresent()); }
@Test public void assertGetSimpleTableSegmentWithoutSimpleTableSegmentForSQLServer() { SQLServerDropIndexStatement dropIndexStatement = new SQLServerDropIndexStatement(); Optional<SimpleTableSegment> simpleTableSegment = DropIndexStatementHandler.getSimpleTableSegment(dropIndexStatement); assertFalse(simpleTableSegment.isPresent()); }