Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add not-null constraint for column trackedentitytypeid in trackedentity table [DHIS2-15066] #19112

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4627513
feat: Add not-null constraint for column trackedentitytypeid in track…
zubaira Nov 9, 2024
adf3d6a
Merge branch 'master' into DHIS2-15066
zubaira Nov 15, 2024
962dae2
fix test
zubaira Nov 15, 2024
972f8d5
fix unit test
zubaira Nov 16, 2024
e642c35
fix unit test
zubaira Nov 16, 2024
290ad52
fix unit test
zubaira Nov 16, 2024
bee4104
remove unused dependency
zubaira Nov 16, 2024
900f3d7
fix integration test
zubaira Nov 16, 2024
62ef7d6
fix controller tests
zubaira Nov 16, 2024
ea2402b
fix tests
zubaira Nov 16, 2024
81daef6
Merge branch 'master' into DHIS2-15066
zubaira Nov 21, 2024
4f26b27
update flyway to cover existin not null rows
zubaira Nov 21, 2024
adc0326
update flyway
zubaira Nov 21, 2024
4ac4a44
update flyway migration
zubaira Dec 4, 2024
13024a3
minor
zubaira Dec 4, 2024
2baca3a
minor
zubaira Dec 4, 2024
38edde3
Merge branch 'master' into DHIS2-15066
zubaira Dec 4, 2024
b0797bc
expcetion message
zubaira Dec 5, 2024
e62c46b
correction in markdown
zubaira Dec 5, 2024
72868f4
Find inconstent trackedentities, fix them and set trackentitytypeid n…
zubaira Dec 5, 2024
746ec8b
update
zubaira Dec 5, 2024
1484545
add exception
zubaira Dec 5, 2024
c3359ce
add exception
zubaira Dec 5, 2024
b265862
Merge branch 'master' into DHIS2-15066
zubaira Dec 5, 2024
d885171
code reviews
zubaira Dec 6, 2024
964ed52
code review
zubaira Dec 6, 2024
91189c9
minor
zubaira Dec 6, 2024
6dcdf05
fix unit test
zubaira Dec 6, 2024
f2adebf
set operation instead of looping through the records
zubaira Dec 6, 2024
cdb5bf8
Merge branch 'master' into DHIS2-15066
zubaira Dec 6, 2024
659a986
Merge branch 'master' into DHIS2-15066
zubaira Dec 11, 2024
cfea998
update flyway
zubaira Dec 11, 2024
2682751
Merge branch 'master' into DHIS2-15066
zubaira Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
foreign-key="fk_trackedentityinstance_organisationunitid" not-null="true" lazy="false"/>

<many-to-one name="trackedEntityType" class="org.hisp.dhis.trackedentity.TrackedEntityType"
column="trackedentitytypeid" foreign-key="fk_trackedentityinstance_trackedentitytypeid" lazy="false"/>
column="trackedentitytypeid" foreign-key="fk_trackedentityinstance_trackedentitytypeid" lazy="false" not-null="true"/>
</class>

<sql-query name="updateTrackedEntitiesLastUpdated">update trackedentity set lastUpdated = :lastUpdated, lastupdatedbyuserinfo = CAST(:lastupdatedbyuserinfo as jsonb) WHERE uid in :trackedEntities</sql-query>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import org.hisp.dhis.programrule.ProgramRuleVariableService;
import org.hisp.dhis.security.acl.AclService;
import org.hisp.dhis.test.TestBase;
import org.hisp.dhis.trackedentity.TrackedEntityType;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserDetails;
import org.hisp.dhis.user.sharing.Sharing;
Expand Down Expand Up @@ -132,8 +133,11 @@ void setup() {
void testCopyProgramFromUidWithValidProgram() throws NotFoundException, ForbiddenException {

OrganisationUnit orgUnit = createOrganisationUnit("New Org 1");
TrackedEntityType trackedEntityType = createTrackedEntityType('E');

List<Enrollment> originalEnrollments =
List.of(createEnrollment(original, createTrackedEntity(orgUnit), orgUnit));
List.of(
createEnrollment(original, createTrackedEntity(orgUnit, trackedEntityType), orgUnit));
when(programService.getProgram(VALID_PROGRAM_UID)).thenReturn(original);

when(aclService.canWrite(UserDetails.fromUser(user), original)).thenReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,14 @@ private List<Enrollment> getEnrollments() {
}

private TrackedEntity getTrackedEntityA() {
TrackedEntity te = createTrackedEntity(organisationUnitA);
TrackedEntity te = createTrackedEntity(organisationUnitA, createTrackedEntityType('I'));
te.setTrackedEntityType(trackedEntityTypeA);
zubaira marked this conversation as resolved.
Show resolved Hide resolved

return te;
}

private TrackedEntity getTrackedEntityB() {
TrackedEntity te = createTrackedEntity(organisationUnitB);
TrackedEntity te = createTrackedEntity(organisationUnitB, createTrackedEntityType('F'));
te.setTrackedEntityType(trackedEntityTypeB);
zubaira marked this conversation as resolved.
Show resolved Hide resolved

return te;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void setUp() {
Program program = createProgram('A');
ProgramStage programStage = createProgramStage('A', program);

trackedEntity = createTrackedEntity(organisationUnit);
trackedEntity = createTrackedEntity(organisationUnit, createTrackedEntityType('P'));
trackedEntity.setUid(TE_UID.getValue());
enrollment = createEnrollment(program, trackedEntity, organisationUnit);
enrollment.setUid(EN_UID.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public void setUp() {

OrganisationUnit organisationUnit = createOrganisationUnit('A');

teA = createTrackedEntity(organisationUnit);
teA = createTrackedEntity(organisationUnit, createTrackedEntityType('D'));
teA.setUid(TE_A_UID.getValue());
teB = createTrackedEntity(organisationUnit);
teB = createTrackedEntity(organisationUnit, createTrackedEntityType('E'));
teB.setUid(TE_B_UID.getValue());
teC = createTrackedEntity(organisationUnit);
teC = createTrackedEntity(organisationUnit, createTrackedEntityType('F'));
teC.setUid(TE_C_UID.getValue());

relationshipA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void setUp() {
OrganisationUnit orgUnit = createOrganisationUnit('A');
Program program = createProgram('A');
Attribute attribute = createAttribute('A');
trackedEntity = createTrackedEntity('A', orgUnit);
trackedEntity = createTrackedEntity('A', orgUnit, createTrackedEntityType('U'));
trackedEntity.setUid(TE_UID.getValue());
trackedEntity.setAttributeValues(AttributeValues.of(Map.of(attribute.getUid(), UNIQUE_VALUE)));
enrollment = createEnrollment(program, trackedEntity, orgUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ private Attribute attribute(TrackedEntityAttribute trackedEntityAttribute, Strin
}

private TrackedEntity trackedEntity() {
return createTrackedEntity('I', organisationUnit, trackedEntityAttribute);
return createTrackedEntity(
'I', organisationUnit, trackedEntityAttribute, createTrackedEntityType('W'));
}

private org.hisp.dhis.tracker.imports.domain.Enrollment payloadEnrollment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private TrackedEntityType trackedEntityType(String uid, char uniqueChar) {
}

private TrackedEntity trackedEntity(UID uid, TrackedEntityType type, OrganisationUnit orgUnit) {
TrackedEntity te = createTrackedEntity(orgUnit);
TrackedEntity te = createTrackedEntity(orgUnit, createTrackedEntityType('R'));
te.setUid(uid.getValue());
te.setTrackedEntityType(type);
zubaira marked this conversation as resolved.
Show resolved Hide resolved
return te;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ void verifyValidationFailsForEnrollmentDeletionAndUserWithoutTrackedEntityTypeRe
}

private TrackedEntity teWithNoEnrollments() {
TrackedEntity trackedEntity = createTrackedEntity(organisationUnit);
TrackedEntity trackedEntity =
createTrackedEntity(organisationUnit, createTrackedEntityType('C'));
trackedEntity.setUid(TE_ID.getValue());
trackedEntity.setEnrollments(Sets.newHashSet());
trackedEntity.setTrackedEntityType(trackedEntityType);
zubaira marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ void verifySuccessEventValidationWhenEventHasNoOrgUnitAssigned() {
}

private TrackedEntity teWithNoEnrollments() {
TrackedEntity trackedEntity = createTrackedEntity(organisationUnit);
TrackedEntity trackedEntity =
createTrackedEntity(organisationUnit, createTrackedEntityType('E'));
trackedEntity.setUid(TE_ID.getValue());
trackedEntity.setEnrollments(Sets.newHashSet());
trackedEntity.setTrackedEntityType(trackedEntityType);
zubaira marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ void shouldFailWhenUpdateTEAndUserHasNoWriteAccess() {
}

private TrackedEntity teWithNoEnrollments() {
TrackedEntity trackedEntity = createTrackedEntity(organisationUnit);
TrackedEntity trackedEntity =
createTrackedEntity(organisationUnit, createTrackedEntityType('Z'));
trackedEntity.setUid(TE_ID.getValue());
trackedEntity.setEnrollments(Sets.newHashSet());
trackedEntity.setTrackedEntityType(trackedEntityType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTrackedEntityType

Expand All @@ -311,7 +312,8 @@ private TrackedEntity teWithDeleteEnrollments() {
Enrollment enrollment = new Enrollment();
enrollment.setDeleted(true);

TrackedEntity trackedEntity = createTrackedEntity(organisationUnit);
TrackedEntity trackedEntity =
createTrackedEntity(organisationUnit, createTrackedEntityType('B'));
trackedEntity.setUid(TE_ID.getValue());
trackedEntity.setEnrollments(Sets.newHashSet(enrollment));
trackedEntity.setTrackedEntityType(trackedEntityType);
zubaira marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -320,7 +322,8 @@ private TrackedEntity teWithDeleteEnrollments() {
}

private TrackedEntity teWithEnrollments() {
TrackedEntity trackedEntity = createTrackedEntity(organisationUnit);
TrackedEntity trackedEntity =
createTrackedEntity(organisationUnit, createTrackedEntityType('R'));
trackedEntity.setUid(TE_ID.getValue());
trackedEntity.setEnrollments(Sets.newHashSet(new Enrollment()));
trackedEntity.setTrackedEntityType(trackedEntityType);
zubaira marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DO $$
DECLARE
dummy_tet_id INT;
dummy_tet_uid VARCHAR(11);
BEGIN
-- If there are NULL values in trackedentitytypeid, proceed with the update and NOT NULL constraint
IF EXISTS (SELECT 1 FROM trackedentity WHERE trackedentitytypeid IS NULL) THEN
-- Step 2: Generate a dummy ID for trackedentitytype
SELECT COALESCE(MAX(trackedentitytypeid), 0) + 1 INTO dummy_tet_id FROM trackedentitytype;

-- Generate a unique UID for the dummy entry
LOOP
SELECT generate_uid() INTO dummy_tet_uid;
-- Ensure the UID is unique in trackedentitytype
EXIT WHEN NOT EXISTS (SELECT 1 FROM trackedentitytype WHERE uid = dummy_tet_uid);
END LOOP;

-- Step 3: Insert dummy TrackedEntityType using generated ID and UID
INSERT INTO trackedentitytype(
trackedentitytypeid, uid, code, created, lastupdated, name, description, formname, style)
VALUES (dummy_tet_id, dummy_tet_uid, 'dummy_tet', now(), now(), 'dummy_tet', 'Placeholder for NULL values', 'dummy_tet', '{}'::jsonb);

-- Step 4: Update rows with NULL values in trackedentitytypeid
UPDATE trackedentity
SET trackedentitytypeid = dummy_tet_id
WHERE trackedentitytypeid IS NULL;

-- Step 5: Add NOT NULL constraint to trackedentitytypeid
ALTER TABLE trackedentity ALTER COLUMN trackedentitytypeid SET NOT NULL;
END IF;
END $$;
Original file line number Diff line number Diff line change
Expand Up @@ -2141,29 +2141,36 @@ public static TrackedEntityType createTrackedEntityType(char uniqueChar) {
return trackedEntityType;
}

public static TrackedEntity createTrackedEntity(OrganisationUnit organisationUnit) {
public static TrackedEntity createTrackedEntity(
OrganisationUnit organisationUnit, TrackedEntityType trackedEntityType) {
TrackedEntity trackedEntity = new TrackedEntity();
trackedEntity.setAutoFields();
trackedEntity.setOrganisationUnit(organisationUnit);
trackedEntity.setTrackedEntityType(trackedEntityType);

return trackedEntity;
}

public static TrackedEntity createTrackedEntity(
char uniqueChar, OrganisationUnit organisationUnit) {
char uniqueChar, OrganisationUnit organisationUnit, TrackedEntityType trackedEntityType) {
TrackedEntity trackedEntity = new TrackedEntity();
trackedEntity.setAutoFields();
trackedEntity.setOrganisationUnit(organisationUnit);
trackedEntity.setUid(BASE_TE_UID + uniqueChar);
trackedEntity.setTrackedEntityType(trackedEntityType);

return trackedEntity;
}

public static TrackedEntity createTrackedEntity(
char uniqueChar, OrganisationUnit organisationUnit, TrackedEntityAttribute attribute) {
char uniqueChar,
OrganisationUnit organisationUnit,
TrackedEntityAttribute attribute,
TrackedEntityType trackedEntityType) {
TrackedEntity trackedEntity = new TrackedEntity();
trackedEntity.setAutoFields();
trackedEntity.setOrganisationUnit(organisationUnit);
trackedEntity.setTrackedEntityType(trackedEntityType);

TrackedEntityAttributeValue attributeValue = new TrackedEntityAttributeValue();
attributeValue.setAttribute(attribute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,8 @@ void setUp() throws ConflictException {
manager.save(trackedEntityType);

// Tracked Entity Instances (Registrations)
TrackedEntity teiA = createTrackedEntity(ouD);
TrackedEntity teiA = createTrackedEntity(ouD, trackedEntityType);
teiA.setUid("trackEntInA");
teiA.setTrackedEntityType(trackedEntityType);
manager.save(teiA);

// Tracked Entity Attribute Values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.hisp.dhis.test.integration.PostgresIntegrationTestBase;
import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityType;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
import org.hisp.dhis.tracker.trackedentityattributevalue.TrackedEntityAttributeValueService;
import org.junit.jupiter.api.Disabled;
Expand Down Expand Up @@ -108,7 +109,10 @@ void testSaveTrackedEntity() {
TrackedEntityAttribute attribute = createTrackedEntityAttribute('A');
manager.save(ou);
manager.save(attribute);
TrackedEntity trackedEntity = createTrackedEntity('A', ou, attribute);

TrackedEntityType trackedEntityType = createTrackedEntityType('O');
manager.save(trackedEntityType);
TrackedEntity trackedEntity = createTrackedEntity('A', ou, attribute, trackedEntityType);
manager.save(trackedEntity);
AuditQuery query = AuditQuery.builder().uid(Sets.newHashSet(trackedEntity.getUid())).build();
await().atMost(TIMEOUT, TimeUnit.SECONDS).until(() -> auditService.countAudits(query) >= 0);
Expand All @@ -127,7 +131,11 @@ void testSaveTrackedAttributeValue() {
TrackedEntityAttribute attribute = createTrackedEntityAttribute('A');
manager.save(ou);
manager.save(attribute);
TrackedEntity trackedEntity = createTrackedEntity('A', ou, attribute);

TrackedEntityType trackedEntityType = createTrackedEntityType('O');
manager.save(trackedEntityType);

TrackedEntity trackedEntity = createTrackedEntity('A', ou, attribute, trackedEntityType);
manager.save(trackedEntity);
TrackedEntityAttributeValue dataValue =
createTrackedEntityAttributeValue('A', trackedEntity, attribute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.hisp.dhis.test.integration.PostgresIntegrationTestBase;
import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityType;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -70,7 +71,9 @@ class HardDeleteAuditTest extends PostgresIntegrationTestBase {
void testHardDeleteTrackedEntity() {
OrganisationUnit ou = createOrganisationUnit('A');
TrackedEntityAttribute attribute = createTrackedEntityAttribute('A');
TrackedEntity trackedEntity = createTrackedEntity('A', ou, attribute);
TrackedEntityType trackedEntityType = createTrackedEntityType('O');
manager.save(trackedEntityType);
TrackedEntity trackedEntity = createTrackedEntity('A', ou, attribute, trackedEntityType);
transactionTemplate.execute(
status -> {
manager.save(ou);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,11 @@ void setUp() {
programService.updateProgram(program);
TrackedEntityType trackedEntityType = createTrackedEntityType('A');
trackedEntityTypeService.addTrackedEntityType(trackedEntityType);
trackedEntity = createTrackedEntity(organisationUnit);
trackedEntity.setTrackedEntityType(trackedEntityType);
trackedEntity = createTrackedEntity(organisationUnit, trackedEntityType);
manager.save(trackedEntity);
trackedEntityB = createTrackedEntity(organisationUnit);
trackedEntityB.setTrackedEntityType(trackedEntityType);
trackedEntityB = createTrackedEntity(organisationUnit, trackedEntityType);
manager.save(trackedEntityB);
trackedEntityWithAssociations = createTrackedEntity('T', organisationUnit);
trackedEntityWithAssociations = createTrackedEntity('T', organisationUnit, trackedEntityType);
DateTime testDate1 = DateTime.now();
testDate1.withTimeAtStartOfDay();
testDate1 = testDate1.minusDays(70);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
import org.hisp.dhis.test.integration.PostgresIntegrationTestBase;
import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityDataElementDimension;
import org.hisp.dhis.trackedentity.TrackedEntityType;
import org.hisp.dhis.tracker.export.event.EventChangeLogService;
import org.hisp.dhis.tracker.export.event.TrackedEntityDataValueChangeLog;
import org.hisp.dhis.tracker.export.event.TrackedEntityDataValueChangeLogQueryParams;
Expand Down Expand Up @@ -1267,7 +1268,9 @@ void programIndicatorFilterMergeSourcesDeletedTest() throws ConflictException {
"Event eventDataValues references to source DataElements are replaced with target DataElement, source DataElements are not deleted")
void eventMergeTest() throws ConflictException {
// given
TrackedEntity trackedEntity = createTrackedEntity(ou1);
TrackedEntityType trackedEntityType = createTrackedEntityType('O');
identifiableObjectManager.save(trackedEntityType);
TrackedEntity trackedEntity = createTrackedEntity(ou1, trackedEntityType);
identifiableObjectManager.save(trackedEntity);
Enrollment enrollment = createEnrollment(program, trackedEntity, ou1);
identifiableObjectManager.save(enrollment);
Expand Down Expand Up @@ -1352,7 +1355,10 @@ void eventMergeTest() throws ConflictException {
"Event eventDataValues references with source DataElements are deleted when using DISCARD merge strategy")
void eventMergeDiscardTest() throws ConflictException {
// given
TrackedEntity trackedEntity = createTrackedEntity(ou1);

TrackedEntityType trackedEntityType = createTrackedEntityType('O');
identifiableObjectManager.save(trackedEntityType);
TrackedEntity trackedEntity = createTrackedEntity(ou1, trackedEntityType);
identifiableObjectManager.save(trackedEntity);
Enrollment enrollment = createEnrollment(program, trackedEntity, ou1);
identifiableObjectManager.save(enrollment);
Expand Down Expand Up @@ -1445,7 +1451,10 @@ void eventMergeDiscardTest() throws ConflictException {
"Event eventDataValues references to source DataElements are replaced with target DataElement, source DataElements are deleted")
void eventMergeSourcesDeletedTest() throws ConflictException {
// given
TrackedEntity trackedEntity = createTrackedEntity(ou1);

TrackedEntityType trackedEntityType = createTrackedEntityType('O');
identifiableObjectManager.save(trackedEntityType);
TrackedEntity trackedEntity = createTrackedEntity(ou1, trackedEntityType);
identifiableObjectManager.save(trackedEntity);
Enrollment enrollment = createEnrollment(program, trackedEntity, ou1);
identifiableObjectManager.save(enrollment);
Expand Down Expand Up @@ -2549,7 +2558,9 @@ void dataValueAuditMergeDeleteTest() throws ConflictException {
"TrackedEntityDataValueChangeLog with references to source DataElements are not changed or deleted when sources not deleted")
void trackedEntityDataValueChangeLogMergeTest() throws ConflictException {
// given
TrackedEntity trackedEntity = createTrackedEntity(ou1);
TrackedEntityType trackedEntityType = createTrackedEntityType('O');
identifiableObjectManager.save(trackedEntityType);
TrackedEntity trackedEntity = createTrackedEntity(ou1, trackedEntityType);
identifiableObjectManager.save(trackedEntity);
Enrollment enrollment = createEnrollment(program, trackedEntity, ou1);
identifiableObjectManager.save(enrollment);
Expand Down Expand Up @@ -2602,7 +2613,9 @@ void trackedEntityDataValueChangeLogMergeTest() throws ConflictException {
"TrackedEntityDataValueChangeLog with references to source DataElements are deleted when sources are deleted")
void trackedEntityDataValueChangeLogMergeDeletedTest() throws ConflictException {
// given
TrackedEntity trackedEntity = createTrackedEntity(ou1);
TrackedEntityType trackedEntityType = createTrackedEntityType('O');
identifiableObjectManager.save(trackedEntityType);
TrackedEntity trackedEntity = createTrackedEntity(ou1, trackedEntityType);
identifiableObjectManager.save(trackedEntity);
Enrollment enrollment = createEnrollment(program, trackedEntity, ou1);
identifiableObjectManager.save(enrollment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.test.integration.PostgresIntegrationTestBase;
import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
Expand Down Expand Up @@ -97,9 +98,12 @@ void setUp() {
manager.save(ouA);
manager.save(ouB);
manager.save(ouC);
trackedEntityA = createTrackedEntity('A', ouA);
trackedEntityB = createTrackedEntity('B', ouB);
trackedEntityC = createTrackedEntity('C', ouC);

TrackedEntityType trackedEntityType = createTrackedEntityType('O');
manager.save(trackedEntityType);
trackedEntityA = createTrackedEntity('A', ouA, trackedEntityType);
trackedEntityB = createTrackedEntity('B', ouB, trackedEntityType);
trackedEntityC = createTrackedEntity('C', ouC, trackedEntityType);
manager.save(trackedEntityA);
manager.save(trackedEntityB);
manager.save(trackedEntityC);
Expand Down
Loading
Loading