use of com.haulmont.cuba.gui.components.autocomplete.impl.AliasRemover in project cuba by cuba-platform.
the class AliasRemoverTest method testAliasReplacement.
@Test
public void testAliasReplacement() throws Exception {
AliasRemover aliasRemover = new AliasRemover();
HintRequest input = new HintRequest();
input.setQuery("select queryEntity.!vin as \"vin\" from ref$Car queryEntity");
input.setPosition(input.getQuery().indexOf("!"));
input.setExpectedTypes(EnumSet.of(InferredType.Any));
HintRequest result = aliasRemover.replaceAliases(input);
Assert.assertEquals('!', result.getQuery().charAt(result.getPosition()));
Assert.assertTrue(!result.getQuery().contains("as \""));
System.out.println(result.getQuery());
input.setQuery("select queryEntity.vin as \"vin\", queryEntity.!version as \"version\" from ref$Car queryEntity");
input.setPosition(input.getQuery().indexOf("!"));
input.setExpectedTypes(EnumSet.of(InferredType.Any));
result = aliasRemover.replaceAliases(input);
Assert.assertEquals('!', result.getQuery().charAt(result.getPosition()));
Assert.assertTrue(!result.getQuery().contains("as \""));
System.out.println(result.getQuery());
input.setQuery("select queryEntity.!vin as \"vin\", queryEntity.version as \"version\" from ref$Car queryEntity");
input.setPosition(input.getQuery().indexOf("!"));
input.setExpectedTypes(EnumSet.of(InferredType.Any));
result = aliasRemover.replaceAliases(input);
Assert.assertEquals('!', result.getQuery().charAt(result.getPosition()));
Assert.assertTrue(!result.getQuery().contains("as \""));
System.out.println(result.getQuery());
input.setQuery("select queryEntity.vin as \"vin\", queryEntity.version as \"version\" from ref$Car queryEntity");
input.setPosition(input.getQuery().indexOf("\"ver"));
input.setExpectedTypes(EnumSet.of(InferredType.Any));
result = aliasRemover.replaceAliases(input);
Assert.assertEquals(' ', result.getQuery().charAt(result.getPosition()));
Assert.assertTrue(!result.getQuery().contains("as \""));
System.out.println(result.getQuery());
}
Aggregations