Search in sources :

Example 1 with AnalyticsTableUpdateParams

use of org.hisp.dhis.analytics.AnalyticsTableUpdateParams in project dhis2-core by dhis2.

the class JdbcEventAnalyticsTableManagerTest method verifyGetAnalyticsTableWithOuLevels.

@Test
void verifyGetAnalyticsTableWithOuLevels() {
    List<OrganisationUnitLevel> ouLevels = rnd.objects(OrganisationUnitLevel.class, 2).collect(Collectors.toList());
    Program programA = rnd.nextObject(Program.class);
    programA.setId(0);
    when(idObjectManager.getAllNoAcl(Program.class)).thenReturn(Collections.singletonList(programA));
    when(organisationUnitService.getFilledOrganisationUnitLevels()).thenReturn(ouLevels);
    when(jdbcTemplate.queryForList("select distinct(extract(year from psi.executiondate)) from programstageinstance psi inner join programinstance pi on psi.programinstanceid = pi.programinstanceid where psi.lastupdated <= '2019-08-01T00:00:00' and pi.programid = 0 and psi.executiondate is not null and psi.executiondate > '1000-01-01' and psi.deleted is false ", Integer.class)).thenReturn(Lists.newArrayList(2018, 2019));
    AnalyticsTableUpdateParams params = AnalyticsTableUpdateParams.newBuilder().withStartTime(START_TIME).build();
    List<AnalyticsTable> tables = subject.getAnalyticsTables(params);
    assertThat(tables, hasSize(1));
    new AnalyticsTableAsserter.Builder(tables.get(0)).withTableName(TABLE_PREFIX + programA.getUid().toLowerCase()).withTableType(AnalyticsTableType.EVENT).withColumnSize(subject.getFixedColumns().size() + PeriodType.getAvailablePeriodTypes().size() + ouLevels.size() + (programA.isRegistration() ? 1 : 0)).addColumns(periodColumns).withDefaultColumns(subject.getFixedColumns()).addColumn(quote("uidlevel" + ouLevels.get(0).getLevel()), col -> match(ouLevels.get(0), col)).addColumn(quote("uidlevel" + ouLevels.get(1).getLevel()), col -> match(ouLevels.get(1), col)).build().verify();
}
Also used : AnalyticsTableAsserter(org.hisp.dhis.analytics.util.AnalyticsTableAsserter) BeforeEach(org.junit.jupiter.api.BeforeEach) CategoryService(org.hisp.dhis.category.CategoryService) BeanRandomizer(org.hisp.dhis.random.BeanRandomizer) CHARACTER_11(org.hisp.dhis.analytics.ColumnDataType.CHARACTER_11) ResourceTableService(org.hisp.dhis.resourcetable.ResourceTableService) Date(java.util.Date) ValueType(org.hisp.dhis.common.ValueType) AnalyticsTableUpdateParams(org.hisp.dhis.analytics.AnalyticsTableUpdateParams) OrganisationUnitService(org.hisp.dhis.organisationunit.OrganisationUnitService) GEOMETRY(org.hisp.dhis.analytics.ColumnDataType.GEOMETRY) GEOMETRY_POINT(org.hisp.dhis.analytics.ColumnDataType.GEOMETRY_POINT) DhisConvenienceTest.createProgramStage(org.hisp.dhis.DhisConvenienceTest.createProgramStage) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) INTEGER(org.hisp.dhis.analytics.ColumnDataType.INTEGER) Map(java.util.Map) AnalyticsTableType(org.hisp.dhis.analytics.AnalyticsTableType) DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) IndexType(org.hisp.dhis.analytics.IndexType) Category(org.hisp.dhis.category.Category) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Sets(com.google.common.collect.Sets) Test(org.junit.jupiter.api.Test) List(java.util.List) DhisConvenienceTest.createCategory(org.hisp.dhis.DhisConvenienceTest.createCategory) DhisConvenienceTest.createDataElement(org.hisp.dhis.DhisConvenienceTest.createDataElement) Matchers.equalTo(org.hamcrest.Matchers.equalTo) LocalDate(java.time.LocalDate) Matchers.is(org.hamcrest.Matchers.is) DhisConvenienceTest.createProgramTrackedEntityAttribute(org.hisp.dhis.DhisConvenienceTest.createProgramTrackedEntityAttribute) CategoryCombo(org.hisp.dhis.category.CategoryCombo) Matchers.containsString(org.hamcrest.Matchers.containsString) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) Mockito.mock(org.mockito.Mockito.mock) TIMESTAMP(org.hisp.dhis.analytics.ColumnDataType.TIMESTAMP) DhisConvenienceTest.createTrackedEntityAttribute(org.hisp.dhis.DhisConvenienceTest.createTrackedEntityAttribute) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) DOUBLE(org.hisp.dhis.analytics.ColumnDataType.DOUBLE) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn) Mock(org.mockito.Mock) PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) AnalyticsTableHookService(org.hisp.dhis.analytics.AnalyticsTableHookService) PartitionManager(org.hisp.dhis.analytics.partition.PartitionManager) Program(org.hisp.dhis.program.Program) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) HashSet(java.util.HashSet) DataElement(org.hisp.dhis.dataelement.DataElement) DatabaseInfo(org.hisp.dhis.system.database.DatabaseInfo) ArgumentCaptor(org.mockito.ArgumentCaptor) Lists(com.google.common.collect.Lists) IdentifiableObjectManager(org.hisp.dhis.common.IdentifiableObjectManager) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) BIGINT(org.hisp.dhis.analytics.ColumnDataType.BIGINT) SystemSettingManager(org.hisp.dhis.setting.SystemSettingManager) ColumnNotNullConstraint(org.hisp.dhis.analytics.ColumnNotNullConstraint) DhisConvenienceTest.createCategoryCombo(org.hisp.dhis.DhisConvenienceTest.createCategoryCombo) DataApprovalLevelService(org.hisp.dhis.dataapproval.DataApprovalLevelService) AnalyticsTablePartition(org.hisp.dhis.analytics.AnalyticsTablePartition) DateTime(org.joda.time.DateTime) TEXT(org.hisp.dhis.analytics.ColumnDataType.TEXT) AggregationType(org.hisp.dhis.analytics.AggregationType) Mockito.when(org.mockito.Mockito.when) StatementBuilder(org.hisp.dhis.jdbc.StatementBuilder) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet) ProgramStage(org.hisp.dhis.program.ProgramStage) Mockito.verify(org.mockito.Mockito.verify) Mockito(org.mockito.Mockito) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) PeriodType(org.hisp.dhis.period.PeriodType) DhisConvenienceTest.getDate(org.hisp.dhis.DhisConvenienceTest.getDate) SettingKey(org.hisp.dhis.setting.SettingKey) Collections(java.util.Collections) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) Program(org.hisp.dhis.program.Program) AnalyticsTableAsserter(org.hisp.dhis.analytics.util.AnalyticsTableAsserter) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) AnalyticsTableUpdateParams(org.hisp.dhis.analytics.AnalyticsTableUpdateParams) Test(org.junit.jupiter.api.Test)

Example 2 with AnalyticsTableUpdateParams

use of org.hisp.dhis.analytics.AnalyticsTableUpdateParams in project dhis2-core by dhis2.

the class JdbcEventAnalyticsTableManagerTest method verifyGetLatestAnalyticsTables.

@Test
void verifyGetLatestAnalyticsTables() {
    Program prA = createProgram('A');
    Program prB = createProgram('B');
    Program prC = createProgram('C');
    Program prD = createProgram('D');
    List<Program> programs = Lists.newArrayList(prA, prB, prC, prD);
    Date lastFullTableUpdate = new DateTime(2019, 3, 1, 2, 0).toDate();
    Date lastLatestPartitionUpdate = new DateTime(2019, 3, 1, 9, 0).toDate();
    Date startTime = new DateTime(2019, 3, 1, 10, 0).toDate();
    Set<String> skipPrograms = new HashSet<>();
    skipPrograms.add(prC.getUid());
    skipPrograms.add(prD.getUid());
    AnalyticsTableUpdateParams params = AnalyticsTableUpdateParams.newBuilder().withStartTime(startTime).withLatestPartition().withSkipPrograms(skipPrograms).build();
    List<Map<String, Object>> queryResp = Lists.newArrayList();
    queryResp.add(ImmutableMap.of("dataelementid", 1));
    when(systemSettingManager.getDateSetting(SettingKey.LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE)).thenReturn(lastFullTableUpdate);
    when(systemSettingManager.getDateSetting(SettingKey.LAST_SUCCESSFUL_LATEST_ANALYTICS_PARTITION_UPDATE)).thenReturn(lastLatestPartitionUpdate);
    when(jdbcTemplate.queryForList(Mockito.anyString())).thenReturn(queryResp);
    when(idObjectManager.getAllNoAcl(Program.class)).thenReturn(programs);
    List<AnalyticsTable> tables = subject.getAnalyticsTables(params);
    assertThat(tables, hasSize(2));
    AnalyticsTable tableA = tables.get(0);
    AnalyticsTable tableB = tables.get(1);
    assertThat(tableA, notNullValue());
    assertThat(tableB, notNullValue());
    AnalyticsTablePartition partitionA = tableA.getLatestPartition();
    AnalyticsTablePartition partitionB = tableA.getLatestPartition();
    assertThat(partitionA, notNullValue());
    assertThat(partitionA.isLatestPartition(), equalTo(true));
    assertThat(partitionA.getStartDate(), equalTo(lastFullTableUpdate));
    assertThat(partitionA.getEndDate(), equalTo(startTime));
    assertThat(partitionB, notNullValue());
    assertThat(partitionB.isLatestPartition(), equalTo(true));
    assertThat(partitionB.getStartDate(), equalTo(lastFullTableUpdate));
    assertThat(partitionB.getEndDate(), equalTo(startTime));
}
Also used : DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) Program(org.hisp.dhis.program.Program) AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) AnalyticsTableUpdateParams(org.hisp.dhis.analytics.AnalyticsTableUpdateParams) Matchers.containsString(org.hamcrest.Matchers.containsString) Date(java.util.Date) LocalDate(java.time.LocalDate) DhisConvenienceTest.getDate(org.hisp.dhis.DhisConvenienceTest.getDate) DateTime(org.joda.time.DateTime) AnalyticsTablePartition(org.hisp.dhis.analytics.AnalyticsTablePartition) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 3 with AnalyticsTableUpdateParams

use of org.hisp.dhis.analytics.AnalyticsTableUpdateParams in project dhis2-core by dhis2.

the class JdbcEventAnalyticsTableManagerTest method verifyGetAnalyticsTableWithOuGroupSet.

@Test
void verifyGetAnalyticsTableWithOuGroupSet() {
    List<OrganisationUnitGroupSet> ouGroupSet = rnd.objects(OrganisationUnitGroupSet.class, 2).collect(Collectors.toList());
    Program programA = rnd.nextObject(Program.class);
    programA.setId(0);
    when(idObjectManager.getAllNoAcl(Program.class)).thenReturn(Collections.singletonList(programA));
    when(idObjectManager.getDataDimensionsNoAcl(OrganisationUnitGroupSet.class)).thenReturn(ouGroupSet);
    AnalyticsTableUpdateParams params = AnalyticsTableUpdateParams.newBuilder().withStartTime(START_TIME).build();
    when(jdbcTemplate.queryForList(getYearQueryForCurrentYear(programA, false), Integer.class)).thenReturn(Lists.newArrayList(2018, 2019));
    List<AnalyticsTable> tables = subject.getAnalyticsTables(params);
    assertThat(tables, hasSize(1));
    new AnalyticsTableAsserter.Builder(tables.get(0)).withTableName(TABLE_PREFIX + programA.getUid().toLowerCase()).withTableType(AnalyticsTableType.EVENT).withColumnSize(subject.getFixedColumns().size() + PeriodType.getAvailablePeriodTypes().size() + ouGroupSet.size() + (programA.isRegistration() ? 1 : 0)).addColumns(periodColumns).withDefaultColumns(subject.getFixedColumns()).addColumn(quote(ouGroupSet.get(0).getUid()), col -> match(ouGroupSet.get(0), col)).addColumn(quote(ouGroupSet.get(1).getUid()), col -> match(ouGroupSet.get(1), col)).build().verify();
}
Also used : AnalyticsTableAsserter(org.hisp.dhis.analytics.util.AnalyticsTableAsserter) BeforeEach(org.junit.jupiter.api.BeforeEach) CategoryService(org.hisp.dhis.category.CategoryService) BeanRandomizer(org.hisp.dhis.random.BeanRandomizer) CHARACTER_11(org.hisp.dhis.analytics.ColumnDataType.CHARACTER_11) ResourceTableService(org.hisp.dhis.resourcetable.ResourceTableService) Date(java.util.Date) ValueType(org.hisp.dhis.common.ValueType) AnalyticsTableUpdateParams(org.hisp.dhis.analytics.AnalyticsTableUpdateParams) OrganisationUnitService(org.hisp.dhis.organisationunit.OrganisationUnitService) GEOMETRY(org.hisp.dhis.analytics.ColumnDataType.GEOMETRY) GEOMETRY_POINT(org.hisp.dhis.analytics.ColumnDataType.GEOMETRY_POINT) DhisConvenienceTest.createProgramStage(org.hisp.dhis.DhisConvenienceTest.createProgramStage) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) INTEGER(org.hisp.dhis.analytics.ColumnDataType.INTEGER) Map(java.util.Map) AnalyticsTableType(org.hisp.dhis.analytics.AnalyticsTableType) DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) IndexType(org.hisp.dhis.analytics.IndexType) Category(org.hisp.dhis.category.Category) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Sets(com.google.common.collect.Sets) Test(org.junit.jupiter.api.Test) List(java.util.List) DhisConvenienceTest.createCategory(org.hisp.dhis.DhisConvenienceTest.createCategory) DhisConvenienceTest.createDataElement(org.hisp.dhis.DhisConvenienceTest.createDataElement) Matchers.equalTo(org.hamcrest.Matchers.equalTo) LocalDate(java.time.LocalDate) Matchers.is(org.hamcrest.Matchers.is) DhisConvenienceTest.createProgramTrackedEntityAttribute(org.hisp.dhis.DhisConvenienceTest.createProgramTrackedEntityAttribute) CategoryCombo(org.hisp.dhis.category.CategoryCombo) Matchers.containsString(org.hamcrest.Matchers.containsString) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) Mockito.mock(org.mockito.Mockito.mock) TIMESTAMP(org.hisp.dhis.analytics.ColumnDataType.TIMESTAMP) DhisConvenienceTest.createTrackedEntityAttribute(org.hisp.dhis.DhisConvenienceTest.createTrackedEntityAttribute) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) DOUBLE(org.hisp.dhis.analytics.ColumnDataType.DOUBLE) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn) Mock(org.mockito.Mock) PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) AnalyticsTableHookService(org.hisp.dhis.analytics.AnalyticsTableHookService) PartitionManager(org.hisp.dhis.analytics.partition.PartitionManager) Program(org.hisp.dhis.program.Program) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) HashSet(java.util.HashSet) DataElement(org.hisp.dhis.dataelement.DataElement) DatabaseInfo(org.hisp.dhis.system.database.DatabaseInfo) ArgumentCaptor(org.mockito.ArgumentCaptor) Lists(com.google.common.collect.Lists) IdentifiableObjectManager(org.hisp.dhis.common.IdentifiableObjectManager) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) BIGINT(org.hisp.dhis.analytics.ColumnDataType.BIGINT) SystemSettingManager(org.hisp.dhis.setting.SystemSettingManager) ColumnNotNullConstraint(org.hisp.dhis.analytics.ColumnNotNullConstraint) DhisConvenienceTest.createCategoryCombo(org.hisp.dhis.DhisConvenienceTest.createCategoryCombo) DataApprovalLevelService(org.hisp.dhis.dataapproval.DataApprovalLevelService) AnalyticsTablePartition(org.hisp.dhis.analytics.AnalyticsTablePartition) DateTime(org.joda.time.DateTime) TEXT(org.hisp.dhis.analytics.ColumnDataType.TEXT) AggregationType(org.hisp.dhis.analytics.AggregationType) Mockito.when(org.mockito.Mockito.when) StatementBuilder(org.hisp.dhis.jdbc.StatementBuilder) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet) ProgramStage(org.hisp.dhis.program.ProgramStage) Mockito.verify(org.mockito.Mockito.verify) Mockito(org.mockito.Mockito) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) PeriodType(org.hisp.dhis.period.PeriodType) DhisConvenienceTest.getDate(org.hisp.dhis.DhisConvenienceTest.getDate) SettingKey(org.hisp.dhis.setting.SettingKey) Collections(java.util.Collections) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) Program(org.hisp.dhis.program.Program) AnalyticsTableAsserter(org.hisp.dhis.analytics.util.AnalyticsTableAsserter) AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) AnalyticsTableUpdateParams(org.hisp.dhis.analytics.AnalyticsTableUpdateParams) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet) Test(org.junit.jupiter.api.Test)

Example 4 with AnalyticsTableUpdateParams

use of org.hisp.dhis.analytics.AnalyticsTableUpdateParams in project dhis2-core by dhis2.

the class JdbcEnrollmentAnalyticsTableManagerTest method verifyTeiTypeOrgUnitFetchesOuUidWhenPopulatingEventAnalyticsTable.

@Test
void verifyTeiTypeOrgUnitFetchesOuUidWhenPopulatingEventAnalyticsTable() {
    ArgumentCaptor<String> sql = ArgumentCaptor.forClass(String.class);
    when(databaseInfo.isSpatialSupport()).thenReturn(true);
    Program p1 = createProgram('A');
    TrackedEntityAttribute tea = createTrackedEntityAttribute('a', ValueType.ORGANISATION_UNIT);
    tea.setId(9999);
    ProgramTrackedEntityAttribute programTrackedEntityAttribute = createProgramTrackedEntityAttribute(p1, tea);
    p1.setProgramAttributes(Lists.newArrayList(programTrackedEntityAttribute));
    when(idObjectManager.getAllNoAcl(Program.class)).thenReturn(Lists.newArrayList(p1));
    AnalyticsTableUpdateParams params = AnalyticsTableUpdateParams.newBuilder().withLastYears(2).withStartTime(START_TIME).build();
    subject.populateTable(params, PartitionUtils.getTablePartitions(subject.getAnalyticsTables(params)).get(0));
    verify(jdbcTemplate).execute(sql.capture());
    String ouQuery = "(select ou.%s from organisationunit ou where ou.uid = " + "(select value from trackedentityattributevalue where trackedentityinstanceid=pi.trackedentityinstanceid and " + "trackedentityattributeid=9999)) as \"" + tea.getUid() + "\"";
    assertThat(sql.getValue(), containsString(String.format(ouQuery, "uid")));
}
Also used : Program(org.hisp.dhis.program.Program) DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) DhisConvenienceTest.createTrackedEntityAttribute(org.hisp.dhis.DhisConvenienceTest.createTrackedEntityAttribute) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) DhisConvenienceTest.createProgramTrackedEntityAttribute(org.hisp.dhis.DhisConvenienceTest.createProgramTrackedEntityAttribute) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) DhisConvenienceTest.createProgramTrackedEntityAttribute(org.hisp.dhis.DhisConvenienceTest.createProgramTrackedEntityAttribute) AnalyticsTableUpdateParams(org.hisp.dhis.analytics.AnalyticsTableUpdateParams) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.jupiter.api.Test)

Example 5 with AnalyticsTableUpdateParams

use of org.hisp.dhis.analytics.AnalyticsTableUpdateParams in project dhis2-core by dhis2.

the class JdbcAnalyticsTableManagerTest method testGetRegularAnalyticsTable.

@Test
void testGetRegularAnalyticsTable() {
    Date startTime = new DateTime(2019, 3, 1, 10, 0).toDate();
    List<Integer> dataYears = Lists.newArrayList(2018, 2019);
    AnalyticsTableUpdateParams params = AnalyticsTableUpdateParams.newBuilder().withStartTime(startTime).build();
    when(jdbcTemplate.queryForList(Mockito.anyString(), ArgumentMatchers.<Class<Integer>>any())).thenReturn(dataYears);
    List<AnalyticsTable> tables = subject.getAnalyticsTables(params);
    assertEquals(1, tables.size());
    AnalyticsTable table = tables.get(0);
    assertNotNull(table);
    assertNotNull(table.getTablePartitions());
    assertEquals(2, table.getTablePartitions().size());
    AnalyticsTablePartition partitionA = table.getTablePartitions().get(0);
    AnalyticsTablePartition partitionB = table.getTablePartitions().get(1);
    assertNotNull(partitionA);
    assertNotNull(partitionA.getStartDate());
    assertNotNull(partitionA.getEndDate());
    assertEquals(partitionA.getYear().intValue(), new DateTime(partitionA.getStartDate()).getYear());
    assertNotNull(partitionB);
    assertNotNull(partitionB.getStartDate());
    assertNotNull(partitionB.getEndDate());
    assertEquals(partitionB.getYear().intValue(), new DateTime(partitionB.getStartDate()).getYear());
}
Also used : AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) AnalyticsTableUpdateParams(org.hisp.dhis.analytics.AnalyticsTableUpdateParams) AnalyticsTablePartition(org.hisp.dhis.analytics.AnalyticsTablePartition) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test)

Aggregations

AnalyticsTableUpdateParams (org.hisp.dhis.analytics.AnalyticsTableUpdateParams)16 Test (org.junit.jupiter.api.Test)14 DhisConvenienceTest.createProgram (org.hisp.dhis.DhisConvenienceTest.createProgram)11 Program (org.hisp.dhis.program.Program)11 Date (java.util.Date)9 Matchers.containsString (org.hamcrest.Matchers.containsString)9 AnalyticsTable (org.hisp.dhis.analytics.AnalyticsTable)9 DhisConvenienceTest.createProgramTrackedEntityAttribute (org.hisp.dhis.DhisConvenienceTest.createProgramTrackedEntityAttribute)7 DhisConvenienceTest.createTrackedEntityAttribute (org.hisp.dhis.DhisConvenienceTest.createTrackedEntityAttribute)7 ProgramTrackedEntityAttribute (org.hisp.dhis.program.ProgramTrackedEntityAttribute)7 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)7 DateTime (org.joda.time.DateTime)7 DhisConvenienceTest.createDataElement (org.hisp.dhis.DhisConvenienceTest.createDataElement)6 DhisConvenienceTest.createProgramStage (org.hisp.dhis.DhisConvenienceTest.createProgramStage)6 AnalyticsTablePartition (org.hisp.dhis.analytics.AnalyticsTablePartition)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 Map (java.util.Map)5 LocalDate (java.time.LocalDate)4 HashSet (java.util.HashSet)4 DhisConvenienceTest.createCategory (org.hisp.dhis.DhisConvenienceTest.createCategory)4