use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalEventObjectB.
@Test
void testMergeAnalyticalEventObjectB() {
// Given
EventVisualization eventVisualization = new EventVisualization("any");
BaseDimensionalObject deCDim = new BaseDimensionalObject(deC.getUid(), DimensionType.PROGRAM_DATA_ELEMENT, null, null, null, psA, "EQ:uidA");
eventVisualization.getColumns().add(deCDim);
eventVisualization.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouA, ouB, ouC)));
eventVisualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA, peB)));
// When
dimensionService.mergeAnalyticalObject(eventVisualization);
// Then
assertEquals(1, eventVisualization.getDataElementDimensions().size());
assertEquals(2, eventVisualization.getPeriods().size());
assertEquals(3, eventVisualization.getOrganisationUnits().size());
TrackedEntityDataElementDimension teDeDim = eventVisualization.getDataElementDimensions().get(0);
assertEquals(deC, teDeDim.getDataElement());
assertEquals(psA, teDeDim.getProgramStage());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalEventObjectRelativePeriods.
@Test
void testMergeAnalyticalEventObjectRelativePeriods() {
// Given
EventVisualization eventVisualization = new EventVisualization("any");
eventVisualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
eventVisualization.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouA, ouB, ouC, ouD, ouE)));
eventVisualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peLast12Months)));
// When
dimensionService.mergeAnalyticalObject(eventVisualization);
// Then
assertEquals(2, eventVisualization.getDataDimensionItems().size());
assertEquals(0, eventVisualization.getPeriods().size());
assertTrue(eventVisualization.getRelatives().isLast12Months());
assertEquals(5, eventVisualization.getOrganisationUnits().size());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class AclServiceTest method testUserBCanUpdateEventVisualizationWithAuthority.
@Test
void testUserBCanUpdateEventVisualizationWithAuthority() {
// Given
User userA = createUser('A');
manager.save(userA);
EventVisualization eventVisualization = new EventVisualization();
eventVisualization.setAutoFields();
eventVisualization.setName("FavA");
eventVisualization.setCreatedBy(userA);
eventVisualization.getSharing().setOwner(userA);
eventVisualization.setPublicAccess(AccessStringHelper.DEFAULT);
eventVisualization.setType(EventVisualizationType.COLUMN);
assertTrue(aclService.canUpdate(userA, eventVisualization));
manager.save(eventVisualization);
// Then
UserAuthorityGroup userAuthorityGroup = new UserAuthorityGroup();
userAuthorityGroup.setAutoFields();
userAuthorityGroup.setName("UR");
userAuthorityGroup.getAuthorities().add("F_EVENT_VISUALIZATION_PUBLIC_ADD");
manager.save(userAuthorityGroup);
User userB = createUser('B');
userB.getUserAuthorityGroups().add(userAuthorityGroup);
manager.save(userB);
eventVisualization.getSharing().addUserAccess(new UserAccess(userB, AccessStringHelper.FULL));
manager.update(eventVisualization);
assertTrue(aclService.canUpdate(userB, eventVisualization));
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class AclServiceTest method testVerifyEventVisualizationCantExternalize.
@Test
void testVerifyEventVisualizationCantExternalize() {
// Given
User user = createAdminUser("F_EVENT_VISUALIZATION_PUBLIC_ADD");
EventVisualization eventVisualization = new EventVisualization();
eventVisualization.setAutoFields();
eventVisualization.setPublicAccess(AccessStringHelper.DEFAULT);
eventVisualization.setExternalAccess(true);
eventVisualization.setType(EventVisualizationType.COLUMN);
// Then
assertFalse(aclService.verifySharing(eventVisualization, user).isEmpty());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class AclServiceTest method testUserBCanUpdateEventVisualizationWithoutAuthority.
@Test
void testUserBCanUpdateEventVisualizationWithoutAuthority() {
// Given
User userA = createUser('A');
manager.save(userA);
EventVisualization eventVisualization = new EventVisualization();
eventVisualization.setAutoFields();
eventVisualization.setName("FavA");
eventVisualization.setCreatedBy(userA);
eventVisualization.getSharing().setOwner(userA);
eventVisualization.setPublicAccess(AccessStringHelper.DEFAULT);
eventVisualization.setType(EventVisualizationType.COLUMN);
assertTrue(aclService.canUpdate(userA, eventVisualization));
manager.save(eventVisualization);
// Then
User userB = createUser('B');
manager.save(userB);
eventVisualization.getSharing().addUserAccess(new UserAccess(userB, AccessStringHelper.FULL));
manager.update(eventVisualization);
assertTrue(aclService.canUpdate(userB, eventVisualization));
}
Aggregations