Search in sources :

Example 1 with ContentAssistant

use of org.eclipse.reddeer.jface.text.contentassist.ContentAssistant in project jbosstools-hibernate by jbosstools.

the class HQLEditorCodeAssistTest method testHQLEditor.

@Test
public void testHQLEditor() {
    prepare();
    KnownConfigurationsView v = new KnownConfigurationsView();
    v.open();
    v.selectConsole(prj);
    EditConfigurationShell confShell = v.openConsoleConfiguration(prj);
    EditConfigurationMainPage mainPage = confShell.getMainPage();
    mainPage.setProject(prj);
    mainPage.setType("JPA (jdk 1.5+)");
    mainPage.setDatabaseConnection("[JPA Project Configured Connection]");
    mainPage.setHibernateVersion(hbVersion);
    confShell.ok();
    v.open();
    v.selectConsole(prj);
    new ContextMenuItem("HQL Editor").select();
    HQLEditor hqlEditor = new HQLEditor(prj);
    hqlEditor.setText("from ");
    hqlEditor.setCursorPosition("from ".length());
    String proposal = "Actor - org.gen";
    ContentAssistant ca = hqlEditor.openContentAssistant();
    List<String> proposals = ca.getProposals();
    ca.close();
    assertTrue(proposal + " is expected", proposals.contains(proposal));
    hqlEditor.setText("from Actor a where a.");
    hqlEditor.setCursorPosition("from Actor a where a.".length());
    proposal = "actorId - Actor";
    ca = hqlEditor.openContentAssistant();
    proposals = ca.getProposals();
    ca.close();
    assertTrue(proposal + " is expected", proposals.contains(proposal));
}
Also used : ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) EditConfigurationShell(org.jboss.tools.hibernate.reddeer.console.EditConfigurationShell) EditConfigurationMainPage(org.jboss.tools.hibernate.reddeer.console.EditConfigurationMainPage) HQLEditor(org.jboss.tools.hibernate.reddeer.hqleditor.HQLEditor) KnownConfigurationsView(org.jboss.tools.hibernate.reddeer.console.views.KnownConfigurationsView) ContentAssistant(org.eclipse.reddeer.jface.text.contentassist.ContentAssistant) Test(org.junit.Test)

Example 2 with ContentAssistant

use of org.eclipse.reddeer.jface.text.contentassist.ContentAssistant in project jbosstools-hibernate by jbosstools.

the class CriteriaEditorCodeAssistTest method checkCriteriaEditor.

private void checkCriteriaEditor() {
    KnownConfigurationsView v = new KnownConfigurationsView();
    v.open();
    v.selectConsole(prj);
    new ContextMenuItem("Hibernate Criteria Editor").select();
    String expression = "ses";
    CriteriaEditor criteriaEditor = new CriteriaEditor(prj);
    criteriaEditor.setText(expression);
    criteriaEditor.setCursorPosition(expression.length());
    String proposal = "session : Session";
    ContentAssistant ca = criteriaEditor.openContentAssistant();
    List<String> proposals = ca.getProposals();
    ca.close();
    assertTrue(proposal + " is expected", proposals.contains(proposal));
    expression = "session.cre";
    criteriaEditor.setText(expression);
    criteriaEditor.setCursorPosition(expression.length());
    proposal = "createCriteria\\(Class arg0\\) \\: Criteria \\- Session";
    Double hv = Double.parseDouble(hbVersion);
    if (hv >= 4.0) {
        proposal = "createCriteria\\(Class \\w*\\) : Criteria - SharedSessionContract";
    }
    ca = criteriaEditor.openContentAssistant();
    proposals = ca.getProposals();
    ca.close();
    boolean shouldFail = true;
    for (String p : proposals) {
        if (p.matches(proposal)) {
            shouldFail = false;
            break;
        }
    }
    if (shouldFail) {
        fail(proposal + " CA proposal is expected but was " + proposals);
    }
    expression = "session.createCriteria(Act";
    criteriaEditor.setText(expression);
    criteriaEditor.setCursorPosition(expression.length());
    proposal = "Actor - org.gen";
    ca = criteriaEditor.openContentAssistant();
    proposals = ca.getProposals();
    ca.close();
    assertTrue(proposal + " is expected", proposals.contains(proposal));
}
Also used : CriteriaEditor(org.jboss.tools.hibernate.reddeer.criteriaeditor.CriteriaEditor) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) KnownConfigurationsView(org.jboss.tools.hibernate.reddeer.console.views.KnownConfigurationsView) ContentAssistant(org.eclipse.reddeer.jface.text.contentassist.ContentAssistant)

Aggregations

ContentAssistant (org.eclipse.reddeer.jface.text.contentassist.ContentAssistant)2 ContextMenuItem (org.eclipse.reddeer.swt.impl.menu.ContextMenuItem)2 KnownConfigurationsView (org.jboss.tools.hibernate.reddeer.console.views.KnownConfigurationsView)2 EditConfigurationMainPage (org.jboss.tools.hibernate.reddeer.console.EditConfigurationMainPage)1 EditConfigurationShell (org.jboss.tools.hibernate.reddeer.console.EditConfigurationShell)1 CriteriaEditor (org.jboss.tools.hibernate.reddeer.criteriaeditor.CriteriaEditor)1 HQLEditor (org.jboss.tools.hibernate.reddeer.hqleditor.HQLEditor)1 Test (org.junit.Test)1