Search in sources :

Example 1 with MaintenanceActions

use of org.hisp.dhis.actions.MaintenanceActions in project dhis2-core by dhis2.

the class EventActions method delete.

/**
 * Hard deletes event.
 *
 * @param eventId
 * @return
 */
@Override
public ApiResponse delete(String eventId) {
    ApiResponse response = super.delete(eventId);
    new MaintenanceActions().removeSoftDeletedEvents();
    return response;
}
Also used : MaintenanceActions(org.hisp.dhis.actions.MaintenanceActions) ApiResponse(org.hisp.dhis.dto.ApiResponse)

Example 2 with MaintenanceActions

use of org.hisp.dhis.actions.MaintenanceActions in project dhis2-core by dhis2.

the class TestCleanUp method deleteCreatedEntities.

/**
 * Deletes entities created during test run. Entities deleted one by one
 * starting from last created one.
 */
public void deleteCreatedEntities() {
    Map<String, String> createdEntities = TestRunStorage.getCreatedEntities();
    List<String> reverseOrderedKeys = new ArrayList<>(createdEntities.keySet());
    Collections.reverse(reverseOrderedKeys);
    Iterator<String> iterator = reverseOrderedKeys.iterator();
    while (iterator.hasNext()) {
        String key = iterator.next();
        boolean deleted = deleteEntity(createdEntities.get(key), key);
        if (deleted) {
            TestRunStorage.removeEntity(createdEntities.get(key), key);
            createdEntities.remove(createdEntities.get(key), key);
        }
        new MaintenanceActions().removeSoftDeletedData();
    }
    while (deleteCount < 2 && !createdEntities.isEmpty()) {
        deleteCount++;
        deleteCreatedEntities();
    }
    TestRunStorage.removeAllEntities();
}
Also used : MaintenanceActions(org.hisp.dhis.actions.MaintenanceActions)

Example 3 with MaintenanceActions

use of org.hisp.dhis.actions.MaintenanceActions in project dhis2-core by dhis2.

the class TrackerNtiApiTest method afterEachNTI.

@AfterEach
public void afterEachNTI() {
    loginActions.loginAsSuperUser();
    new MaintenanceActions().removeSoftDeletedData();
}
Also used : MaintenanceActions(org.hisp.dhis.actions.MaintenanceActions) AfterEach(org.junit.jupiter.api.AfterEach)

Aggregations

MaintenanceActions (org.hisp.dhis.actions.MaintenanceActions)3 ApiResponse (org.hisp.dhis.dto.ApiResponse)1 AfterEach (org.junit.jupiter.api.AfterEach)1