use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class EventSecurityTest method testAddEventSimpleUserFullAccess10.
/**
* program = DATA READ programStage = orgUnit = Accessible status = ERROR
*/
@Test
void testAddEventSimpleUserFullAccess10() {
programA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
programStageA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
manager.update(programA);
manager.update(programStageA);
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid());
ImportSummary importSummary = eventService.addEvent(event, ImportOptions.getDefaultImportOptions(), false);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(event.getEvent(), importSummary.getReference());
programA.setPublicAccess(AccessStringHelper.DATA_READ);
programStageA.setPublicAccess(AccessStringHelper.DEFAULT);
manager.update(programA);
manager.update(programStageA);
User user = createUser("user1").setOrganisationUnits(Sets.newHashSet(organisationUnitA));
injectSecurityContext(user);
assertTrue(programStageInstanceService.programStageInstanceExists(event.getEvent()));
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(event.getUid());
assertNotNull(programStageInstance);
Event eventFromPsi = eventService.getEvent(programStageInstance);
assertNotNull(eventFromPsi);
assertEquals(event.getUid(), eventFromPsi.getEvent());
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS 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());
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class MetadataSyncPostProcessorTest method testShouldSendSuccessEmailIfSyncSummaryIsOk.
@Test
void testShouldSendSuccessEmailIfSyncSummaryIsOk() {
metadataSyncSummary.setImportReport(new ImportReport());
metadataSyncSummary.getImportReport().setStatus(Status.OK);
metadataSyncSummary.setMetadataVersion(dataVersion);
MetadataRetryContext mockRetryContext = mock(MetadataRetryContext.class);
boolean status = metadataSyncPostProcessor.handleSyncNotificationsAndAbortStatus(metadataSyncSummary, mockRetryContext, dataVersion);
assertFalse(status);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class MetadataSyncPostProcessorTest method testShouldSendEmailToAdminWithProperSubjectAndBody.
@Test
void testShouldSendEmailToAdminWithProperSubjectAndBody() {
ImportReport importReport = mock(ImportReport.class);
metadataSyncSummary.setImportReport(importReport);
metadataSyncSummary.getImportReport().setStatus(Status.OK);
metadataSyncSummary.setMetadataVersion(dataVersion);
MetadataRetryContext mockRetryContext = mock(MetadataRetryContext.class);
boolean status = metadataSyncPostProcessor.handleSyncNotificationsAndAbortStatus(metadataSyncSummary, mockRetryContext, dataVersion);
assertFalse(status);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class MetadataVersionDelegateTest method testShouldReturnEmptyMetadataDifference.
@Test
void testShouldReturnEmptyMetadataDifference() {
when(metadataSystemSettingService.getRemoteInstanceUserName()).thenReturn(username);
when(metadataSystemSettingService.getRemoteInstancePassword()).thenReturn(password);
String response = "{\"name\":\"testVersion\",\"created\":\"2016-05-26T11:43:59.787+0000\",\"type\":\"BEST_EFFORT\",\"id\":\"ktwh8PHNwtB\",\"hashCode\":\"12wa32d4f2et3tyt5yu6i\"}";
MetadataVersion metadataVersion = new MetadataVersion("testVersion", VersionType.BEST_EFFORT);
metadataVersion.setHashCode("12wa32d4f2et3tyt5yu6i");
String url = "http://localhost:9080/api/metadata/version/history?baseline=testVersion";
when(metadataSystemSettingService.getMetaDataDifferenceURL("testVersion")).thenReturn(url);
AvailabilityStatus availabilityStatus = new AvailabilityStatus(true, "test_message", null);
when(synchronizationManager.isRemoteServerAvailable()).thenReturn(availabilityStatus);
DhisHttpResponse dhisHttpResponse = new DhisHttpResponse(httpResponse, response, HttpStatus.BAD_REQUEST.value());
try (MockedStatic<HttpUtils> mocked = mockStatic(HttpUtils.class)) {
mocked.when(() -> HttpUtils.httpGET(baselineUrl, true, username, password, null, VERSION_TIMEOUT, true)).thenReturn(dhisHttpResponse);
assertThrows(MetadataVersionServiceException.class, () -> target.getMetaDataDifference(metadataVersion), "Client Error. Http call failed with status code: 400 Caused by: " + dhisHttpResponse.getResponse());
}
}
Aggregations