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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations