Search in sources :

Example 6 with StatisticKeyEntity

use of org.orcid.statistics.jpa.entities.StatisticKeyEntity in project ORCID-Source by ORCID.

the class StatisticsDaoTest method testStatistics.

@Test
@Transactional
public void testStatistics() {
    StatisticKeyEntity key = statisticsDao.createKey();
    StatisticKeyEntity latestKey = statisticsDao.createKey();
    StatisticValuesEntity os1 = new StatisticValuesEntity(latestKey, "s1", 11);
    StatisticValuesEntity os2 = new StatisticValuesEntity(latestKey, "s2", 3);
    StatisticValuesEntity os3 = new StatisticValuesEntity(latestKey, "s3", 12);
    StatisticValuesEntity os4 = new StatisticValuesEntity(latestKey, "s4", 7);
    StatisticValuesEntity os5 = new StatisticValuesEntity(latestKey, "s5", 0);
    StatisticValuesEntity os6 = new StatisticValuesEntity(key, "s6", 0);
    StatisticValuesEntity os7 = new StatisticValuesEntity(key, "s7", 0);
    statisticsDao.persist(os1);
    statisticsDao.persist(os2);
    statisticsDao.persist(os3);
    statisticsDao.persist(os4);
    statisticsDao.persist(os5);
    statisticsDao.persist(os6);
    statisticsDao.persist(os7);
    StatisticKeyEntity latestKeyFromDB = statisticsDao.getLatestKey();
    assertEquals(latestKey, latestKeyFromDB);
    List<StatisticValuesEntity> statistics = statisticsDao.getStatistic(latestKeyFromDB.getId());
    assertNotNull(statistics);
    assertEquals(statistics.size(), 5);
    assertTrue(statistics.contains(os1));
    assertTrue(statistics.contains(os2));
    assertTrue(statistics.contains(os3));
    assertTrue(statistics.contains(os4));
    assertTrue(statistics.contains(os5));
    assertFalse(statistics.contains(os6));
    assertFalse(statistics.contains(os7));
}
Also used : StatisticValuesEntity(org.orcid.statistics.jpa.entities.StatisticValuesEntity) StatisticKeyEntity(org.orcid.statistics.jpa.entities.StatisticKeyEntity) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

StatisticKeyEntity (org.orcid.statistics.jpa.entities.StatisticKeyEntity)6 Date (java.util.Date)4 StatisticValuesEntity (org.orcid.statistics.jpa.entities.StatisticValuesEntity)4 TreeMap (java.util.TreeMap)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Test (org.junit.Test)1 StatisticsSummary (org.orcid.jaxb.model.statistics.StatisticsSummary)1 StatisticsTimeline (org.orcid.jaxb.model.statistics.StatisticsTimeline)1 AnonymousAuthenticationToken (org.springframework.security.authentication.AnonymousAuthenticationToken)1 Authentication (org.springframework.security.core.Authentication)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)1