Search in sources :

Example 1 with RelationshipActions

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

the class RelationshipsTest method before.

@BeforeAll
public void before() throws Exception {
    relationshipActions = new RelationshipActions();
    trackedEntityInstanceActions = new RestApiActions("/trackedEntityInstances");
    metadataActions = new MetadataActions();
    eventActions = new EventActions();
    new LoginActions().loginAsSuperUser();
    metadataActions.importAndValidateMetadata(new File("src/test/resources/tracker/relationshipTypes.json"));
    JsonObject teiObject = new FileReaderUtils().read(new File("src/test/resources/tracker/teis/teis.json")).replacePropertyValuesWithIds("trackedEntityInstance").get(JsonObject.class);
    teis = trackedEntityInstanceActions.post(teiObject).extractUids();
    JsonObject eventObject = new FileReaderUtils().read(new File("src/test/resources/tracker/events/events.json")).replacePropertyValuesWithIds("event").get(JsonObject.class);
    ApiResponse response = eventActions.post(eventObject).validateStatus(200);
    events = response.extractUids();
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) FileReaderUtils(org.hisp.dhis.helpers.file.FileReaderUtils) JsonObject(com.google.gson.JsonObject) MetadataActions(org.hisp.dhis.actions.metadata.MetadataActions) LoginActions(org.hisp.dhis.actions.LoginActions) RelationshipActions(org.hisp.dhis.actions.tracker.RelationshipActions) EventActions(org.hisp.dhis.actions.tracker.EventActions) File(java.io.File) ApiResponse(org.hisp.dhis.dto.ApiResponse) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with RelationshipActions

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

the class PotentialDuplicatesRelationshipTests method shouldRemoveDuplicateRelationshipWhenAutoMerging.

@Test
public void shouldRemoveDuplicateRelationshipWhenAutoMerging() {
    String teiA = createTei();
    String teiB = createTei();
    String relationship = createRelationship(teiA, teiB).extractImportedRelationships().get(0);
    String potentialDuplicate = potentialDuplicatesActions.createAndValidatePotentialDuplicate(teiA, teiB, "OPEN");
    potentialDuplicatesActions.autoMergePotentialDuplicate(potentialDuplicate).validate().statusCode(200);
    trackerActions.getTrackedEntity(teiA + "?fields=*").validate().statusCode(200).body("relationships", hasSize(0));
    new RelationshipActions().get(relationship).validateStatus(404);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RelationshipActions(org.hisp.dhis.actions.tracker.RelationshipActions) PotentialDuplicatesApiTest(org.hisp.dhis.tracker.deduplication.PotentialDuplicatesApiTest) Test(org.junit.jupiter.api.Test)

Aggregations

RelationshipActions (org.hisp.dhis.actions.tracker.RelationshipActions)2 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 LoginActions (org.hisp.dhis.actions.LoginActions)1 RestApiActions (org.hisp.dhis.actions.RestApiActions)1 MetadataActions (org.hisp.dhis.actions.metadata.MetadataActions)1 EventActions (org.hisp.dhis.actions.tracker.EventActions)1 ApiResponse (org.hisp.dhis.dto.ApiResponse)1 FileReaderUtils (org.hisp.dhis.helpers.file.FileReaderUtils)1 PotentialDuplicatesApiTest (org.hisp.dhis.tracker.deduplication.PotentialDuplicatesApiTest)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 Test (org.junit.jupiter.api.Test)1