@Test public void testDefaultAdapter() { String veryLongVarName = defaultAdapter.nameTopVariable(veryLongSignatureVarName, defaultSuffix, emptyVarSet); assertEquals( veryLongVarName, defaultAdapter.sqlQuote(veryLongSignatureVarName + defaultSuffix)); }
@Test(expected = RuntimeException.class) public void testOracleTooMuchSimilarVars() { Set<String> assignedVars = new HashSet<>(); int createdVarNb = (int) (Math.pow(10, OracleSQLDialectAdapter.VARIABLE_NUMBER_LENGTH) + 1); for (int i = 0; i < createdVarNb; i++) { assignedVars.add( oracleAdapter.nameTopVariable(veryLongSignatureVarName, defaultSuffix, assignedVars)); } }
@Test public void testOracleOneShot() { String veryLongVarName = oracleAdapter.nameTopVariable(veryLongSignatureVarName, defaultSuffix, emptyVarSet); assertTrue(veryLongVarName.length() <= OracleSQLDialectAdapter.VARIABLE_NAME_MAX_LENGTH); assertTrue(veryLongVarName.contains(defaultSuffix)); assertTrue(veryLongVarName.contains("veryVery")); assertEquals(veryLongVarName, "\"veryVeryVeryVeryVeryV0Suffix\""); }
@Test public void testOracleTenSimilarVars() { Set<String> assignedVars = new HashSet<>(); int createdVarNb = (int) Math.pow(10, OracleSQLDialectAdapter.VARIABLE_NUMBER_LENGTH); for (int i = 0; i < createdVarNb; i++) { assignedVars.add( oracleAdapter.nameTopVariable(veryLongSignatureVarName, defaultSuffix, assignedVars)); } assertEquals(assignedVars.size(), createdVarNb); }
@Test(expected = IllegalArgumentException.class) public void testOracleExcessiveSuffix2() { oracleAdapter.nameTopVariable("short", excessiveSuffix + "More", emptyVarSet); }
@Test public void testOracleMaxNonModifiedVarName() { String limitVarName = oracleAdapter.nameTopVariable(limitSignatureVarName, defaultSuffix, emptyVarSet); assertEquals(limitVarName, oracleAdapter.sqlQuote(limitSignatureVarName + defaultSuffix)); }