Search in sources :

Example 1 with TrackedEntityTypeActions

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

the class PotentialDuplicatesMergeTests method shouldNotMergeDifferentTypeTeis.

@Test
public void shouldNotMergeDifferentTypeTeis() {
    String trackedEntityType = new TrackedEntityTypeActions().create();
    String teiA = createTei(Constants.TRACKED_ENTITY_TYPE);
    String teiB = createTei(trackedEntityType);
    String potentialDuplicate = potentialDuplicatesActions.createAndValidatePotentialDuplicate(teiA, teiB, "OPEN");
    potentialDuplicatesActions.autoMergePotentialDuplicate(potentialDuplicate).validate().statusCode(409).body("message", Matchers.containsString("Entities have different Tracked Entity Types"));
}
Also used : TrackedEntityTypeActions(org.hisp.dhis.actions.metadata.TrackedEntityTypeActions) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) PotentialDuplicatesApiTest(org.hisp.dhis.tracker.deduplication.PotentialDuplicatesApiTest)

Example 2 with TrackedEntityTypeActions

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

the class TeiValidationTests method setupData.

private void setupData() {
    TrackedEntityAttributeActions trackedEntityAttributeActions = new TrackedEntityAttributeActions();
    ProgramActions programActions = new ProgramActions();
    TrackedEntityTypeActions trackedEntityTypeActions = new TrackedEntityTypeActions();
    trackedEntityType = trackedEntityTypeActions.create();
    // create attributes
    uniqueTetAttribute = trackedEntityAttributeActions.create("TEXT", true);
    mandatoryTetAttribute = trackedEntityAttributeActions.create("TEXT");
    mandatoryProgramAttribute = trackedEntityAttributeActions.create("TEXT");
    attributeWithOptionSet = trackedEntityAttributeActions.createOptionSetAttribute("ZGkmoWb77MW");
    trackedEntityTypeActions.addAttribute(trackedEntityType, mandatoryTetAttribute, true);
    trackedEntityTypeActions.addAttribute(trackedEntityType, attributeWithOptionSet, false);
    trackedEntityTypeActions.addAttribute(trackedEntityType, uniqueTetAttribute, false);
    // create a program
    program = programActions.createTrackerProgram(trackedEntityType, Constants.ORG_UNIT_IDS).extractUid();
    programActions.addAttribute(program, mandatoryProgramAttribute, true);
}
Also used : TrackedEntityTypeActions(org.hisp.dhis.actions.metadata.TrackedEntityTypeActions) ProgramActions(org.hisp.dhis.actions.metadata.ProgramActions) TrackedEntityAttributeActions(org.hisp.dhis.actions.metadata.TrackedEntityAttributeActions)

Example 3 with TrackedEntityTypeActions

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

the class TeiUpdateTests method shouldNotUpdateImmutableProperties.

@Test
public void shouldNotUpdateImmutableProperties() throws Exception {
    // arrange
    String tei = importTei();
    String trackedEntityType = new TrackedEntityTypeActions().create();
    JsonObject body = trackerActions.getTrackedEntity(tei).getBodyAsJsonBuilder().addProperty("trackedEntity", tei).addProperty("trackedEntityType", trackedEntityType).wrapIntoArray("trackedEntities");
    // assert
    trackerActions.postAndGetJobReport(body, new QueryParamsBuilder().add("importStrategy=UPDATE")).validateErrorReport().body("errorCode", Matchers.hasItem("E1126")).body("message", Matchers.hasItem(Matchers.containsString("trackedEntityType")));
}
Also used : TrackedEntityTypeActions(org.hisp.dhis.actions.metadata.TrackedEntityTypeActions) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TrackedEntityTypeActions (org.hisp.dhis.actions.metadata.TrackedEntityTypeActions)3 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 JsonObject (com.google.gson.JsonObject)1 ProgramActions (org.hisp.dhis.actions.metadata.ProgramActions)1 TrackedEntityAttributeActions (org.hisp.dhis.actions.metadata.TrackedEntityAttributeActions)1 QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)1 TrackerNtiApiTest (org.hisp.dhis.tracker.TrackerNtiApiTest)1 PotentialDuplicatesApiTest (org.hisp.dhis.tracker.deduplication.PotentialDuplicatesApiTest)1