Search in sources :

Example 31 with Statement

use of com.google.api.ads.admanager.jaxws.v202111.Statement in project googleads-java-lib by googleads.

the class StatementBuilderTest method testRemoveLimitAndOffset.

@Test
public void testRemoveLimitAndOffset() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement initialOffset = statementBuilder.where("id = 1").limit(100).offset(100).toStatement();
    assertEquals("WHERE id = 1 LIMIT 100 OFFSET 100", initialOffset.getQuery());
    Statement removed = statementBuilder.removeLimitAndOffset().toStatement();
    assertEquals("WHERE id = 1", removed.getQuery());
}
Also used : Statement(com.google.api.ads.admanager.axis.v202108.Statement) Test(org.junit.Test)

Example 32 with Statement

use of com.google.api.ads.admanager.jaxws.v202111.Statement in project googleads-java-lib by googleads.

the class StatementBuilderTest method testWhere.

@Test
public void testWhere() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement statement = statementBuilder.where("id = 12345").toStatement();
    assertEquals("WHERE id = 12345", statement.getQuery());
}
Also used : Statement(com.google.api.ads.admanager.axis.v202111.Statement) Test(org.junit.Test)

Example 33 with Statement

use of com.google.api.ads.admanager.jaxws.v202111.Statement in project googleads-java-lib by googleads.

the class StatementBuilderTest method testBindVariables_text.

@Test
public void testBindVariables_text() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement statement = statementBuilder.where("text = :text").withBindVariableValue("text", "foo").toStatement();
    String_ValueMapEntry entry = statement.getValues(0);
    assertEquals("text", entry.getKey());
    assertEquals(TextValue.class, entry.getValue().getClass());
    assertEquals("foo", ((TextValue) entry.getValue()).getValue());
}
Also used : String_ValueMapEntry(com.google.api.ads.admanager.axis.v202111.String_ValueMapEntry) Statement(com.google.api.ads.admanager.axis.v202111.Statement) Test(org.junit.Test)

Example 34 with Statement

use of com.google.api.ads.admanager.jaxws.v202111.Statement in project googleads-java-lib by googleads.

the class StatementBuilderTest method testSelect.

@Test
public void testSelect() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement statement = statementBuilder.select("id, name").toStatement();
    assertEquals("SELECT id, name", statement.getQuery());
}
Also used : Statement(com.google.api.ads.admanager.axis.v202105.Statement) Test(org.junit.Test)

Example 35 with Statement

use of com.google.api.ads.admanager.jaxws.v202111.Statement in project eol-globi-data by jhpoelen.

the class CypherQueryExecutorIT method executeBoltQuery.

@Test
public void executeBoltQuery() {
    Driver driver = GraphDatabase.driver("bolt://preston:7687", AuthTokens.none());
    Session session = driver.session(AccessMode.READ);
    try (Transaction transaction = session.beginTransaction()) {
        String s = "CYPHER 2.3 START dataset = node:datasets({namespace}) RETURN dataset.namespace LIMIT 1";
        Statement statement = new Statement(s, new TreeMap<String, Object>() {

            {
                put("namespace", "namespace:\"globalbioticinteractions/template-dataset\"");
            }
        });
        StatementResult run = transaction.run(statement);
        run.stream().map(r -> r.asMap()).forEach(System.out::println);
        transaction.success();
    }
}
Also used : Driver(org.neo4j.driver.v1.Driver) AccessMode(org.neo4j.driver.v1.AccessMode) Assert.assertNotNull(org.junit.Assert.assertNotNull) AuthTokens(org.neo4j.driver.v1.AuthTokens) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) IOException(java.io.IOException) Transaction(org.neo4j.driver.v1.Transaction) CypherQuery(org.eol.globi.util.CypherQuery) Statement(org.neo4j.driver.v1.Statement) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Session(org.neo4j.driver.v1.Session) TreeMap(java.util.TreeMap) StatementResult(org.neo4j.driver.v1.StatementResult) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) GraphDatabase(org.neo4j.driver.v1.GraphDatabase) StatementResult(org.neo4j.driver.v1.StatementResult) Transaction(org.neo4j.driver.v1.Transaction) Statement(org.neo4j.driver.v1.Statement) Driver(org.neo4j.driver.v1.Driver) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Session(org.neo4j.driver.v1.Session) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)61 Statement (com.google.api.ads.admanager.axis.v202105.Statement)16 Statement (com.google.api.ads.admanager.axis.v202108.Statement)16 Statement (com.google.api.ads.admanager.axis.v202111.Statement)16 Statement (com.google.api.ads.admanager.axis.v202202.Statement)16 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202105.String_ValueMapEntry)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202108.String_ValueMapEntry)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202111.String_ValueMapEntry)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202202.String_ValueMapEntry)4 Session (org.neo4j.driver.v1.Session)2 Statement (org.neo4j.driver.v1.Statement)2 StatementResult (org.neo4j.driver.v1.StatementResult)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Statement (com.google.api.ads.admanager.jaxws.v202105.Statement)1 StringValueMapEntry (com.google.api.ads.admanager.jaxws.v202105.StringValueMapEntry)1 Statement (com.google.api.ads.admanager.jaxws.v202108.Statement)1 StringValueMapEntry (com.google.api.ads.admanager.jaxws.v202108.StringValueMapEntry)1 Statement (com.google.api.ads.admanager.jaxws.v202111.Statement)1 StringValueMapEntry (com.google.api.ads.admanager.jaxws.v202111.StringValueMapEntry)1 Statement (com.google.api.ads.admanager.jaxws.v202202.Statement)1