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

fix: Remove unnecessary calls to the DB during DataValueSet import [DHIS2-16138] #15639

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -351,9 +351,7 @@ private void validateDataValueOrgUnitInUserHierarchy(
.getOrgUnitInHierarchyMap()
.get(
valueContext.getOrgUnit().getUid(),
() ->
organisationUnitService.isDescendant(
valueContext.getOrgUnit(), context.getCurrentOrgUnits()));
() -> valueContext.getOrgUnit().isDescendant(context.getCurrentOrgUnits()));

if (!inUserHierarchy) {
context.addConflict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ void setUp() {
approvalService = mock(DataApprovalService.class);
dataValueService = mock(DataValueService.class);
organisationUnitService = mock(OrganisationUnitService.class);
when(organisationUnitService.isDescendant(any(OrganisationUnit.class), any(Set.class)))
.thenReturn(true);
when(organisationUnitService.isDescendant(
any(OrganisationUnit.class), any(OrganisationUnit.class)))
.thenReturn(true);

i18n = mock(I18n.class);
validator =
Expand Down Expand Up @@ -899,6 +894,9 @@ private DataValueContextBuilder createDataValueContext(DataValue dataValue) {
if (ouId != null) {
OrganisationUnit ou = new OrganisationUnit();
ou.setUid(ouId);
// we set the path here just for the tests. This is usually done by the persistence layer
// but there is no interaction with that in these tests.
ou.setPath(ou.getPath());
builder.orgUnit(ou);
}
if (coId != null) {
Expand Down
Loading