InsertStatementHandler implements SQLStatementHandler { public static Optional<OnDuplicateKeyColumnsSegment> getOnDuplicateKeyColumnsSegment(final InsertStatement insertStatement) { if (insertStatement instanceof MySQLStatement) { return ((MySQLInsertStatement) insertStatement).getOnDuplicateKeyColumns(); } return Optional.empty(); }  static Optional<OnDuplicateKeyColumnsSegment> getOnDuplicateKeyColumnsSegment(final InsertStatement insertStatement); static Optional<SetAssignmentSegment> getSetAssignmentSegment(final InsertStatement insertStatement); static Optional<WithSegment> getWithSegment(final InsertStatement insertStatement); static Optional<OutputSegment> getOutputSegment(final InsertStatement insertStatement);  }
@Test public void assertGetOnDuplicateKeyColumnsSegmentWithOnDuplicateKeyColumnsSegmentForMySQL() { MySQLInsertStatement insertStatement = new MySQLInsertStatement(); insertStatement.setOnDuplicateKeyColumns(new OnDuplicateKeyColumnsSegment(0, 0, Collections.emptyList())); Optional<OnDuplicateKeyColumnsSegment> onDuplicateKeyColumnsSegment = InsertStatementHandler.getOnDuplicateKeyColumnsSegment(insertStatement); assertTrue(onDuplicateKeyColumnsSegment.isPresent()); }
@Test public void assertGetOnDuplicateKeyColumnsSegmentWithoutOnDuplicateKeyColumnsSegmentForMySQL() { MySQLInsertStatement insertStatement = new MySQLInsertStatement(); Optional<OnDuplicateKeyColumnsSegment> onDuplicateKeyColumnsSegment = InsertStatementHandler.getOnDuplicateKeyColumnsSegment(insertStatement); assertFalse(onDuplicateKeyColumnsSegment.isPresent()); }