Search in sources :

Example 21 with Discovery4Search

use of siena.base.test.model.Discovery4Search in project siena by mandubian.

the class GaeTest method testSearchSingleFieldBeginSeveralResults.

public void testSearchSingleFieldBeginSeveralResults() {
    Discovery4Search[] discs = new Discovery4Search[5];
    discs[0] = new Discovery4Search("alpha", LongAutoID_CURIE);
    discs[1] = new Discovery4Search("beta", LongAutoID_CURIE);
    discs[2] = new Discovery4Search("alphagamma", LongAutoID_CURIE);
    discs[3] = new Discovery4Search("delta", LongAutoID_CURIE);
    discs[4] = new Discovery4Search("eta", LongAutoID_CURIE);
    pm.insert((Object[]) discs);
    Query<Discovery4Search> query = pm.createQuery(Discovery4Search.class).search("alpha*", "name");
    List<Discovery4Search> res = query.fetch();
    assertEquals(2, res.size());
    assertEquals(discs[0], res.get(0));
    assertEquals(discs[2], res.get(1));
}
Also used : Discovery4Search(siena.base.test.model.Discovery4Search)

Example 22 with Discovery4Search

use of siena.base.test.model.Discovery4Search in project siena by mandubian.

the class BaseAsyncTest method testSearchSingleCount.

public void testSearchSingleCount() {
    Discovery4Search[] discs = new Discovery4Search[100];
    for (int i = 0; i < 100; i++) {
        discs[i] = new Discovery4Search("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs).get();
    QueryAsync<Discovery4Search> query = pm.createQuery(Discovery4Search.class).search("Disc_5", "name");
    int res = query.count().get();
    assertEquals(1, res);
}
Also used : Discovery4Search(siena.base.test.model.Discovery4Search)

Example 23 with Discovery4Search

use of siena.base.test.model.Discovery4Search in project siena by mandubian.

the class BaseTest method testSearchSingle.

public void testSearchSingle() {
    Discovery4Search[] discs = new Discovery4Search[100];
    for (int i = 0; i < 100; i++) {
        discs[i] = new Discovery4Search("Disc_" + i, LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery4Search> query = pm.createQuery(Discovery4Search.class).search("Disc_5", "name");
    List<Discovery4Search> res = query.fetch();
    assertEquals(1, res.size());
    assertEquals(discs[5], res.get(0));
}
Also used : Discovery4Search(siena.base.test.model.Discovery4Search)

Example 24 with Discovery4Search

use of siena.base.test.model.Discovery4Search in project siena by mandubian.

the class PostgresqlTest method testSearchMultipleWordsSingleField.

public void testSearchMultipleWordsSingleField() {
    Discovery4Search AB = new Discovery4Search("alpha beta", LongAutoID_CURIE);
    Discovery4Search GB = new Discovery4Search("gamma beta", LongAutoID_CURIE);
    Discovery4Search GD = new Discovery4Search("gamma delta", LongAutoID_CURIE);
    Discovery4Search ET = new Discovery4Search("epsilon theta", LongAutoID_CURIE);
    pm.insert(AB);
    pm.insert(GB);
    pm.insert(GD);
    pm.insert(ET);
    Query<Discovery4Search> query = pm.createQuery(Discovery4Search.class).search("alpha | delta", "name").order("name");
    List<Discovery4Search> res = query.fetch();
    assertEquals(2, res.size());
    assertEquals(AB, res.get(0));
    assertEquals(GD, res.get(1));
}
Also used : Discovery4Search(siena.base.test.model.Discovery4Search)

Example 25 with Discovery4Search

use of siena.base.test.model.Discovery4Search in project siena by mandubian.

the class JdbcTest method testSearchSingleTwiceInTheSameQuery.

// 2 searches in the same query is not available in Postgres for the time being
public void testSearchSingleTwiceInTheSameQuery() {
    Discovery4Search[] discs = new Discovery4Search[100];
    for (int i = 0; i < 100; i++) {
        discs[i] = new Discovery4Search("Disc_" + i + " " + (100 - i) + "_csid", LongAutoID_CURIE);
    }
    pm.insert((Object[]) discs);
    Query<Discovery4Search> query = pm.createQuery(Discovery4Search.class).search("Disc_5", "name").search("95_csid");
    try {
        List<Discovery4Search> res = query.fetch();
    } catch (SienaRestrictedApiException ex) {
        return;
    }
    fail();
}
Also used : SienaRestrictedApiException(siena.SienaRestrictedApiException) Discovery4Search(siena.base.test.model.Discovery4Search)

Aggregations

Discovery4Search (siena.base.test.model.Discovery4Search)25 List (java.util.List)7 ArrayList (java.util.ArrayList)3 SienaException (siena.SienaException)2 SienaRestrictedApiException (siena.SienaRestrictedApiException)2