Search in sources :

Example 6 with PointValueCache

use of com.infiniteautomation.mango.pointvaluecache.PointValueCache in project ma-core-public by infiniteautomation.

the class DataPointRTPointValueCacheTest method test1.

/**
 * Test an initial cash that is larger than the default
 */
@Test
public void test1() {
    DataPointVO vo = new DataPointVO();
    vo.setId(1);
    PointValueDao dao = Common.getBean(PointValueDao.class);
    PointValueCache pointValueCache = Common.getBean(PointValueCache.class);
    List<PointValueTime> initialCache = createCache(vo, 5);
    DataPointRTPointValueCache cache = new DataPointRTPointValueCache(vo, 1, initialCache, dao, pointValueCache);
    Assert.assertEquals(initialCache.get(0).getValue(), cache.getLatestPointValue().getValue());
    Assert.assertEquals(initialCache.get(0).getTime(), cache.getLatestPointValue().getTime());
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) PointValueDao(com.serotonin.m2m2.db.dao.PointValueDao) BasicSQLPointValueDao(com.serotonin.m2m2.db.dao.BasicSQLPointValueDao) PointValueCache(com.infiniteautomation.mango.pointvaluecache.PointValueCache) Test(org.junit.Test)

Example 7 with PointValueCache

use of com.infiniteautomation.mango.pointvaluecache.PointValueCache in project ma-core-public by infiniteautomation.

the class DataPointRTPointValueCacheTest method test3.

/**
 * Test resetting the cache
 */
@Test
public void test3() {
    DataPointVO vo = new DataPointVO();
    vo.setId(1);
    PointValueDao dao = Common.getBean(PointValueDao.class);
    PointValueCache pointValueCache = Common.getBean(PointValueCache.class);
    List<PointValueTime> initialCache = createCache(vo, 5);
    DataPointRTPointValueCache cache = new DataPointRTPointValueCache(vo, 5, initialCache, dao, pointValueCache);
    cache.invalidate(true);
    List<PointValueTime> latest = cache.getLatestPointValues(5);
    for (int i = 0; i < 5; i++) {
        Assert.assertEquals(initialCache.get(i).getValue(), latest.get(i).getValue());
        Assert.assertEquals(initialCache.get(i).getTime(), latest.get(i).getTime());
    }
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) PointValueDao(com.serotonin.m2m2.db.dao.PointValueDao) BasicSQLPointValueDao(com.serotonin.m2m2.db.dao.BasicSQLPointValueDao) PointValueCache(com.infiniteautomation.mango.pointvaluecache.PointValueCache) Test(org.junit.Test)

Aggregations

PointValueCache (com.infiniteautomation.mango.pointvaluecache.PointValueCache)7 PointValueDao (com.serotonin.m2m2.db.dao.PointValueDao)6 BasicSQLPointValueDao (com.serotonin.m2m2.db.dao.BasicSQLPointValueDao)5 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)5 Test (org.junit.Test)5 DataPointDao (com.serotonin.m2m2.db.dao.DataPointDao)2 ExecutorService (java.util.concurrent.ExecutorService)2 DataSourceDao (com.serotonin.m2m2.db.dao.DataSourceDao)1 PublisherDao (com.serotonin.m2m2.db.dao.PublisherDao)1 DataPointGroupInitializer (com.serotonin.m2m2.rt.DataPointGroupInitializer)1 RuntimeManagerImpl (com.serotonin.m2m2.rt.RuntimeManagerImpl)1 DataPointWithEventDetectors (com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1