Search in sources :

Example 11 with FilterCriteria

use of org.openhab.core.persistence.FilterCriteria in project openhab1-addons by openhab.

the class AbstractTwoItemIntegrationTest method testQueryUsingName.

@Test
public void testQueryUsingName() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setOrdering(Ordering.ASCENDING);
    criteria.setItemName(getItemName());
    Iterable<HistoricItem> iterable = BaseIntegrationTest.service.query(criteria);
    assertIterableContainsItems(iterable, true);
}
Also used : FilterCriteria(org.openhab.core.persistence.FilterCriteria) HistoricItem(org.openhab.core.persistence.HistoricItem) Test(org.junit.Test)

Example 12 with FilterCriteria

use of org.openhab.core.persistence.FilterCriteria in project openhab1-addons by openhab.

the class AbstractTwoItemIntegrationTest method testQueryUsingNameAndStartAndEndWithLTOperator.

@Test
public void testQueryUsingNameAndStartAndEndWithLTOperator() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setOperator(Operator.LT);
    criteria.setState(getSecondItemState());
    criteria.setItemName(getItemName());
    criteria.setBeginDate(beforeStore);
    criteria.setEndDate(afterStore2);
    Iterable<HistoricItem> iterable = BaseIntegrationTest.service.query(criteria);
    Iterator<HistoricItem> iterator = iterable.iterator();
    HistoricItem actual1 = iterator.next();
    assertFalse(iterator.hasNext());
    assertStateEquals(getFirstItemState(), actual1.getState());
    assertTrue(actual1.getTimestamp().before(afterStore1));
    assertTrue(actual1.getTimestamp().after(beforeStore));
}
Also used : FilterCriteria(org.openhab.core.persistence.FilterCriteria) HistoricItem(org.openhab.core.persistence.HistoricItem) Test(org.junit.Test)

Example 13 with FilterCriteria

use of org.openhab.core.persistence.FilterCriteria in project openhab1-addons by openhab.

the class AbstractTwoItemIntegrationTest method testQueryUsingNameAndStartAndEndWithLTOperatorNoMatch.

@Test
public void testQueryUsingNameAndStartAndEndWithLTOperatorNoMatch() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setOperator(Operator.LT);
    criteria.setState(getFirstItemState());
    criteria.setItemName(getItemName());
    criteria.setBeginDate(beforeStore);
    criteria.setEndDate(afterStore2);
    Iterable<HistoricItem> iterable = BaseIntegrationTest.service.query(criteria);
    Iterator<HistoricItem> iterator = iterable.iterator();
    assertFalse(iterator.hasNext());
}
Also used : FilterCriteria(org.openhab.core.persistence.FilterCriteria) HistoricItem(org.openhab.core.persistence.HistoricItem) Test(org.junit.Test)

Example 14 with FilterCriteria

use of org.openhab.core.persistence.FilterCriteria in project openhab1-addons by openhab.

the class AbstractTwoItemIntegrationTest method testQueryUsingNameAndStartAndEndWithGTOperatorNoMatch.

@Test
public void testQueryUsingNameAndStartAndEndWithGTOperatorNoMatch() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setOperator(Operator.GT);
    criteria.setState(getSecondItemState());
    criteria.setItemName(getItemName());
    criteria.setBeginDate(beforeStore);
    criteria.setEndDate(afterStore2);
    Iterable<HistoricItem> iterable = BaseIntegrationTest.service.query(criteria);
    Iterator<HistoricItem> iterator = iterable.iterator();
    assertFalse(iterator.hasNext());
}
Also used : FilterCriteria(org.openhab.core.persistence.FilterCriteria) HistoricItem(org.openhab.core.persistence.HistoricItem) Test(org.junit.Test)

Example 15 with FilterCriteria

use of org.openhab.core.persistence.FilterCriteria in project openhab1-addons by openhab.

the class AbstractTwoItemIntegrationTest method testQueryUsingNameAndStartAndEndNoMatch.

@Test
public void testQueryUsingNameAndStartAndEndNoMatch() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setItemName(getItemName());
    criteria.setBeginDate(beforeStore);
    // sic
    criteria.setEndDate(beforeStore);
    Iterable<HistoricItem> iterable = BaseIntegrationTest.service.query(criteria);
    assertFalse(iterable.iterator().hasNext());
}
Also used : FilterCriteria(org.openhab.core.persistence.FilterCriteria) HistoricItem(org.openhab.core.persistence.HistoricItem) Test(org.junit.Test)

Aggregations

FilterCriteria (org.openhab.core.persistence.FilterCriteria)19 HistoricItem (org.openhab.core.persistence.HistoricItem)19 Test (org.junit.Test)17 Query (com.db4o.query.Query)1 Date (java.util.Date)1