Search in sources :

Example 21 with SUCCESS

use of org.hisp.dhis.dxf2.importsummary.ImportStatus.SUCCESS in project dhis2-core by dhis2.

the class DataValueSetServiceTest method testImportValueCatComboOk.

/**
 * User has data write access for DataSet and also categoryOptions Expect
 * success
 *
 * @throws IOException
 */
@Test
void testImportValueCatComboOk() throws IOException {
    enableDataSharing(user, dsA, AccessStringHelper.DATA_READ_WRITE);
    enableDataSharing(user, categoryOptionA, AccessStringHelper.DATA_WRITE);
    enableDataSharing(user, categoryOptionB, AccessStringHelper.DATA_WRITE);
    in = new ClassPathResource("datavalueset/dataValueSetACatCombo.xml").getInputStream();
    ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
    assertNotNull(summary);
    assertNotNull(summary.getImportCount());
    assertEquals(ImportStatus.SUCCESS, summary.getStatus());
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) ClassPathResource(org.springframework.core.io.ClassPathResource) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 22 with SUCCESS

use of org.hisp.dhis.dxf2.importsummary.ImportStatus.SUCCESS in project dhis2-core by dhis2.

the class DataValueSetServiceTest method testImportValueDefaultCatComboOk.

/**
 * User has data write access for DataSet DataValue use default category
 * combo Expect success
 *
 * @throws IOException
 */
@Test
void testImportValueDefaultCatComboOk() throws IOException {
    clearSecurityContext();
    enableDataSharing(user, dsA, AccessStringHelper.DATA_READ_WRITE);
    dataSetService.updateDataSet(dsA);
    in = new ClassPathResource("datavalueset/dataValueSetA.xml").getInputStream();
    ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
    assertNotNull(summary);
    assertNotNull(summary.getImportCount());
    assertEquals(ImportStatus.SUCCESS, summary.getStatus());
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) ClassPathResource(org.springframework.core.io.ClassPathResource) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 23 with SUCCESS

use of org.hisp.dhis.dxf2.importsummary.ImportStatus.SUCCESS in project dhis2-core by dhis2.

the class EnrollmentSecurityTest method testGetEnrollmentsInSearchScopeForUser.

/**
 * program = DATA READ orgUnit = Accessible in search scope status = SUCCESS
 */
@Test
void testGetEnrollmentsInSearchScopeForUser() {
    ImportSummary importSummary = enrollmentService.addEnrollment(createEnrollment(programA.getUid(), maleA.getUid()), ImportOptions.getDefaultImportOptions());
    assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
    programA.getSharing().setPublicAccess(AccessStringHelper.DATA_READ);
    manager.update(programA);
    User user = createUser("user1");
    user.setOrganisationUnits(Sets.newHashSet(organisationUnitB));
    user.setTeiSearchOrganisationUnits(Sets.newHashSet(organisationUnitA, organisationUnitB));
    user.setDataViewOrganisationUnits(Sets.newHashSet(organisationUnitB));
    injectSecurityContext(user);
    ProgramInstanceQueryParams params = new ProgramInstanceQueryParams();
    params.setProgram(programA);
    params.setOrganisationUnitMode(OrganisationUnitSelectionMode.ACCESSIBLE);
    params.setUser(user);
    Enrollments enrollments = enrollmentService.getEnrollments(params);
    assertNotNull(enrollments);
    assertNotNull(enrollments.getEnrollments());
    assertEquals(1, enrollments.getEnrollments().size());
    assertEquals(importSummary.getReference(), enrollments.getEnrollments().get(0).getEnrollment());
}
Also used : User(org.hisp.dhis.user.User) Enrollments(org.hisp.dhis.dxf2.events.enrollment.Enrollments) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) ProgramInstanceQueryParams(org.hisp.dhis.program.ProgramInstanceQueryParams) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 24 with SUCCESS

use of org.hisp.dhis.dxf2.importsummary.ImportStatus.SUCCESS in project dhis2-core by dhis2.

the class EnrollmentSecurityTest method testGetEnrollmentUserWithDataReadWrite.

/**
 * program = DATA READ/WRITE orgUnit = Accessible status = SUCCESS
 */
@Test
void testGetEnrollmentUserWithDataReadWrite() {
    ImportSummary importSummary = enrollmentService.addEnrollment(createEnrollment(programA.getUid(), maleA.getUid()), ImportOptions.getDefaultImportOptions());
    assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
    programA.getSharing().setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
    manager.updateNoAcl(programA);
    User user = createUser("user1").setOrganisationUnits(Sets.newHashSet(organisationUnitA));
    injectSecurityContext(user);
    Enrollment enrollment = enrollmentService.getEnrollment(importSummary.getReference());
    assertNotNull(enrollment);
    assertEquals(enrollment.getEnrollment(), importSummary.getReference());
}
Also used : User(org.hisp.dhis.user.User) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) Enrollment(org.hisp.dhis.dxf2.events.enrollment.Enrollment) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 25 with SUCCESS

use of org.hisp.dhis.dxf2.importsummary.ImportStatus.SUCCESS in project dhis2-core by dhis2.

the class EventSecurityTest method testAddEventSimpleUserFullAccess1.

/**
 * program = DATA READ/WRITE programStage = DATA READ/WRITE orgUnit =
 * Accessible status = SUCCESS
 */
@Test
void testAddEventSimpleUserFullAccess1() {
    programA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
    programStageA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
    manager.updateNoAcl(programA);
    manager.updateNoAcl(programStageA);
    User user = createUser("user1").setOrganisationUnits(Sets.newHashSet(organisationUnitA));
    userService.addUser(user);
    injectSecurityContext(user);
    Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid());
    // make sure data is flushed, so event service can access it
    manager.flush();
    ImportSummary importSummary = eventService.addEvent(event, ImportOptions.getDefaultImportOptions(), false);
    assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
}
Also used : User(org.hisp.dhis.user.User) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) Event(org.hisp.dhis.dxf2.events.event.Event) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)20 User (org.hisp.dhis.user.User)10 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)9 Test (org.junit.jupiter.api.Test)9 Event (org.hisp.dhis.dxf2.events.event.Event)6 Date (java.util.Date)4 Program (org.hisp.dhis.program.Program)4 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 DataValueService (org.hisp.dhis.datavalue.DataValueService)3 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)3 Enrollment (org.hisp.dhis.dxf2.events.enrollment.Enrollment)3 Events (org.hisp.dhis.dxf2.events.event.Events)3 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)3 IOException (java.io.IOException)2 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)2 IdScheme (org.hisp.dhis.common.IdScheme)2 IdSchemes (org.hisp.dhis.common.IdSchemes)2 ImportSummariesResponseExtractor (org.hisp.dhis.dxf2.common.ImportSummariesResponseExtractor)2 DataValueSetService (org.hisp.dhis.dxf2.datavalueset.DataValueSetService)2