use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class SharingTest method setDtoUserAccessesClearsExisting.
@Test
void setDtoUserAccessesClearsExisting() {
Sharing actual = new Sharing();
User user1 = new User();
user1.setUid("id");
actual.setDtoUserAccesses(singleton(new org.hisp.dhis.user.UserAccess(user1, "rw------")));
User user2 = new User();
user2.setUid("uid");
actual.setDtoUserAccesses(singleton(new org.hisp.dhis.user.UserAccess(user2, "r-------")));
assertEquals(1, actual.getUsers().size());
UserAccess userAccess = actual.getUsers().values().iterator().next();
assertEquals("r-------", userAccess.getAccess());
assertEquals("uid", userAccess.getId());
}
use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class SharingTest method addUserAccessIgnoresNull.
@Test
void addUserAccessIgnoresNull() {
Sharing actual = new Sharing();
actual.setUserAccesses(singleton(new UserAccess("rw------", "uid")));
actual.addUserAccess(null);
assertEquals(1, actual.getUsers().size());
}
use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class SharingTest method withAccessAppliesToPublic.
@Test
void withAccessAppliesToPublic() {
Sharing original = new Sharing();
original.setPublicAccess("abcd1234");
assertEquals("abab1234", original.withAccess(Sharing::copyMetadataToData).getPublicAccess());
}
use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class SharingTest method setUserAccessesClearsExisting.
@Test
void setUserAccessesClearsExisting() {
Sharing actual = new Sharing();
actual.setUserAccesses(singleton(new UserAccess("rw------", "id")));
actual.setUserAccesses(singleton(new UserAccess("r-------", "uid")));
assertEquals(1, actual.getUsers().size());
UserAccess userAccess = actual.getUsers().values().iterator().next();
assertEquals("r-------", userAccess.getAccess());
assertEquals("uid", userAccess.getId());
}
use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class SharingTest method withAccessAppliesToUserGroups.
@Test
void withAccessAppliesToUserGroups() {
Sharing original = new Sharing();
original.setUserGroups(singletonMap("key", new UserGroupAccess("abcd1234", "uid")));
Sharing actual = original.withAccess(Sharing::copyMetadataToData);
Map<String, UserGroupAccess> groups = actual.getUserGroups();
assertEquals(1, groups.size());
assertEquals("key", groups.keySet().iterator().next());
assertEquals("abab1234", groups.values().iterator().next().getAccess());
assertEquals("uid", groups.values().iterator().next().getId());
}
Aggregations