use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-core-public by infiniteautomation.
the class EventInstanceServiceTest method testQueryReadPermissionEnforcement.
@Override
@Test
public void testQueryReadPermissionEnforcement() {
EventInstanceVO vo = newVO(editUser);
setReadPermission(MangoPermission.requireAnyRole(editRole), vo);
EventInstanceVO saved = service.insert(vo);
runAs.runAs(readUser, () -> {
ConditionSortLimit conditions = new ConditionSortLimit(null, null, 1, 0);
AtomicInteger count = new AtomicInteger();
getService().customizedQuery(conditions, (item) -> {
count.getAndIncrement();
});
assertEquals(0, count.get());
});
runAs.runAs(editUser, () -> {
Condition c = getDao().getIdField().eq(saved.getId());
ConditionSortLimit conditions = new ConditionSortLimit(c, null, null, null);
AtomicInteger count = new AtomicInteger();
getService().customizedQuery(conditions, (item) -> {
count.getAndIncrement();
assertEquals(saved.getId(), item.getId());
});
assertEquals(1, count.get());
});
}
use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-core-public by infiniteautomation.
the class AbstractBasicVOServiceWithPermissionsTestBase method testQueryEditPermissionEnforcement.
@Test
public void testQueryEditPermissionEnforcement() {
VO vo = newVO(readUser);
setEditPermission(MangoPermission.requireAnyRole(editRole), vo);
VO saved = service.insert(vo);
runAs.runAs(readUser, () -> {
ConditionSortLimit conditions = new ConditionSortLimit(null, null, 1, 0);
AtomicInteger count = new AtomicInteger();
getService().customizedQuery(conditions, (item) -> {
count.getAndIncrement();
});
assertEquals(0, count.get());
});
}
use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-core-public by infiniteautomation.
the class AbstractBasicVOServiceWithPermissionsTestBase method testQueryReadPermissionEnforcement.
@Test
public void testQueryReadPermissionEnforcement() {
VO vo = newVO(editUser);
setReadPermission(MangoPermission.requireAnyRole(editRole), vo);
VO saved = service.insert(vo);
runAs.runAs(readUser, () -> {
ConditionSortLimit conditions = new ConditionSortLimit(null, null, 1, 0);
AtomicInteger count = new AtomicInteger();
getService().customizedQuery(conditions, (item) -> {
count.getAndIncrement();
});
assertEquals(0, count.get());
});
runAs.runAs(editUser, () -> {
Condition c = getDao().getIdField().eq(saved.getId());
ConditionSortLimit conditions = new ConditionSortLimit(c, null, null, null);
AtomicInteger count = new AtomicInteger();
getService().customizedQuery(conditions, (item) -> {
count.getAndIncrement();
assertEquals(saved.getId(), item.getId());
});
assertEquals(1, count.get());
});
}
use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-core-public by infiniteautomation.
the class AbstractBasicVOServiceWithPermissionsTestBase method testCountQueryEditPermissionEnforcement.
@Test
public void testCountQueryEditPermissionEnforcement() {
VO vo = newVO(readUser);
setEditPermission(MangoPermission.requireAnyRole(editRole), vo);
service.insert(vo);
runAs.runAs(readUser, () -> {
ConditionSortLimit conditions = new ConditionSortLimit(null, null, null, 0);
int count = getService().customizedCount(conditions);
assertEquals(0, count);
});
}
use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-core-public by infiniteautomation.
the class AbstractVOServiceWithPermissionsTest method queryForName.
public int queryForName(String name) {
Condition c = getDao().getNameField().eq(name);
ConditionSortLimit conditions = new ConditionSortLimit(c, null, null, 0);
AtomicInteger count = new AtomicInteger();
getService().customizedQuery(conditions, (item) -> {
count.getAndIncrement();
assertEquals(name, item.getName());
});
return count.get();
}
Aggregations