name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
morf_AbstractSqlDialectTest_testMathsMultiply_rdh
/** * Test that adding numbers returns as expected. */ @Test public void testMathsMultiply() { String result = testDialect.getSqlFrom(new MathsField(new FieldLiteral(1), MathsOperator.MULTIPLY, new FieldLiteral(1))); assertEquals(expectedMathsMultiply(), result); }
3.26
morf_AbstractSqlDialectTest_testSelectOrderByNullsFirstDescendingScript_rdh
/** * Tests a select with an "order by" clause with nulls first and descending direction. */ @Test public void testSelectOrderByNullsFirstDescendingScript() { FieldReference fieldReference = new FieldReference(STRING_FIELD); SelectStatement stmt = new SelectStatement(fieldReference).from(new TableReference(ALTERNATE...
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations16_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions. */ @Test public void shouldGenerateCorrectSqlForMathOperations16() { String result = testDialect.getSqlFrom(field("a").plus(field("b")).plus(field("c")).divideBy(literal(2)).plus(field("z"))); assertEquals(expectedSqlForMathOperations16(...
3.26
morf_AbstractSqlDialectTest_expectedRightTrim_rdh
/** * * @return The expected SQL for a Left Trim */ protected String expectedRightTrim() { return "SELECT RTRIM(field1) FROM " + tableName("schedule"); }
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperationsForExistingDataFix4_rdh
/** * Regression test that checks if the DSL with Math expressions produces expected SQL. * * Calling: * * <pre> * field(&quot;vatRate / (vatRate + 100)&quot;) * </pre> * * is actually a hack that was used as a workaround in order to create the * expected SQL below. Since * {@link org.alfasoftware.morf.sql.S...
3.26
morf_AbstractSqlDialectTest_expectedUpdateUsingTargetTableInDifferentSchema_rdh
/** * * @return The expected SQL for performing an update with a destination table which lives in a different schema. */ protected String expectedUpdateUsingTargetTableInDifferentSchema() { return ((("UPDATE " + differentSchemaTableName("FloatingRateRate")) + " A SET settlementFrequency = (SELECT settlementFrequency...
3.26
morf_AbstractSqlDialectTest_testFormatSqlStatement_rdh
/** * Tests the {@link SqlDialect#formatSqlStatement(String)} performs * correctly. */ @Test public void testFormatSqlStatement() { expectedSqlStatementFormat(); }
3.26
morf_AbstractSqlDialectTest_testMergeSimple_rdh
/** * Tests a simple merge. */ @Test public void testMergeSimple() { TableReference foo = new TableReference("foo").as("foo"); TableReference somewhere = new TableReference("somewhere"); SelectStatement sourceStmt = new SelectStatement(somewhere.field("newId").as("id"), somewhere.field("newBar").as("bar")).from(somew...
3.26
morf_AbstractSqlDialectTest_expectedDateLiteral_rdh
/** * * @return The expected date literal. */ protected String expectedDateLiteral() { return "DATE '2010-01-02'"; }
3.26
morf_AbstractSqlDialectTest_testResultSetToRecord_rdh
/** * Tests non-null values are returned correctly from resultsets * * @throws SQLException * If a SQL exception is thrown. */ @Test public void testResultSetToRecord() throws SQLException { ResultSet resultSet = mock(ResultSet.class); List<DataType> dataTypes = Arrays.asList(DataType.values()); List<Column> col...
3.26
morf_AbstractSqlDialectTest_testDropTables_rdh
/** * Tests SQL for dropping a tables with optional parameters. */ @Test public void testDropTables() { Table table1 = metadata.getTable(TEST_TABLE); Table table2 = metadata.getTable(OTHER_TABLE); compareStatements(m25(), testDialect.dropTables(ImmutableList.of(table1), false, false)); compareStatemen...
3.26
morf_AbstractSqlDialectTest_testGetSqlForLeftPad_rdh
/** * Tests that the Left pad works. */ @Test public void testGetSqlForLeftPad() { // Given Function leftPad = leftPad(new FieldReference(STRING_FIELD), new FieldLiteral(10), new FieldLiteral("j")); SelectStatement leftPadStatement = new SelectStatement(leftPad).from(new TableReference(TEST_TABLE)); // When String r...
3.26
morf_AbstractSqlDialectTest_testAddBigIntegerColumn_rdh
/** * Test adding a big integer column. */ @Test public void testAddBigIntegerColumn() { testAlterTableColumn(AlterationType.ADD, column("bigIntegerField_new", DataType.BIG_INTEGER).nullable(), expectedAlterTableAddBigIntegerColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_testSelectWithExceptStatement_rdh
/** * Tests the generation of SQL string for a query with EXCEPT operator. */ @Test public void testSelectWithExceptStatement() { assumeTrue("for dialects with no EXCEPT operation support the test will be skipped.", expectedSelectWithExcept() != null); SelectStatement stmt = new SelectStatement(new FieldReference(ST...
3.26
morf_AbstractSqlDialectTest_expectedUpdateUsingSourceTableInDifferentSchema_rdh
/** * * @return The expected SQL for performing an update with a source table which lives in a different schema. */ protected String expectedUpdateUsingSourceTableInDifferentSchema() { return ("UPDATE " + tableName("FloatingRateRate")) + " A SET settlementFrequency = (SELECT settlementFrequency FROM MYSCHEMA.Floatin...
3.26
morf_AbstractSqlDialectTest_testSelectWithJoinForUpdate_rdh
/** * Tests that we can't combine JOIN with FOR UPDATE */ @Test(expected = IllegalArgumentException.class) public void testSelectWithJoinForUpdate() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).crossJoin(new TableReference("Test2")).forUpdate(); testDialect.convertStatem...
3.26
morf_AbstractSqlDialectTest_setUp_rdh
/** * Initialise the fixture state. */ @Before public void setUp() { // Get the candidate dialect to test testDialect = createTestDialect(); // Main test table testTable = table(TEST_TABLE).columns(idColumn(), versionColumn(), column(STRING_FIELD, DataType.STRING, 3).nullable(), column(INT_FIELD, Data...
3.26
morf_AbstractSqlDialectTest_testCaseWithStrings_rdh
/** * Test an update statement with case in it. */ @Test public void testCaseWithStrings() { CaseStatement enabledWhenAutoRunIsT = new CaseStatement(new FieldLiteral("DISABLED"), new WhenCondition(eq(new FieldReference("autorunBackgroundProcess"), new FieldLiteral("Y")), new FieldLiteral("ENABLED"))); UpdateStatement...
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations12_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions * that use brackets. */ @Test public void shouldGenerateCorrectSqlForMathOperations12() { String result = testDialect.getSqlFrom(bracket(field("a").plus(field("b"))).divideBy(field("c"))); assertEquals(expectedSqlForMathOperations12(), r...
3.26
morf_AbstractSqlDialectTest_m11_rdh
/** * Test that AddMonths functionality behaves as expected. */ @Test public void m11() { String result = testDialect.getSqlFrom(addMonths(field("testField"), new FieldLiteral(-3))); assertEquals(expectedAddMonths(), result); }
3.26
morf_AbstractSqlDialectTest_expectedRound_rdh
/** * * @return The expected SQL for rounding */ protected String expectedRound() { return "SELECT ROUND(field1, 2) FROM " + tableName("schedule"); }
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations4_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions. * <p> * Bracket should be generated for subexpression "b+100". Even without explicit * {@link org.alfasoftware.morf.sql.SqlUtils#bracket(MathsField)} call. * </p> */ @Test public void shouldGenerateCorrectSqlForMathOperations4() { St...
3.26
morf_AbstractSqlDialectTest_m20_rdh
/** * Test adding a unique index. */ @SuppressWarnings("unchecked") @Test public void m20() { Table table = metadata.getTable(TEST_TABLE);Index index = index("indexName").unique().columns(table.columns().get(0).getName()); compareStatements(expectedAddIndexStatementsUnique(), testDialect.addIndexStatements(table, ind...
3.26
morf_AbstractSqlDialectTest_expectedHints5_rdh
/** * * @return The expected SQL when no hint directive is used on the {@link InsertStatement}. */ private String expectedHints5() { return (("INSERT INTO " + tableName("Foo")) + " SELECT a, b FROM ") + tableName("Foo_1");}
3.26
morf_AbstractSqlDialectTest_testAlterColumnMakePrimary_rdh
/** * Test changing column to be the primary key. */ @Test public void testAlterColumnMakePrimary() { testAlterTableColumn(TEST_TABLE, AlterationType.ALTER, getColumn(TEST_TABLE, DATE_FIELD), column(DATE_FIELD, DataType.DATE).nullable().primaryKey(), expectedAlterColumnMakePrimaryStatements()); }
3.26
morf_AbstractSqlDialectTest_testAlterDecimalColumn_rdh
/** * Test altering a floating point column. */ @Test public void testAlterDecimalColumn() { testAlterTableColumn(TEST_TABLE, AlterationType.ALTER, getColumn(TEST_TABLE, FLOAT_FIELD), column(FLOAT_FIELD, DataType.DECIMAL, 14, 3).nullable(), expectedAlterTableAlterDecimalColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_verifyPostInsertStatementsNotInsertingUnderAutonumLimit_rdh
/** * Verify on the expected SQL statements to be run after insert for the test database table. * * @param sqlScriptExecutor * The script executor to use * @param connection * The connection to use */ @SuppressWarnings("unused") protected void verifyPostInsertStatementsNotInsertingUnderAutonumLimit(SqlScript...
3.26
morf_AbstractSqlDialectTest_testDeleteWithWhereCriterion_rdh
/** * Tests that a delete string with a where criterion is created correctly. */ @Test public void testDeleteWithWhereCriterion() { DeleteStatement stmt = new DeleteStatement(new TableReference(TEST_TABLE)).where(eq(new FieldReference(new TableReference(TEST_TABLE), STRING_FIELD), "A001003657")); String value = varCh...
3.26
morf_AbstractSqlDialectTest_testSelectMinimum_rdh
/** * Tests use of a minimum function in a select. */ @Test public void testSelectMinimum() { SelectStatement stmt = new SelectStatement(min(new FieldReference(INT_FIELD))).from(new TableReference(TEST_TABLE)); String expectedSql = "SELECT MIN(intField) FROM " + tableName(TEST_TABLE);assertEquals("Select with minimum...
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperations8_rdh
/** * * @return expected SQL for math operation 8 */ protected String expectedSqlForMathOperations8() { return "a + b + c + d + e"; }
3.26
morf_AbstractSqlDialectTest_testSelectWithQualifiedFieldNames_rdh
/** * Tests a select with fields qualified with table specifiers. */ @Test public void testSelectWithQualifiedFieldNames() { SelectStatement stmt = new SelectStatement(new FieldReference(new TableReference(TEST_TABLE), STRING_FIELD), new FieldReference(new TableReference(TEST_TABLE), INT_FIELD), new FieldReferenc...
3.26
morf_AbstractSqlDialectTest_testSelectWithMultipleTableAlias_rdh
/** * Tests a select with table aliases. */ @Test public void testSelectWithMultipleTableAlias() { SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD), new FieldReference(INT_FIELD), new FieldReference(DATE_FIELD).as("aliasDate")).from(new TableReference(TEST_TABLE).as("T")).innerJoin...
3.26
morf_AbstractSqlDialectTest_testAddIntegerColumn_rdh
/** * Test adding an integer column. */ @Test public void testAddIntegerColumn() { testAlterTableColumn(AlterationType.ADD, column("intField_new", DataType.INTEGER).nullable(), expectedAlterTableAddIntegerColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_testResultSetToRecordNulls_rdh
/** * Checks that we return all nulls in the resulting record if the result set returns all nulls. * * @throws SQLException * If a SQL exception is thrown. */ @Test public void testResultSetToRecordNulls() throws SQLException { List<Column> columns = Arrays.asList(DataType.values()).stream().filter(d -> !d.equal...
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperationsForExistingDataFix1_rdh
/** * Regression test that checks if the DSL with Math expressions, that is used produces expected SQL. */ @Test public void shouldGenerateCorrectSqlForMathOperationsForExistingDataFix1() { Function dsl = round(field("doublevalue").divideBy(literal(1000)).multiplyBy(field("doublevalue")), literal(2)); String sql = te...
3.26
morf_AbstractSqlDialectTest_testDeleteWithLimitAndComplexWhereCriterion_rdh
/** * Tests that a delete string with a limit and a complex where criterion (involving an 'OR') is created correctly (i.e. brackets around the 'OR' are preserved). */ @Test public void testDeleteWithLimitAndComplexWhereCriterion() { DeleteStatement stmt = DeleteStatement.delete(new TableReference(TEST_TABLE)).where(o...
3.26
morf_AbstractSqlDialectTest_getTestDialect_rdh
/** * * @return the testDialect */ public SqlDialect getTestDialect() { return testDialect; }
3.26
morf_AbstractSqlDialectTest_testSelectMultipleNestedWhereScript_rdh
/** * Tests a select with multiple nested where clauses. */ @Test public void testSelectMultipleNestedWhereScript() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(and(eq(new FieldReference(STRING_FIELD), "A0001"), or(greaterThan(new FieldReference(INT_FIELD), 20080101), les...
3.26
morf_AbstractSqlDialectTest_testParameterisedInsertWithNoFieldsSpecified_rdh
/** * Tests a parameterised insert with no specified field values specified. */ @Test public void testParameterisedInsertWithNoFieldsSpecified() { InsertStatement stmt = new InsertStatement().into(new TableReference(TEST_TABLE)); String sql = testDialect.convertStatementToSQL(stmt, metadata); assertEquals("Generate...
3.26
morf_AbstractSqlDialectTest_expectedHints3a_rdh
/** * * @return The expected SQL for the {@link UpdateStatement#useParallelDml(int)} directive. */ protected String expectedHints3a() { return ("UPDATE " + tableName("Foo")) + " SET a = b";}
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations1_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions. * <p> * Since it is a chain of operations, and all of the operations takes a field * as a second operand, there should be no brackets in the generated SQL. * </p> */ @Test public void shouldGenerateCorrectSqlForMathOperations1() { ...
3.26
morf_AbstractSqlDialectTest_expectedJoinOnEverything_rdh
/** * * @return The expected SQL for a join with no ON criteria */ protected String expectedJoinOnEverything() { return ((("SELECT * FROM " + tableName("TableOne")) + " INNER JOIN ") + tableName("TableTwo")) + " ON 1=1"; }
3.26
morf_AbstractSqlDialectTest_checkDatabaseSafeStringToRecordValue_rdh
/** * Format a value through the result set record for testing. * * @param value * The value to format. * @return The formatted value. */ private String checkDatabaseSafeStringToRecordValue(DataType dataType, String value) throws SQLException { ResultSet resultSet = mock(ResultSet.class); when(resultSet.getBi...
3.26
morf_AbstractSqlDialectTest_testSelectAllRecords_rdh
/** * Tests the SQL for a simple select statement. */ @Test public void testSelectAllRecords() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)); assertEquals("SQL to select all records", "SELECT * FROM " + tableName(TEST_TABLE), testDialect.convertStatementToSQL(stmt)); }
3.26
morf_AbstractSqlDialectTest_testClobFieldLiteralWithLongfield_rdh
/** * Test that getSqlFrom((ClobFieldLiteral)) Returns correctly. */ @Test public void testClobFieldLiteralWithLongfield() { String result = testDialect.getSqlFrom(new ClobFieldLiteral(LONG_FIELD_STRING)); assertEquals(expectedClobLiteralCast(), result); }
3.26
morf_AbstractSqlDialectTest_testRepairAutoNumberStartPositionOverRepairLimit_rdh
/** * Tests for {@link SqlDialect#repairAutoNumberStartPosition(Table, SqlScriptExecutor, Connection)} */ @Test public void testRepairAutoNumberStartPositionOverRepairLimit() { setMaxIdOnAutonumberTable(MAX_ID_OVER_REPAIR_LIMIT); testDialect.repairAutoNumberStartPosition(metadata.getTable(TEST_TABLE), sqlScriptExecut...
3.26
morf_AbstractSqlDialectTest_m14_rdh
/** * Check that we can concatenate a number of string literals. */ @Test public void m14() { SelectStatement v329 = new SelectStatement(new ConcatenatedField(new FieldLiteral("ABC"), new FieldLiteral(" "), new FieldLiteral("DEF")).as("assetDescription")).from(new TableReference("schedule")); String result = testD...
3.26
morf_AbstractSqlDialectTest_testSelectWithDbLink_rdh
/** * Tests the generation of SQL string for a query with a DB-link. */ @Test public void testSelectWithDbLink() { assumeTrue("for dialects with no EXCEPT operation support the test will be skipped.", expectedSelectWithDbLink() != null); SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD)).fro...
3.26
morf_AbstractSqlDialectTest_testUseIndexOnSubquery_rdh
/** * Check that we don't allow the use of the use index hint on a subquery. */ @Test(expected = IllegalArgumentException.class) public void testUseIndexOnSubquery() { testDialect.convertStatementToSQL(select().from(select().from("Foo").useIndex(tableRef("Foo"), "Foo_1"))); }
3.26
morf_AbstractSqlDialectTest_testUseImplicitJoinOrderOnSubquery_rdh
/** * Check that we don't allow the use of the join order hint on a subquery. */ @Test(expected = IllegalArgumentException.class) public void testUseImplicitJoinOrderOnSubquery() { testDialect.convertStatementToSQL(select().from(select().from("Foo").useImplicitJoinOrder())); }
3.26
morf_AbstractSqlDialectTest_expectedSelectSumWithExpression_rdh
/** * * @return the decimal representation of a literal for testing */ protected String expectedSelectSumWithExpression() { return "SELECT SUM(intField * 2 / 3) FROM " + tableName(TEST_TABLE); }
3.26
morf_AbstractSqlDialectTest_testDaysBetween_rdh
/** * Test that DAYS_BETWEEN functionality behaves as expected */ @Test public void testDaysBetween() { SelectStatement testStatement = select(daysBetween(field("dateOne"), field("dateTwo"))).from(tableRef("MyTable")); assertEquals(expectedDaysBetween(), testDialect.convertStatementToSQL(testStatement)); }
3.26
morf_AbstractSqlDialectTest_testCastToInteger_rdh
/** * Tests the output of a cast to an integer. */ @Test public void testCastToInteger() { String result = testDialect.getSqlFrom(new Cast(new FieldReference("value"), DataType.INTEGER, 10)); assertEquals(expectedIntegerCast(), result); }
3.26
morf_AbstractSqlDialectTest_testCreateTableStatements_rdh
/** * Tests the SQL for creating tables. */@SuppressWarnings("unchecked") @Test public void testCreateTableStatements() { Table table = metadata.getTable(TEST_TABLE); Table alternate = metadata.getTable(ALTERNATE_TABLE); Table nonNull = metadata.getTable(NON_NULL_TABLE); Table compositePrimaryKey = me...
3.26
morf_AbstractSqlDialectTest_differentSchemaTableName_rdh
/** * For tests using tables from different schema values. * * @param baseName * Base table name. * @return Decorated name. */ protected String differentSchemaTableName(String baseName) { return "MYSCHEMA." + baseName;}
3.26
morf_AbstractSqlDialectTest_testMathsMinus_rdh
/** * Test that adding numbers returns as expected. */ @Test public void testMathsMinus() { String result = testDialect.getSqlFrom(new MathsField(new FieldLiteral(1), MathsOperator.MINUS, new FieldLiteral(1))); assertEquals(expectedMathsMinus(), result); }
3.26
morf_AbstractSqlDialectTest_testSelectOrderByNullsLastScript_rdh
/** * Tests a select with an "order by" clause with nulls last and default direction. */ @Test public void testSelectOrderByNullsLastScript() { FieldReference fieldReference = new FieldReference(STRING_FIELD); SelectStatement stmt = new SelectStatement(fieldReference).from(new TableReference(ALTERNATE_TABLE)).orde...
3.26
morf_AbstractSqlDialectTest_testUpdateUsingAliasedDestinationTable_rdh
/** * Tests an update where the destination table is aliased. */ @Test public void testUpdateUsingAliasedDestinationTable() { SelectStatement selectStmt = new SelectStatement(new FieldReference("settlementFrequency")).from(new TableReference("FloatingRateDetail").as("B")).where(eq(new FieldReference(new TableReferenc...
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations13_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions. */ @Test public void shouldGenerateCorrectSqlForMathOperations13() { String result = testDialect.getSqlFrom(field("a").plus(field("b")).plus(field("c")).divideBy(literal(2))); assertEquals(expectedSqlForMathOperations13(), result); }
3.26
morf_AbstractSqlDialectTest_m10_rdh
/** * Tests concatenation in a select with {@linkplain FieldReference}s and * {@linkplain FieldLiteral}s. */ @Test public void m10() { SelectStatement stmt = new SelectStatement(new ConcatenatedField(new FieldReference("assetDescriptionLine1"), new FieldLiteral(" "), new FieldReference("assetDescriptionLine2"))....
3.26
morf_AbstractSqlDialectTest_testSelectWithConcatenationUsingCase_rdh
/** * Tests concatenation in a select with {@linkplain CaseStatement}. */ @Testpublic void testSelectWithConcatenationUsingCase() { WhenCondition whenCondition = new WhenCondition(eq(new FieldReference("taxVariationIndicator"), new FieldLiteral('Y')), new FieldReference("exposureCustomerNumber")); SelectStatement st...
3.26
morf_AbstractSqlDialectTest_testLeast_rdh
/** * Test the LEAST functionality behaves as expected */ @Test public void testLeast() { SelectStatement testStatement = select(least(new NullFieldLiteral(), field("bob"))).from(tableRef("MyTable")); assertEquals(expectedLeast().toLowerCase(), testDialect.convertStatementToSQL(testStatement).toLowerCase()); }
3.26
morf_AbstractSqlDialectTest_testAverage_rdh
/** * Tests an average statement */ @Test public void testAverage() { final TableReference tableOne = tableRef("TableOne"); SelectStatement testStatement = select(average(field("name")), averageDistinct(field("name"))).from(tableOne); assertEquals("SELECT AVG(name), AVG(DISTINCT name) FROM " + tableName("TableOne"...
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations5_rdh
/** * Tests that expression builder produces an output with brackets if a second * operand is Math operation. */ @Test public void shouldGenerateCorrectSqlForMathOperations5() { String result = testDialect.getSqlFrom(field("a").multiplyBy(field("b").plus(field("c")))); assertEquals(expectedSqlForMathOperations5(), r...
3.26
morf_AbstractSqlDialectTest_tableName_rdh
/** * Many tests have common results apart from a table name decoration. This method allows for * those tests to be commonised and save a lot of duplication between descendent classes. * * <p>If no decoration is required for an SQL dialect descendant classes need not implement this method.</p> * * @param baseName...
3.26
morf_AbstractSqlDialectTest_m21_rdh
/** * Tests that the syntax is correct for renaming a table which has a long name. */ @SuppressWarnings("unchecked") @Test public void m21() { String tableNameOver30 = "123456789012345678901234567890XXX"; String indexName30 = "123456789012345678901234567_PK"; Table longNamedTable = table(tableNameOver30).columns(idC...
3.26
morf_AbstractSqlDialectTest_testSelectOrderByDescendingScript_rdh
/** * Tests a select with a descending "order by" clause. */ @Test public void testSelectOrderByDescendingScript() { SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD)).from(new TableReference(ALTERNATE_TABLE)).orderBy(new FieldReference(STRING_FIELD, Direction.DESCENDING)); String expectedS...
3.26
morf_AbstractSqlDialectTest_testSelectNotWhereScript_rdh
/** * Tests a select with a "not" where clause. */ @Test public void testSelectNotWhereScript() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(not(eq(new FieldReference(STRING_FIELD), "A0001"))); String value = varCharCast("'A0001'"); String expectedSql = (((("SELECT * FROM ...
3.26
morf_AbstractSqlDialectTest_testCountArgument_rdh
/** * Tests a count statement with an argument */ @Test public void testCountArgument() { final TableReference tableOne = tableRef("TableOne"); SelectStatement testStatement = select(count(field("name")), countDistinct(field("name"))).from(tableOne); assertEquals(testDialect.convertStatementToSQL(testStatement), "SEL...
3.26
morf_AbstractSqlDialectTest_expectedHints4_rdh
/** * * @return The expected SQL for the {@link InsertStatement#useDirectPath()} directive. */ protected String expectedHints4() {return (("INSERT INTO " + tableName("Foo")) + " SELECT a, b FROM ") + tableName("Foo_1"); }
3.26
morf_AbstractSqlDialectTest_expectedDaysBetween_rdh
/** * * @return The expected SQL statement when performing the ANSI daysBetween call */ protected String expectedDaysBetween() { return "SELECT (dateTwo - dateOne) DAY FROM MyTable"; }
3.26
morf_AbstractSqlDialectTest_testRandomString_rdh
/** * Tests that random string functionality builds the expected SQL string. */ @Test public void testRandomString() { SelectStatement statement = new SelectStatement(randomString(new FieldLiteral(10))).from(new TableReference(TEST_TABLE)); String actual = testDialect.convertStatementToSQL(statement); assertEquals("R...
3.26
morf_AbstractSqlDialectTest_testAddIndexStatementsOnMultipleColumns_rdh
/** * Test adding an index over multiple columns. */@SuppressWarnings("unchecked") @Test public void testAddIndexStatementsOnMultipleColumns() { Table table = metadata.getTable(TEST_TABLE); Index index = index("indexName").columns(table.columns().get(0).getName(), table.columns().get(1).getName()); compareStatements(...
3.26
morf_AbstractSqlDialectTest_testCreateViewStatements_rdh
/** * Tests the SQL for creating views. */ @SuppressWarnings("unchecked") @Testpublic void testCreateViewStatements() { compareStatements(expectedCreateViewStatements(), testDialect.viewDeploymentStatements(testView)); }
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations9_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions. * <p> * Bracket should be generated for subexpression "b/c". Even without explicit * {@link org.alfasoftware.morf.sql.SqlUtils#bracket(MathsField)} call. * </p> */ @Test public void shouldGenerateCorrectSqlForMathOperations9() { Alia...
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperations11_rdh
/** * * @return expected SQL for math operation 11 */ protected String expectedSqlForMathOperations11() { return "(a / 100 + 1) / b + 100"; }
3.26
morf_AbstractSqlDialectTest_expectedHints8_rdh
/** * * @return The expected SQL for the {@link SelectStatement#withCustomHint(CustomHint customHint)} directive. Testing all dialcts do not react to an empty hint being supplied. */ protected String expectedHints8() { return "SELECT * FROM SCHEMA2.Foo";// NOSONAR }
3.26
morf_AbstractSqlDialectTest_m3_rdh
/** * Tests case clauses in a select statement. */ @Testpublic void m3() { WhenCondition v87 = new WhenCondition(eq(new FieldReference(CHAR_FIELD), new FieldLiteral('Y')), new FieldReference(INT_FIELD)); SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD), new FieldReference(BOOLEAN_FIELD), ne...
3.26
morf_AbstractSqlDialectTest_testDateToYyyymmdd_rdh
/** * Test that YYYYMMDDToDate functionality behaves as expected. */ @Test public void testDateToYyyymmdd() { String result = testDialect.getSqlFrom(dateToYyyymmdd(field("testField"))); assertEquals(expectedDateToYyyymmdd(), result); }
3.26
morf_AbstractSqlDialectTest_testLeftTrim_rdh
/** * Tests that Left Trim functionality works. */ @Test public void testLeftTrim() { // Given Function leftTrim = leftTrim(new FieldReference("field1")); SelectStatement selectStatement = new SelectStatement(leftTrim).from(new TableReference("schedule")); // When String result = testDialect.convertStatementToSQL(sel...
3.26
morf_AbstractSqlDialectTest_expectedDecimalRepresentationOfLiteral_rdh
/** * * @param literal * The literal whose decimal representation will be returned * @return the decimal representation of a literal for testing */protected String expectedDecimalRepresentationOfLiteral(String literal) { return literal; } /** * Tests that an unparameterised insert where field values have been ...
3.26
morf_AbstractSqlDialectTest_testIndexDropStatements_rdh
/** * Test dropping an index. */ @SuppressWarnings("unchecked") @Test public void testIndexDropStatements() { Table table = metadata.getTable(TEST_TABLE); Index index = index("indexName").unique().columns(table.columns().get(0).getName()); compareStatements(expectedIndexDropStatements(), testDialect.indexDropStatemen...
3.26
morf_AbstractSqlDialectTest_testAddColumnWithDefault_rdh
/** * Test adding a column with default value. */ @Testpublic void testAddColumnWithDefault() { testAlterTableColumn(AlterationType.ADD, column("floatField_new", DataType.DECIMAL, 6, 3).nullable().defaultValue("20.33"), expectedAlterTableAddColumnWithDefaultStatement()); }
3.26
morf_AbstractSqlDialectTest_testAlterColumnFromNotNullableToNullable_rdh
/** * Test changing a column from not nullable to a nullable one. */ @Test public void testAlterColumnFromNotNullableToNullable() { testAlterTableColumn(TEST_TABLE, AlterationType.ALTER, getColumn(TEST_TABLE, FLOAT_FIELD), column(FLOAT_FIELD, DataType.DECIMAL, 20, 3).nullable(), expectedAlterTableAlterColumnFromNotNu...
3.26
morf_AbstractSqlDialectTest_m35_rdh
/** * Tests formatting of numerical values in a {@link Record}. * * @throws SQLException * when a database access error occurs */ @Test public void m35() throws SQLException { assertEquals("Do nothing if no trailing zeroes", "123.123", checkDatabaseSafeStringToRecordValue(DataType.DECIMAL, "123.123")); assertEqu...
3.26
morf_AbstractSqlDialectTest_testCastToBoolean_rdh
/** * Tests the output of a cast to a boolean. */ @Test public void testCastToBoolean() { String result = testDialect.getSqlFrom(new Cast(new FieldReference("value"), DataType.BOOLEAN, 10)); assertEquals(expectedBooleanCast(), result); }
3.26
morf_AbstractSqlDialectTest_testDropViewStatements_rdh
/** * Tests SQL for dropping a view. */ @SuppressWarnings("unchecked") @Test public void testDropViewStatements() { compareStatements(expectedDropViewStatements(), testDialect.dropStatements(testView)); }
3.26
morf_AbstractSqlDialectTest_testNow_rdh
/** * Test that now functionality behaves as expected. */ @Test public void testNow() {String result = testDialect.getSqlFrom(now()); assertEquals(expectedNow(), result); }
3.26
morf_AbstractSqlDialectTest_expectedRowNumber_rdh
/** * * @return The expected SQL for retrieving the row number */ protected String expectedRowNumber() { return "ROW_NUMBER()"; }
3.26
morf_AbstractSqlDialectTest_testSelectMod_rdh
/** * Tests select statement with mod function. */ @Test public void testSelectMod() {SelectStatement stmt = new SelectStatement(mod(new FieldReference(INT_FIELD), new FieldLiteral(5))).from(new TableReference(TEST_TABLE)); String expectedSql = expectedSelectModSQL(); assertEquals("Select scripts are not the same",...
3.26
morf_AbstractSqlDialectTest_testPower_rdh
/** * Tests that POWER functionality builds the expected SQL string. */ @Test public void testPower() { SelectStatement statement = new SelectStatement(power(new FieldReference(FLOAT_FIELD), new FieldReference(INT_FIELD))).from(new TableReference(TEST_TABLE));String actual = testDialect.convertStatementToSQL(statem...
3.26
morf_AbstractSqlDialectTest_testAlterBigIntegerColumn_rdh
/** * Test altering a big integer column. */ @Test public void testAlterBigIntegerColumn() { testAlterTableColumn(TEST_TABLE, AlterationType.ALTER, getColumn(TEST_TABLE, BIG_INTEGER_FIELD), column(BIG_INTEGER_FIELD, DataType.BIG_INTEGER).nullable(), expectedAlterTableAlterBigIntegerColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_expectedSelectSome_rdh
/** * * @return The expected sql. */ protected String expectedSelectSome() {return "SELECT MAX(booleanField) FROM " + tableName(TEST_TABLE); }
3.26
morf_AbstractSqlDialectTest_m18_rdh
/** * Test altering a date column. */ @Test public void m18() { testAlterTableColumn(TEST_TABLE, AlterationType.ALTER, getColumn(TEST_TABLE, DATE_FIELD), column(DATE_FIELD, DataType.DATE), expectedAlterTableAlterDateColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_testDeleteWithLimitWithoutWhereCriterion_rdh
/** * Tests that a delete string with a limit and no where criterion is created correctly. */ @Test public void testDeleteWithLimitWithoutWhereCriterion() { DeleteStatement stmt = DeleteStatement.delete(new TableReference(TEST_TABLE)).limit(1000).build(); assertEquals("Delete with limit", expectedDeleteWithLimitWitho...
3.26
morf_AbstractSqlDialectTest_expectedUpdateWithLiteralValues_rdh
/** * * @return Expected SQL for {@link #testUpdateWithLiteralValues()} */ protected String expectedUpdateWithLiteralValues() { String value = varCharCast("'Value'"); return String.format(("UPDATE %s SET stringField = %s%s, blobFieldOne = %s, blobFieldTwo = %s " + "WHERE ((field1 = %s) AND (field2 = %s) AND (field3 ...
3.26
morf_AbstractSqlDialectTest_testDropTemporaryTableStatements_rdh
/** * Test the SQL for dropping temporary tables. */ @SuppressWarnings("unchecked") @Test public void testDropTemporaryTableStatements() {compareStatements(expectedDropTempTableStatements(), testDialect.dropStatements(testTempTable)); }
3.26
morf_AbstractSqlDialectTest_testAlterIntegerColumn_rdh
/** * Test altering an integer column. */ @Test public void testAlterIntegerColumn() { testAlterTableColumn(TEST_TABLE, AlterationType.ALTER, getColumn(TEST_TABLE, INT_FIELD), column(INT_FIELD, DataType.INTEGER), expectedAlterTableAlterIntegerColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_testSelectWhereScript_rdh
/** * Tests a select with a where clause. */ @Test public void testSelectWhereScript() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(eq(new FieldReference(STRING_FIELD), "A0001")); String value = varCharCast("'A0001'"); String expectedSql = (((("SELECT * FRO...
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperations15_rdh
/** * * @return expected SQL for math operation 15 */ protected String expectedSqlForMathOperations15() {return "a + (b + c) / 2"; }
3.26