Search in sources :

Example 6 with UserGroupAccess

use of org.hisp.dhis.user.UserGroupAccess in project dhis2-core by dhis2.

the class MetadataExportServiceTest method testSkipSharing.

// @Test
// TODO Fix this
public void testSkipSharing() {
    MetadataExportParams params = new MetadataExportParams();
    params.setSkipSharing(true);
    params.setClasses(Sets.newHashSet(DataElement.class));
    User user = createUser('A');
    UserGroup group = createUserGroup('A', Sets.newHashSet(user));
    DataElement de1 = createDataElement('A');
    DataElement de2 = createDataElement('B');
    DataElement de3 = createDataElement('C');
    DataElement de4 = createDataElement('D');
    DataElement de5 = createDataElement('E');
    de1.setUserAccesses(Sets.newHashSet(new UserAccess(user, "rwrwrwrw")));
    de2.setPublicAccess("rwrwrwrw");
    de3.setCreatedBy(user);
    de4.setUserGroupAccesses(Sets.newHashSet(new UserGroupAccess(group, "rwrwrwrw")));
    de5.setExternalAccess(true);
    manager.save(user);
    manager.save(group);
    manager.save(de1);
    manager.save(de2);
    manager.save(de3);
    manager.save(de4);
    manager.save(de5);
    Map<Class<? extends IdentifiableObject>, List<? extends IdentifiableObject>> metadata = metadataExportService.getMetadata(params);
    assertEquals(5, metadata.get(DataElement.class).size());
    metadata.get(DataElement.class).stream().forEach(element -> checkSharingFields(element));
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) User(org.hisp.dhis.user.User) UserAccess(org.hisp.dhis.user.UserAccess) List(java.util.List) UserGroup(org.hisp.dhis.user.UserGroup) UserGroupAccess(org.hisp.dhis.user.UserGroupAccess) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject)

Aggregations

UserGroupAccess (org.hisp.dhis.user.UserGroupAccess)6 User (org.hisp.dhis.user.User)5 UserAccess (org.hisp.dhis.user.UserAccess)4 UserGroup (org.hisp.dhis.user.UserGroup)4 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)3 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)3 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)2 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2 Program (org.hisp.dhis.program.Program)2 Sharing (org.hisp.dhis.webapi.webdomain.sharing.Sharing)2 SharingUserAccess (org.hisp.dhis.webapi.webdomain.sharing.SharingUserAccess)2 SharingUserGroupAccess (org.hisp.dhis.webapi.webdomain.sharing.SharingUserGroupAccess)2 Test (org.junit.jupiter.api.Test)2 AccessDeniedException (org.springframework.security.access.AccessDeniedException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Collection (java.util.Collection)1 List (java.util.List)1 AttributeValue (org.hisp.dhis.attribute.AttributeValue)1 EmbeddedObject (org.hisp.dhis.common.EmbeddedObject)1 DataElement (org.hisp.dhis.dataelement.DataElement)1