package apoc;

import apoc.util.Neo4jContainerExtension;
import apoc.util.TestUtil;
import org.junit.Test;

import static apoc.util.TestContainerUtil.createEnterpriseDB;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/*
 This test is just to verify if the APOC are correctly deployed
 into a Neo4j instance without any startup issue.
 If you don't have docker installed it will fail, and you can simply ignore it.
 */
public class StartupTest {
    @Test
    public void test() {
        try {
            Neo4jContainerExtension neo4jContainer = createEnterpriseDB(!TestUtil.isTravis())
                    .withNeo4jConfig("dbms.transaction.timeout", "5s");
            neo4jContainer.start();
            assertTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning());
            neo4jContainer.close();
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Should not have thrown exception when trying to start Neo4j: " + ex);
        }
    }
}

@@ -99,16 +99,128 @@
 it.Test;
+%0Aimport org.neo4j.driver.Session;%0Aimport org.neo4j.driver.Value;%0Aimport org.testcontainers.containers.Container;
 %0A%0Aimport
@@ -799,16 +799,18 @@
  %225s%22);%0A
+%0A%0A
         
@@ -833,24 +833,25 @@
 er.start();%0A
+%0A
             
@@ -933,16 +933,495 @@
 ing());%0A
+%0A            Session session = neo4jContainer.getSession();%0A            int procedureCount = session.run(%22CALL dbms.procedures() YIELD name WHERE name STARTS WITH 'apoc' RETURN count(*) AS count%22).peek().get(%22count%22).asInt();%0A            int functionCount = session.run(%22CALL dbms.functions() YIELD name WHERE name STARTS WITH 'apoc' RETURN count(*) AS count%22).peek().get(%22count%22).asInt();%0A%0A            assertTrue(procedureCount %3E 0);%0A            assertTrue(functionCount %3E 0);%0A%0A
         

check we have procedures