Search in sources :

Example 1 with Row

use of infoeval.main.mysql.Row in project Info-Evaluation by TechnionYP5777.

the class SqlRunnerTest method getSameBirthPlaceCouplesTest.

@Ignore
@Test
public void getSameBirthPlaceCouplesTest() throws Exception {
    for (TableEntry te : querun.getSameBirthPlaceCouples()) {
        String sName = te.getSpouseName(), checkBirthPlaceQuery = "SELECT birthPlace FROM basic_info WHERE name=? LIMIT 1";
        Object[] inp = new Object[1];
        inp[0] = sName;
        ArrayList<Row> res = querun.runQuery(checkBirthPlaceQuery, inp);
        Row row = res.get(0);
        assertEquals(te.getBirthPlace(), (String) row.row.get(0).getValue().cast(row.row.get(0).getKey()));
    }
}
Also used : TableEntry(infoeval.main.mysql.TableEntry) Row(infoeval.main.mysql.Row) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with Row

use of infoeval.main.mysql.Row in project Info-Evaluation by TechnionYP5777.

the class ConnectorTest method basicInfoTableSizeTest.

@Ignore
@Test
public void basicInfoTableSizeTest() throws Exception {
    Connector conn = new Connector();
    assert conn.getConnection() != null;
    ArrayList<Row> rows = conn.runQuery("SELECT COUNT(*) FROM basic_info");
    Row row = rows.get(0);
    Entry<Object, Class> col = row.row.get(0);
    Object size = col.getValue().cast(col.getKey());
    assertEquals(ENTRIES_NUM, size);
    Extractor ext = new Extractor();
    ext.executeQuery(QueryTypes.BASIC_INFO);
    assertEquals(ext.getResults().size(), size);
    conn.close();
}
Also used : Connector(infoeval.main.WikiData.Connector) Row(infoeval.main.mysql.Row) Extractor(infoeval.main.WikiData.Extractor) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with Row

use of infoeval.main.mysql.Row in project Info-Evaluation by TechnionYP5777.

the class ConnectorTest method runQueryTest.

@Test
@SuppressWarnings("rawtypes")
public void runQueryTest() throws Exception {
    Connector conn = new Connector();
    Row row = conn.runQuery("SELECT photoLink FROM basic_info LIMIT 1").get(0);
    Entry<Object, Class> col = row.row.get(0);
    assertNotNull(col.getValue().cast(col.getKey()));
    int res = conn.runUpdate("INSERT INTO WikiID VALUES('osher','1234')");
    assert res == 1;
    res = conn.runUpdate("DELETE FROM WikiID WHERE name LIKE 'osher'");
    assert res == 1;
    conn.close();
}
Also used : Connector(infoeval.main.WikiData.Connector) Row(infoeval.main.mysql.Row) Test(org.junit.Test)

Example 4 with Row

use of infoeval.main.mysql.Row in project Info-Evaluation by TechnionYP5777.

the class SqlTablesFillerTest method wikiIdTableSizeTest.

@SuppressWarnings("rawtypes")
@Ignore
@Test
public void wikiIdTableSizeTest() throws Exception {
    Row row = new Connector().runQuery("SELECT COUNT(*) FROM WikiID").get(0);
    Entry<Object, Class> col = row.row.get(0);
    assertEquals(ENTRIES_NUM, (long) col.getValue().cast(col.getKey()));
}
Also used : Connector(infoeval.main.WikiData.Connector) AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) Row(infoeval.main.mysql.Row) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Row

use of infoeval.main.mysql.Row in project Info-Evaluation by TechnionYP5777.

the class Connector method runQuery.

public ArrayList<Row> runQuery(final String query, final Object[] inputs) throws SQLException, ClassNotFoundException, IOException {
    Connection conn = getConnection();
    ArrayList<Row> table = new ArrayList<Row>();
    PreparedStatement ps = conn.prepareStatement(query);
    for (int ¢ = 1; ¢ <= inputs.length; ++¢) ps.setObject(¢, inputs[¢ - 1]);
    ResultSet rs = ps.executeQuery();
    if (rs != null) {
        Row.formTable(rs, table);
        rs.close();
    }
    if (ps != null)
        ps.close();
    if (conn != null)
        conn.close();
    return table;
}
Also used : Connection(java.sql.Connection) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Row(infoeval.main.mysql.Row)

Aggregations

Row (infoeval.main.mysql.Row)10 Test (org.junit.Test)8 Connector (infoeval.main.WikiData.Connector)6 Ignore (org.junit.Ignore)5 ArrayList (java.util.ArrayList)3 Extractor (infoeval.main.WikiData.Extractor)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 AfterClass (org.junit.AfterClass)2 BeforeClass (org.junit.BeforeClass)2 TableEntry (infoeval.main.mysql.TableEntry)1 Statement (java.sql.Statement)1