Search in sources :

Example 11 with Visualization

use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.

the class DimensionServiceTest method testMergeAnalyticalObjectB.

@Test
void testMergeAnalyticalObjectB() {
    Visualization visualization = new Visualization();
    BaseDimensionalObject deCDim = new BaseDimensionalObject(deC.getUid(), DimensionType.PROGRAM_DATA_ELEMENT, null, null, null, psA, "EQ:uidA");
    visualization.getColumns().add(deCDim);
    visualization.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouA, ouB, ouC)));
    visualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA, peB)));
    dimensionService.mergeAnalyticalObject(visualization);
    assertEquals(1, visualization.getDataElementDimensions().size());
    assertEquals(2, visualization.getPeriods().size());
    assertEquals(3, visualization.getOrganisationUnits().size());
    TrackedEntityDataElementDimension teDeDim = visualization.getDataElementDimensions().get(0);
    assertEquals(deC, teDeDim.getDataElement());
    assertEquals(psA, teDeDim.getProgramStage());
}
Also used : Visualization(org.hisp.dhis.visualization.Visualization) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) TrackedEntityDataElementDimension(org.hisp.dhis.trackedentity.TrackedEntityDataElementDimension) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 12 with Visualization

use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.

the class DimensionServiceTest method testMergeAnalyticalObjectA.

@Test
void testMergeAnalyticalObjectA() {
    Visualization visualization = new Visualization();
    visualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
    visualization.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouA, ouB, ouC, ouD, ouE)));
    visualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA, peB)));
    dimensionService.mergeAnalyticalObject(visualization);
    assertEquals(2, visualization.getDataDimensionItems().size());
    assertEquals(2, visualization.getPeriods().size());
    assertEquals(5, visualization.getOrganisationUnits().size());
}
Also used : Visualization(org.hisp.dhis.visualization.Visualization) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 13 with Visualization

use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.

the class DimensionServiceTest method testMergeAnalyticalObjectUserOrgUnit.

@Test
void testMergeAnalyticalObjectUserOrgUnit() {
    Visualization visualization = new Visualization();
    visualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
    visualization.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouUser)));
    visualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA)));
    dimensionService.mergeAnalyticalObject(visualization);
    assertEquals(2, visualization.getDataDimensionItems().size());
    assertEquals(1, visualization.getPeriods().size());
    assertEquals(0, visualization.getOrganisationUnits().size());
    assertTrue(visualization.isUserOrganisationUnit());
}
Also used : Visualization(org.hisp.dhis.visualization.Visualization) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 14 with Visualization

use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.

the class InterpretationServiceTest method testConstruct.

@Test
void testConstruct() {
    // Given
    final Visualization aVisualizationA = createVisualization('A');
    // When
    final Interpretation anInterpretationA = new Interpretation(aVisualizationA, null, "InterpretationA");
    final Interpretation anInterpretationB = new Interpretation(aVisualizationA, null, "InterpretationB");
    // Then
    assertEquals(aVisualizationA, anInterpretationA.getVisualization());
    assertEquals(aVisualizationA, anInterpretationB.getVisualization());
    assertTrue(aVisualizationA.getInterpretations().contains(anInterpretationA));
    assertTrue(aVisualizationA.getInterpretations().contains(anInterpretationB));
}
Also used : Visualization(org.hisp.dhis.visualization.Visualization) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 15 with Visualization

use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.

the class InterpretationServiceTest method testCreateChartAndInterpretationSyncSharing.

// TODO enable
@Test
@Disabled
void testCreateChartAndInterpretationSyncSharing() throws IOException {
    UserGroup userGroup = createUserGroup('A', Sets.newHashSet(userA, userB));
    userGroupService.addUserGroup(userGroup);
    Visualization visualization = createVisualization('A');
    manager.save(visualization);
    visualization.setPublicAccess(AccessStringHelper.READ_WRITE);
    visualization.getSharing().addUserGroupAccess(new UserGroupAccess(userGroup, AccessStringHelper.READ));
    assertEquals(1, visualization.getUserGroupAccesses().size());
    manager.update(visualization);
    assertEquals(AccessStringHelper.READ_WRITE, visualization.getPublicAccess());
    assertEquals(1, visualization.getUserGroupAccesses().size());
    Interpretation interpretation = new Interpretation(visualization, null, "test");
    interpretationService.saveInterpretation(interpretation);
    interpretationService.updateInterpretation(interpretation);
    assertEquals(AccessStringHelper.READ_WRITE, interpretation.getPublicAccess());
    assertEquals(interpretation.getUserGroupAccesses().size(), visualization.getUserGroupAccesses().size());
}
Also used : Visualization(org.hisp.dhis.visualization.Visualization) UserGroup(org.hisp.dhis.user.UserGroup) UserGroupAccess(org.hisp.dhis.user.sharing.UserGroupAccess) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

Visualization (org.hisp.dhis.visualization.Visualization)48 Test (org.junit.jupiter.api.Test)36 EventVisualization (org.hisp.dhis.eventvisualization.EventVisualization)26 DhisSpringTest (org.hisp.dhis.DhisSpringTest)17 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)14 User (org.hisp.dhis.user.User)13 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)8 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)7 DataElement (org.hisp.dhis.dataelement.DataElement)6 List (java.util.List)5 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)4 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)4 Period (org.hisp.dhis.period.Period)4 Date (java.util.Date)3 Dashboard (org.hisp.dhis.dashboard.Dashboard)3 DataSet (org.hisp.dhis.dataset.DataSet)3 ErrorReport (org.hisp.dhis.feedback.ErrorReport)3 UserAccess (org.hisp.dhis.user.sharing.UserAccess)3 ClassPathResource (org.springframework.core.io.ClassPathResource)3 ArrayList (java.util.ArrayList)2