Github user albertostratio commented on a diff in the pull request:

    https://github.com/apache/incubator-metamodel/pull/2#discussion_r18383366
  
    --- Diff: 
cassandra/src/test/java/org/apache/metamodel/cassandra/CassandraDataContextTest.java
 ---
    @@ -0,0 +1,245 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.metamodel.cassandra;
    +
    +import com.datastax.driver.core.Cluster;
    +import com.datastax.driver.core.Session;
    +
    +import org.apache.metamodel.data.DataSet;
    +import org.apache.metamodel.data.DataSetTableModel;
    +import org.apache.metamodel.data.FilteredDataSet;
    +import org.apache.metamodel.query.FunctionType;
    +import org.apache.metamodel.query.Query;
    +import org.apache.metamodel.query.SelectItem;
    +import org.apache.metamodel.schema.ColumnType;
    +import org.apache.metamodel.schema.Table;
    +import org.junit.Test;
    +
    +import java.util.Arrays;
    +import java.util.List;
    +
    +import javax.swing.table.TableModel;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertTrue;
    +
    +public class CassandraDataContextTest extends CassandraTestCase {
    +
    +    private CassandraSimpleClient client = new CassandraSimpleClient();
    +    private Cluster cluster;
    +    private CassandraDataContext dc;
    +    private String testTableName = "songs";
    +    private String firstRowId = "756716f7-2e54-4715-9f00-91dcbea6cf51";
    +    private String secondRowId = "756716f7-2e54-4715-9f00-91dcbea6cf52";
    +    private String thirdRowId = "756716f7-2e54-4715-9f00-91dcbea6cf53";
    +    private String firstRowTitle = "My first song";
    +    private String secondRowTitle = "My second song";
    +    private String thirdRowTitle = "My third song";
    +
    +    @Override
    +    protected void setUp() throws Exception {
    +        super.setUp();
    +        if (isConfigured()) {
    +            client.connect(getHostname(), getPort());
    +            cluster = client.getCluster();
    +            Session session = cluster.connect();
    +            dc = new CassandraDataContext(cluster, getKeyspaceName());
    +            createCassandraKeySpaceAndTable(session);
    +            populateCassandraTableWithSomeData(session);
    +        }
    +    }
    +
    +    @Override
    +    protected void tearDown() throws Exception {
    +        super.tearDown();
    +        if (isConfigured()) {
    +           client.close();
    +        }
    +    }
    +
    +    public void testSchemaAndSimpleQuery() throws Exception {
    +        if (!isConfigured()) {
    +            System.err.println(getInvalidConfigurationMessage());
    +            return;
    +        }
    +
    +        assertEquals("["+testTableName+"]",
    +                Arrays.toString(dc.getDefaultSchema().getTableNames()));
    +
    +        Table table = dc.getDefaultSchema().getTableByName(testTableName);
    +
    +        assertEquals(ColumnType.STRING, 
table.getColumnByName("id").getType());
    +        assertEquals(ColumnType.STRING, 
table.getColumnByName("title").getType());
    +        assertEquals(ColumnType.BOOLEAN, 
table.getColumnByName("hit").getType());
    +        assertEquals(ColumnType.FLOAT, 
table.getColumnByName("duration").getType());
    +        assertEquals(ColumnType.INTEGER, 
table.getColumnByName("position").getType());
    +        assertEquals(ColumnType.TIMESTAMP, 
table.getColumnByName("creationtime").getType());
    +
    +
    +        DataSet ds = 
dc.query().from(testTableName).select("id").and("title").execute();
    +        assertEquals(CassandraDataSet.class, ds.getClass());
    +        assertFalse(((CassandraDataSet) ds).isQueryPostProcessed());
    +
    +
    +        try {
    +            assertTrue(ds.next());
    +            assertEquals("Row[values=["+secondRowId+", 
"+secondRowTitle+"]]", ds.getRow().toString());
    +            assertTrue(ds.next());
    +            assertEquals("Row[values=["+thirdRowId+", 
"+thirdRowTitle+"]]", ds.getRow().toString());
    +            assertTrue(ds.next());
    +            assertEquals("Row[values=["+firstRowId+", 
"+firstRowTitle+"]]", ds.getRow().toString());
    +            assertFalse(ds.next());
    +        } finally {
    +            // ds.close();
    +        }
    +    }
    +
    +    public void testWhereColumnEqualsValues() throws Exception {
    +        DataSet ds = 
dc.query().from(testTableName).select("id").and("title").where("id")
    --- End diff --
    
    Good catch! Fixed!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to