Search in sources :

Example 1 with SQLTemplateAction

use of org.apache.cayenne.access.jdbc.SQLTemplateAction in project cayenne by apache.

the class AutoAdapterIT method testCreateSQLTemplateAction.

@Test
public void testCreateSQLTemplateAction() {
    Provider<DbAdapter> adapterProvider = mock(Provider.class);
    when(adapterProvider.get()).thenReturn(dataNode.getAdapter());
    AutoAdapter autoAdapter = new AutoAdapter(adapterProvider, NoopJdbcEventLogger.getInstance());
    SQLTemplateAction action = (SQLTemplateAction) autoAdapter.getAction(new SQLTemplate(Artist.class, "select * from artist"), dataNode);
    // it is important for SQLTemplateAction to be used with unwrapped
    // adapter, as the
    // adapter class name is used as a key to the correct SQL template.
    assertNotNull(action.getAdapter());
    assertFalse(action.getAdapter() instanceof AutoAdapter);
    assertSame(dataNode.getAdapter(), action.getAdapter());
}
Also used : SQLTemplate(org.apache.cayenne.query.SQLTemplate) SQLTemplateAction(org.apache.cayenne.access.jdbc.SQLTemplateAction) Test(org.junit.Test)

Aggregations

SQLTemplateAction (org.apache.cayenne.access.jdbc.SQLTemplateAction)1 SQLTemplate (org.apache.cayenne.query.SQLTemplate)1 Test (org.junit.Test)1