package com.nhl.bootique.cayenne;

import com.nhl.bootique.jdbc.JdbcModule;
import com.nhl.bootique.test.junit.BQTestFactory;
import org.apache.cayenne.access.DataDomain;
import org.apache.cayenne.configuration.server.ServerRuntime;
import org.apache.cayenne.query.SQLSelect;
import org.junit.Rule;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;

public class CayenneModuleIT {

    @Rule
    public BQTestFactory testFactory = new BQTestFactory();

    @Test
    public void testFullConfig() {

        ServerRuntime runtime = testFactory.newRuntime()
                .configurator(bootique -> bootique.modules(JdbcModule.class, CayenneModule.class))
                .build("--config=classpath:fullconfig.yml")
                .getRuntime()
                .getInstance(ServerRuntime.class);

        DataDomain domain = runtime.getDataDomain();
        assertNotNull(domain.getEntityResolver().getDbEntity("db_entity2"));

        // trigger a DB op
        SQLSelect.dataRowQuery("SELECT * FROM db_entity2").select(runtime.newContext());
    }
}

@@ -361,16 +361,59 @@
 NotNull;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Apublic
@@ -1105,11 +1105,485 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testNoConfig() %7B%0A%0A        ServerRuntime runtime = testFactory.newRuntime()%0A                .configurator(bootique -%3E bootique.modules(JdbcModule.class, CayenneModule.class))%0A                .build(%22--config=classpath:noconfig.yml%22)%0A                .getRuntime()%0A                .getInstance(ServerRuntime.class);%0A%0A        DataDomain domain = runtime.getDataDomain();%0A        assertTrue(domain.getEntityResolver().getDbEntities().isEmpty());%0A    %7D
 %0A%7D%0A

Make project-less ServerRuntime possible #12