Skip to content

Commit

Permalink
fix: failed test on jenkins testDeleteProgramWithMapView (#19704)
Browse files Browse the repository at this point in the history
* fix: FK constraint error when delete Program with MapView

* fix: failed test on jenkins testDeleteProgramWithMapView
  • Loading branch information
vietnguyen authored Jan 17, 2025
1 parent 2f1e9ee commit 45a7218
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.HashSet;
import java.util.List;
import org.hisp.dhis.mapping.MapView;
import org.hisp.dhis.mapping.MappingService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.test.integration.PostgresIntegrationTestBase;
Expand All @@ -52,8 +53,12 @@ class ProgramServiceTest extends PostgresIntegrationTestBase {

@Autowired private ProgramService programService;

@Autowired private ProgramStageService programStageService;

@Autowired private OrganisationUnitService organisationUnitService;

@Autowired private MappingService mappingService;

private OrganisationUnit organisationUnitA;

private OrganisationUnit organisationUnitB;
Expand Down Expand Up @@ -153,16 +158,18 @@ void testProgramHasOrgUnit() {

@Test
void testDeleteProgramWithMapView() {
entityManager.persist(programA);
programService.addProgram(programA);
ProgramStage programStageA = createProgramStage('A', programA);
entityManager.persist(programStageA);
programStageService.saveProgramStage(programStageA);
programA.getProgramStages().add(programStageA);
MapView mapView = createMapView("Test");
mapView.setProgram(programA);
mapView.setProgramStage(programStageA);
entityManager.persist(mapView);

mappingService.addMapView(mapView);
assertDoesNotThrow(() -> programService.deleteProgram(programA));

entityManager.flush();
mapView = mappingService.getMapView(mapView.getId());
assertNull(mapView.getProgram());
assertNull(mapView.getProgramStage());
}
Expand Down

0 comments on commit 45a7218

Please sign in to comment.