Search in sources :

Example 6 with BulkJsonPatch

use of org.hisp.dhis.jsonpatch.BulkJsonPatch in project dhis2-core by dhis2.

the class BulkPatchManagerTest method testApplyPatchNotShareableSchema.

@Test
void testApplyPatchNotShareableSchema() throws IOException {
    final BulkJsonPatch bulkJsonPatch = loadPatch("bulk_sharing_patch_not_shareable.json", BulkJsonPatch.class);
    BulkPatchParameters patchParameters = BulkPatchParameters.builder().validators(BulkPatchValidatorFactory.SHARING).build();
    List<IdentifiableObject> patchedObjects = patchManager.applyPatch(bulkJsonPatch, patchParameters);
    assertEquals(0, patchedObjects.size());
    assertEquals(2, patchParameters.getErrorReportsCount());
    assertEquals(1, patchParameters.getErrorReportsCount(ErrorCode.E3019));
    assertEquals(1, patchParameters.getErrorReportsCount(ErrorCode.E4014));
}
Also used : BulkPatchParameters(org.hisp.dhis.jsonpatch.BulkPatchParameters) BulkJsonPatch(org.hisp.dhis.jsonpatch.BulkJsonPatch) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)6 BulkJsonPatch (org.hisp.dhis.jsonpatch.BulkJsonPatch)6 BulkPatchParameters (org.hisp.dhis.jsonpatch.BulkPatchParameters)6 DhisSpringTest (org.hisp.dhis.DhisSpringTest)5 Test (org.junit.jupiter.api.Test)5 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)1 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)1 ImportReport (org.hisp.dhis.dxf2.metadata.feedback.ImportReport)1 PatchMapping (org.springframework.web.bind.annotation.PatchMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1