use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsServiceTest method testCannotRemoveToggleAccess.
@Test
@ExpectValidationException("togglePermission")
public void testCannotRemoveToggleAccess() {
MaintenanceEventVO vo = newVO(editUser);
setReadPermission(MangoPermission.requireAnyRole(roleService.getUserRole()), vo);
setEditPermission(MangoPermission.requireAnyRole(roleService.getUserRole()), vo);
service.insert(vo);
runAs.runAs(readUser, () -> {
MaintenanceEventVO fromDb = service.get(vo.getId());
assertVoEqual(vo, fromDb);
fromDb.setTogglePermission(MangoPermission.superadminOnly());
service.update(fromDb.getId(), fromDb);
});
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsServiceTest method updateVO.
@Override
MaintenanceEventVO updateVO(MaintenanceEventVO existing) {
MaintenanceEventVO copy = (MaintenanceEventVO) existing.copy();
copy.setName("new name");
List<Integer> dataPointIds = new ArrayList<>();
for (IDataPoint point : createMockDataPoints(10)) {
dataPointIds.add(point.getId());
}
copy.setDataPoints(dataPointIds);
return copy;
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsServiceTest method setEditPermission.
@Override
void setEditPermission(MangoPermission permission, MaintenanceEventVO vo) {
// A user with edit permission for the sources of all points (and all data sources sources) in this event has edit permission
if (permission != null) {
// Get the data points and add our roles to the read roles
for (int dpId : vo.getDataPoints()) {
DataPointVO dp = DataPointDao.getInstance().get(dpId);
dp.setEditPermission(permission);
DataPointDao.getInstance().update(dp.getId(), dp);
DataSourceVO ds = DataSourceDao.getInstance().get(dp.getDataSourceId());
ds.setEditPermission(permission);
DataSourceDao.getInstance().update(ds.getId(), ds);
}
}
vo.setTogglePermission(permission);
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsServiceTest method newVO.
@Override
MaintenanceEventVO newVO(User owner) {
MaintenanceEventVO vo = new MaintenanceEventVO();
vo.setName(UUID.randomUUID().toString());
List<Integer> dataPointIds = new ArrayList<>();
for (IDataPoint point : createMockDataPoints(5)) {
dataPointIds.add(point.getId());
}
vo.setDataPoints(dataPointIds);
return vo;
}
Aggregations