use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModelImpl in project cuba by cuba-platform.
the class HintProviderTest method requestHint_entityNameHint_order.
@Test
public void requestHint_entityNameHint_order() throws RecognitionException {
EntityBuilder builder = new EntityBuilder();
JpqlEntityModelImpl playerEntity = builder.produceImmediately("Player");
JpqlEntityModelImpl parentEntity = builder.produceImmediately("Parent");
DomainModel model = new DomainModel();
model.add(playerEntity);
model.add(parentEntity);
HintProvider hintProvider = createTestHintProvider(model);
HintResponse response = hintProvider.requestHint("SELECT p FROM P~");
List<String> options = response.getOptions();
assertEquals(2, options.size());
assertEquals("Parent", options.get(0));
assertEquals("Player", options.get(1));
}
use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModelImpl in project cuba by cuba-platform.
the class HintProviderTest method requestHint_erroneous.
@Test
public void requestHint_erroneous() throws RecognitionException {
EntityBuilder builder = new EntityBuilder();
JpqlEntityModelImpl playerEntity = builder.produceImmediately("Player");
DomainModel model = new DomainModel();
model.add(playerEntity);
HintProvider hintProvider = createTestHintProvider(model);
HintResponse response = hintProvider.requestHint("select t FROM p...~");
List<String> options = response.getOptions();
assertEquals(0, options.size());
assertEquals("Query error", response.getErrorMessage());
assertArrayEquals(new String[] { "Cannot parse [p...]", "Error near: \"p\"" }, response.getCauseErrorMessages().toArray());
}
use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModelImpl in project cuba by cuba-platform.
the class HintProviderTest method requestHint_entityNameHint_simple.
@Test
public void requestHint_entityNameHint_simple() throws RecognitionException {
EntityBuilder builder = new EntityBuilder();
JpqlEntityModelImpl playerEntity = builder.produceImmediately("Player");
DomainModel model = new DomainModel();
model.add(playerEntity);
HintProvider hintProvider = createTestHintProvider(model);
HintResponse response = hintProvider.requestHint("SELECT p FROM P~");
List<String> options = response.getOptions();
assertEquals(1, options.size());
assertEquals("Player", options.get(0));
response = hintProvider.requestHint("FROM N~");
options = response.getOptions();
assertEquals(0, options.size());
}
use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModelImpl in project cuba by cuba-platform.
the class QueryTransformerAstBasedTest method getResult_noChangesMade.
@Test
public void getResult_noChangesMade() throws RecognitionException {
EntityBuilder builder = new EntityBuilder();
JpqlEntityModelImpl playerEntity = builder.produceImmediately("Player");
DomainModel model = new DomainModel(playerEntity);
assertTransformsToSame(model, "SELECT p FROM Player p");
}
Aggregations