Search in sources :

Example 16 with FilterCriteria

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

the class AbstractTwoItemIntegrationTest method testQueryUsingNameAndEnd.

@Test
public void testQueryUsingNameAndEnd() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setOrdering(Ordering.ASCENDING);
    criteria.setItemName(getItemName());
    criteria.setEndDate(afterStore2);
    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 17 with FilterCriteria

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

the class AbstractTwoItemIntegrationTest method testQueryUsingNameAndStartAndEndFirst.

@Test
public void testQueryUsingNameAndStartAndEndFirst() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setOrdering(Ordering.ASCENDING);
    criteria.setItemName(getItemName());
    criteria.setBeginDate(beforeStore);
    criteria.setEndDate(afterStore1);
    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 18 with FilterCriteria

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

the class AbstractTwoItemIntegrationTest method testQueryUsingNameAndStartNoMatch.

@Test
public void testQueryUsingNameAndStartNoMatch() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setItemName(getItemName());
    criteria.setBeginDate(afterStore2);
    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)

Example 19 with FilterCriteria

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

the class AbstractTwoItemIntegrationTest method testQueryUsingNameAndStartAndEndWithEQOperator.

@Test
public void testQueryUsingNameAndStartAndEndWithEQOperator() {
    FilterCriteria criteria = new FilterCriteria();
    criteria.setOperator(Operator.EQ);
    criteria.setState(getFirstItemState());
    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)

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