use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class AclServiceTest method testResetSharingEventVisualizationPropsPrivate.
@Test
void testResetSharingEventVisualizationPropsPrivate() {
// Given
User user = createAdminUser();
EventVisualization eventVisualization = new EventVisualization();
eventVisualization.setAutoFields();
eventVisualization.setPublicAccess(AccessStringHelper.DEFAULT);
eventVisualization.setExternalAccess(true);
eventVisualization.setType(EventVisualizationType.COLUMN);
assertFalse(aclService.verifySharing(eventVisualization, user).isEmpty());
// When
aclService.resetSharing(eventVisualization, user);
// Then
assertEquals(AccessStringHelper.DEFAULT, eventVisualization.getPublicAccess());
assertFalse(eventVisualization.getExternalAccess());
assertTrue(eventVisualization.getUserAccesses().isEmpty());
assertTrue(eventVisualization.getUserGroupAccesses().isEmpty());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class AclServiceTest method testUserBCanUpdateEventVisualizationWithAuthorityNoUserAccess.
@Test
void testUserBCanUpdateEventVisualizationWithAuthorityNoUserAccess() {
// 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);
manager.update(eventVisualization);
assertFalse(aclService.canUpdate(userB, eventVisualization));
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class AclServiceTest method testResetSharingEventVisualizationPropsPublic.
@Test
void testResetSharingEventVisualizationPropsPublic() {
// 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);
assertFalse(aclService.verifySharing(eventVisualization, user).isEmpty());
// When
aclService.resetSharing(eventVisualization, user);
// Then
assertEquals(AccessStringHelper.READ_WRITE, eventVisualization.getPublicAccess());
assertFalse(eventVisualization.getExternalAccess());
assertTrue(eventVisualization.getUserAccesses().isEmpty());
assertTrue(eventVisualization.getUserGroupAccesses().isEmpty());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class AclServiceTest method testCanUpdatePrivateEventVisualization.
@Test
void testCanUpdatePrivateEventVisualization() {
// Given
User user = createAdminUser("F_DATAELEMENT_PRIVATE_ADD");
EventVisualization eventVisualization = new EventVisualization("any");
eventVisualization.setAutoFields();
eventVisualization.setCreatedBy(user);
eventVisualization.getSharing().setOwner(user);
eventVisualization.setType(EventVisualizationType.COLUMN);
eventVisualization.setPublicAccess(AccessStringHelper.DEFAULT);
// Then
assertTrue(aclService.canUpdate(user, eventVisualization));
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DashboardItemDeletionHandlerTest method testDeleteEventVisualization.
@Test
void testDeleteEventVisualization() {
programService.addProgram(program);
EventVisualization eventVisualization = createEventVisualization('A', program);
eventVisualizationService.save(eventVisualization);
dashboardItem.setEventVisualization(eventVisualization);
dashboardService.saveDashboard(dashboard);
assertEquals(1, dashboardService.getEventVisualizationDashboardItems(eventVisualization).size());
assertEquals(1, dashboard.getItemCount());
eventVisualizationService.delete(eventVisualization);
assertEquals(0, dashboardService.getEventVisualizationDashboardItems(eventVisualization).size());
assertEquals(0, dashboard.getItemCount());
}
Aggregations