Search in sources :

Example 1 with Connector

use of infoeval.main.WikiData.Connector 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 2 with Connector

use of infoeval.main.WikiData.Connector 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 3 with Connector

use of infoeval.main.WikiData.Connector 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 4 with Connector

use of infoeval.main.WikiData.Connector in project Info-Evaluation by TechnionYP5777.

the class ConnectorTest method wikiIdTableSizeTest.

@Ignore
@Test
public void wikiIdTableSizeTest() throws Exception {
    Connector conn = new Connector();
    assert conn.getConnection() != null;
    ArrayList<Row> rows = conn.runQuery("SELECT COUNT(*) FROM WikiID");
    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.WIKI_ID);
    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 5 with Connector

use of infoeval.main.WikiData.Connector in project Info-Evaluation by TechnionYP5777.

the class ConnectorTest method runUpdateTest.

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

Aggregations

Connector (infoeval.main.WikiData.Connector)7 Test (org.junit.Test)7 Row (infoeval.main.mysql.Row)6 Ignore (org.junit.Ignore)4 Extractor (infoeval.main.WikiData.Extractor)2 AfterClass (org.junit.AfterClass)2 BeforeClass (org.junit.BeforeClass)2 Connection (java.sql.Connection)1