From 423a0e7bd1675c2b9babf15c93a7cd9f3474831e Mon Sep 17 00:00:00 2001 From: luca Date: Tue, 28 Nov 2023 15:17:02 +0100 Subject: [PATCH] fix: clean up --- .../export/enrollment/DefaultEnrollmentService.java | 4 ++-- .../export/enrollment/EnrollmentOperationParams.java | 2 +- .../dhis/tracker/export/enrollment/EnrollmentService.java | 4 ++-- .../dhis/tracker/export/event/EventOperationParams.java | 2 +- .../export/relationship/RelationshipOperationParams.java | 2 +- .../trackedentity/TrackedEntityOperationParams.java | 2 +- .../trackedentity/aggregates/mapper/AbstractMapper.java | 2 +- .../dhis/tracker/imports/TrackerBundleReportMode.java | 2 +- .../dhis/tracker/imports/bundle/TrackerBundleService.java | 2 +- .../hisp/dhis/tracker/imports/preheat/TrackerPreheat.java | 2 +- .../tracker/imports/preheat/TrackerPreheatService.java | 6 +++++- .../hisp/dhis/tracker/imports/programrule/IssueType.java | 2 +- .../imports/validation/validator/ValidationUtils.java | 2 +- .../preheat/supplier/FileResourceSupplierTest.java | 8 ++------ .../preheat/supplier/OrgUnitValueTypeSupplierTest.java | 8 ++------ .../imports/preprocess/AssignedUserPreProcessorTest.java | 2 +- .../BidirectionalRelationshipsPreProcessorTest.java | 2 +- .../imports/preprocess/StrategyPreProcessorTest.java | 2 +- .../executor/enrollment/ValidationExecutorTest.java | 8 ++++---- .../executor/event/ValidationExecutorTest.java | 8 ++++---- .../validation/validator/event/DateValidatorTest.java | 3 +-- .../dhis/webapi/controller/tracker/JsonAssertions.java | 6 ------ .../tracker/export/event/EventsExportControllerTest.java | 5 ++--- .../relationship/RelationshipsExportControllerTest.java | 3 +-- 24 files changed, 38 insertions(+), 51 deletions(-) diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/DefaultEnrollmentService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/DefaultEnrollmentService.java index 0533ff47ec90..df172322eefc 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/DefaultEnrollmentService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/DefaultEnrollmentService.java @@ -193,7 +193,7 @@ private Set getTrackedEntityAttributeValues( @Override public List getEnrollments(EnrollmentOperationParams params) - throws ForbiddenException, BadRequestException, NotFoundException { + throws ForbiddenException, BadRequestException { EnrollmentQueryParams queryParams = paramsMapper.map(params); decideAccess(queryParams); @@ -218,7 +218,7 @@ public List getEnrollments(EnrollmentOperationParams params) @Override public Page getEnrollments(EnrollmentOperationParams params, PageParams pageParams) - throws ForbiddenException, BadRequestException, NotFoundException { + throws ForbiddenException, BadRequestException { EnrollmentQueryParams queryParams = paramsMapper.map(params); decideAccess(queryParams); diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentOperationParams.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentOperationParams.java index 620fcf52dd0e..f7fc475dcc22 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentOperationParams.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentOperationParams.java @@ -95,7 +95,7 @@ public class EnrollmentOperationParams { public static class EnrollmentOperationParamsBuilder { - private List order = new ArrayList<>(); + private final List order = new ArrayList<>(); // Do not remove this unused method. This hides the order field from the builder which Lombok // does not support. The repeated order field and private order method prevent access to order diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentService.java index 75738283b3a7..d99e30af2964 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentService.java @@ -45,11 +45,11 @@ Enrollment getEnrollment(Enrollment enrollment, EnrollmentParams params, boolean /** Get all enrollments matching given params. */ List getEnrollments(EnrollmentOperationParams params) - throws BadRequestException, ForbiddenException, NotFoundException; + throws BadRequestException, ForbiddenException; /** Get a page of enrollments matching given params. */ Page getEnrollments(EnrollmentOperationParams params, PageParams pageParams) - throws BadRequestException, ForbiddenException, NotFoundException; + throws BadRequestException, ForbiddenException; /** * Fields the {@link #getEnrollments(EnrollmentOperationParams)} can order enrollments by. diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventOperationParams.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventOperationParams.java index 2228d926a56c..6ad66809acee 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventOperationParams.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventOperationParams.java @@ -151,7 +151,7 @@ public class EventOperationParams { public static class EventOperationParamsBuilder { - private List order = new ArrayList<>(); + private final List order = new ArrayList<>(); // Do not remove this unused method. This hides the order field from the builder which Lombok // does not support. The repeated order field and private order method prevent access to order diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/relationship/RelationshipOperationParams.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/relationship/RelationshipOperationParams.java index f7c8e5e844b5..dad9871f5419 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/relationship/RelationshipOperationParams.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/relationship/RelationshipOperationParams.java @@ -49,7 +49,7 @@ public class RelationshipOperationParams { public static class RelationshipOperationParamsBuilder { - private List order = new ArrayList<>(); + private final List order = new ArrayList<>(); // Do not remove this unused method. This hides the order field from the builder which Lombok // does not support. The repeated order field and private order method prevent access to order diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/TrackedEntityOperationParams.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/TrackedEntityOperationParams.java index 341796becc6a..e7f2dc653070 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/TrackedEntityOperationParams.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/TrackedEntityOperationParams.java @@ -171,7 +171,7 @@ public class TrackedEntityOperationParams { public static class TrackedEntityOperationParamsBuilder { - private List order = new ArrayList<>(); + private final List order = new ArrayList<>(); // Do not remove this unused method. This hides the order field from the builder which Lombok // does not support. The repeated order field and private order method prevent access to order diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/aggregates/mapper/AbstractMapper.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/aggregates/mapper/AbstractMapper.java index 4c256f4c957f..89ad16f31369 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/aggregates/mapper/AbstractMapper.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/aggregates/mapper/AbstractMapper.java @@ -37,7 +37,7 @@ * @author Luciano Fiandesio */ public abstract class AbstractMapper implements RowCallbackHandler { - Multimap items; + final Multimap items; protected AbstractMapper() { this.items = ArrayListMultimap.create(); diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/TrackerBundleReportMode.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/TrackerBundleReportMode.java index 301313ac0ae2..61756a3c98f1 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/TrackerBundleReportMode.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/TrackerBundleReportMode.java @@ -38,5 +38,5 @@ public enum TrackerBundleReportMode { ERRORS, /** Returns tracker bundle report with warnings but without errors and timings. */ - WARNINGS; + WARNINGS } diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerBundleService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerBundleService.java index cdb50aee5cda..1b1c32d0fec3 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerBundleService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerBundleService.java @@ -77,7 +77,7 @@ public interface TrackerBundleService { /** * Finalize bundle objects * - * @param bundle + * @param bundle to process in post commit operations if any */ void postCommit(TrackerBundle bundle); } diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/TrackerPreheat.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/TrackerPreheat.java index be5d6d9a9cd2..1b494d4ffeb2 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/TrackerPreheat.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/TrackerPreheat.java @@ -270,7 +270,7 @@ public MetadataIdentifier getCategoryOptionComboIdentifier( private List enrollmentsWithOneOrMoreNonDeletedEvent = Lists.newArrayList(); /** A list of Program Stage UID having 1 or more Events */ - private List> programStageWithEvents = Lists.newArrayList(); + private final List> programStageWithEvents = Lists.newArrayList(); /** idScheme map */ @Getter @Setter private TrackerIdSchemeParams idSchemes = new TrackerIdSchemeParams(); diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/TrackerPreheatService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/TrackerPreheatService.java index 05b97823a1ca..2cf5cac3ce05 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/TrackerPreheatService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/TrackerPreheatService.java @@ -35,11 +35,15 @@ * @author Morten Olav Hansen */ public interface TrackerPreheatService { + /** * Preheat a set of pre-defined classes. If size == 0, then preheat all metadata classes * automatically. * - * @param params Params for preheating + * @param trackerObjects list of payload entities + * @param idSchemeParams id schema identifier + * @param user current user + * @return */ TrackerPreheat preheat( TrackerObjects trackerObjects, TrackerIdSchemeParams idSchemeParams, User user); diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/programrule/IssueType.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/programrule/IssueType.java index 76999ffe9c8c..e92ab4b8656d 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/programrule/IssueType.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/programrule/IssueType.java @@ -30,5 +30,5 @@ /** The type of an issue. @Author Enrico Colasante */ public enum IssueType { WARNING, - ERROR; + ERROR } diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/validation/validator/ValidationUtils.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/validation/validator/ValidationUtils.java index 92fd830248ce..0a8696895b63 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/validation/validator/ValidationUtils.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/validation/validator/ValidationUtils.java @@ -173,7 +173,7 @@ public static void validateOptionSet return; } - boolean isValid = true; + boolean isValid; if (optionalObject.getValueType().isMultiText()) { isValid = optionalObject.getOptionSet().hasAllOptions(ValueType.splitMultiText(value)); diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preheat/supplier/FileResourceSupplierTest.java b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preheat/supplier/FileResourceSupplierTest.java index e34306bd2eeb..472586a0b320 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preheat/supplier/FileResourceSupplierTest.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preheat/supplier/FileResourceSupplierTest.java @@ -211,9 +211,7 @@ private Enrollment enrollment(Attribute... attributes) { private List attributes(Attribute[] attributes) { List attrs = new ArrayList<>(); - for (Attribute at : attributes) { - attrs.add(at); - } + Collections.addAll(attrs, attributes); return attrs; } @@ -237,9 +235,7 @@ private Event event(DataValue... dataValues) { private Set dataValues(DataValue[] dataValues) { Set dvs = new HashSet<>(); - for (DataValue dv : dataValues) { - dvs.add(dv); - } + Collections.addAll(dvs, dataValues); return dvs; } diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preheat/supplier/OrgUnitValueTypeSupplierTest.java b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preheat/supplier/OrgUnitValueTypeSupplierTest.java index 9326f0ea7e24..b8ed39720c8c 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preheat/supplier/OrgUnitValueTypeSupplierTest.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preheat/supplier/OrgUnitValueTypeSupplierTest.java @@ -207,9 +207,7 @@ private Enrollment enrollment(Attribute... attributes) { private List attributes(Attribute[] attributes) { List attrs = new ArrayList<>(); - for (Attribute at : attributes) { - attrs.add(at); - } + Collections.addAll(attrs, attributes); return attrs; } @@ -233,9 +231,7 @@ private Event event(DataValue... dataValues) { private Set dataValues(DataValue[] dataValues) { Set dvs = new HashSet<>(); - for (DataValue dv : dataValues) { - dvs.add(dv); - } + Collections.addAll(dvs, dataValues); return dvs; } diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/AssignedUserPreProcessorTest.java b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/AssignedUserPreProcessorTest.java index 2e121ee51539..0c3ea976bc8f 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/AssignedUserPreProcessorTest.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/AssignedUserPreProcessorTest.java @@ -55,7 +55,7 @@ class AssignedUserPreProcessorTest extends DhisConvenienceTest { private static final String USERNAME = "Username"; - private AssignedUserPreProcessor preProcessorToTest = new AssignedUserPreProcessor(); + private final AssignedUserPreProcessor preProcessorToTest = new AssignedUserPreProcessor(); @Mock private TrackerPreheat preheat; diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/BidirectionalRelationshipsPreProcessorTest.java b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/BidirectionalRelationshipsPreProcessorTest.java index c22bf6e242df..546d88a47f65 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/BidirectionalRelationshipsPreProcessorTest.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/BidirectionalRelationshipsPreProcessorTest.java @@ -50,7 +50,7 @@ class BidirectionalRelationshipsPreProcessorTest extends DhisConvenienceTest { private static final String BIDIRECTIONAL_RELATIONSHIP_TYPE_UID = "BIDIRECTIONAL_RELATIONSHIP_TYPE"; - private BidirectionalRelationshipsPreProcessor preProcessorToTest = + private final BidirectionalRelationshipsPreProcessor preProcessorToTest = new BidirectionalRelationshipsPreProcessor(); @Test diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/StrategyPreProcessorTest.java b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/StrategyPreProcessorTest.java index 174e3869c368..021f77de48be 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/StrategyPreProcessorTest.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/preprocess/StrategyPreProcessorTest.java @@ -90,7 +90,7 @@ class StrategyPreProcessorTest extends DhisConvenienceTest { private org.hisp.dhis.tracker.imports.domain.Relationship newPayloadRelationship; - private StrategyPreProcessor preProcessorToTest = new StrategyPreProcessor(); + private final StrategyPreProcessor preProcessorToTest = new StrategyPreProcessor(); @Mock private TrackerPreheat preheat; diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/programrule/executor/enrollment/ValidationExecutorTest.java b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/programrule/executor/enrollment/ValidationExecutorTest.java index 5918b900250f..4c146ad968ea 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/programrule/executor/enrollment/ValidationExecutorTest.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/programrule/executor/enrollment/ValidationExecutorTest.java @@ -65,16 +65,16 @@ class ValidationExecutorTest extends DhisConvenienceTest { private static final String COMPLETED_ENROLLMENT_ID = "CompletedEnrollmentUid"; - private ShowWarningOnCompleteExecutor warningOnCompleteExecutor = + private final ShowWarningOnCompleteExecutor warningOnCompleteExecutor = new ShowWarningOnCompleteExecutor(getValidationRuleAction(WARNING)); - private ShowErrorOnCompleteExecutor errorOnCompleteExecutor = + private final ShowErrorOnCompleteExecutor errorOnCompleteExecutor = new ShowErrorOnCompleteExecutor(getValidationRuleAction(ERROR)); - private ShowErrorExecutor showErrorExecutor = + private final ShowErrorExecutor showErrorExecutor = new ShowErrorExecutor(getValidationRuleAction(ERROR)); - private ShowWarningExecutor showWarningExecutor = + private final ShowWarningExecutor showWarningExecutor = new ShowWarningExecutor(getValidationRuleAction(WARNING)); private TrackerBundle bundle; diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/programrule/executor/event/ValidationExecutorTest.java b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/programrule/executor/event/ValidationExecutorTest.java index 1a955d97f7ce..d43711401fb7 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/programrule/executor/event/ValidationExecutorTest.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/programrule/executor/event/ValidationExecutorTest.java @@ -80,16 +80,16 @@ class ValidationExecutorTest extends DhisConvenienceTest { private static final String ANOTHER_DATA_ELEMENT_ID = "AnotherDataElementId"; - private ShowWarningOnCompleteExecutor warningOnCompleteExecutor = + private final ShowWarningOnCompleteExecutor warningOnCompleteExecutor = new ShowWarningOnCompleteExecutor(getValidationRuleAction(WARNING)); - private ShowErrorOnCompleteExecutor errorOnCompleteExecutor = + private final ShowErrorOnCompleteExecutor errorOnCompleteExecutor = new ShowErrorOnCompleteExecutor(getValidationRuleAction(ERROR)); - private ShowErrorExecutor showErrorExecutor = + private final ShowErrorExecutor showErrorExecutor = new ShowErrorExecutor(getValidationRuleAction(ERROR)); - private ShowWarningExecutor showWarningExecutor = + private final ShowWarningExecutor showWarningExecutor = new ShowWarningExecutor(getValidationRuleAction(WARNING)); private TrackerBundle bundle; diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/validation/validator/event/DateValidatorTest.java b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/validation/validator/event/DateValidatorTest.java index f152bf5ec42c..df85ae8b3bb1 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/validation/validator/event/DateValidatorTest.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/tracker/imports/validation/validator/event/DateValidatorTest.java @@ -41,7 +41,6 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset; -import java.time.temporal.ChronoUnit; import org.hisp.dhis.DhisConvenienceTest; import org.hisp.dhis.common.CodeGenerator; import org.hisp.dhis.event.EventStatus; @@ -277,6 +276,6 @@ private Instant now() { } private Instant sevenDaysAgo() { - return LocalDateTime.now().minus(7, ChronoUnit.DAYS).toInstant(ZoneOffset.UTC); + return LocalDateTime.now().minusDays(7).toInstant(ZoneOffset.UTC); } } diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/JsonAssertions.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/JsonAssertions.java index 1d1c01c44d97..916b4d9f1457 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/JsonAssertions.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/JsonAssertions.java @@ -156,12 +156,6 @@ public static void assertHasNoMember(JsonObject json, String name) { assertFalse(json.has(name), String.format("member \"%s\" should NOT be in %s", name, json)); } - public static void assertHasMembers(JsonObject json, String... names) { - for (String name : names) { - assertHasMember(json, name); - } - } - public static void assertHasMember(JsonObject json, String name) { assertTrue(json.has(name), String.format("member \"%s\" should be in %s", name, json)); } diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportControllerTest.java index 602ccbb64260..7bb7122af412 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportControllerTest.java @@ -480,7 +480,7 @@ private Relationship relationship(RelationshipType type, Event from, TrackedEnti return r; } - private Relationship relationship(TrackedEntity from, Event to) { + private void relationship(TrackedEntity from, Event to) { Relationship r = new Relationship(); RelationshipItem fromItem = new RelationshipItem(); @@ -505,7 +505,6 @@ private Relationship relationship(TrackedEntity from, Event to) { r.setAutoFields(); r.getSharing().setOwner(owner); manager.save(r, false); - return r; } private Note note(String uid, String value, String storedBy) { @@ -518,7 +517,7 @@ private Note note(String uid, String value, String storedBy) { private void assertDefaultResponse(JsonObject json, Event event) { // note that some fields are not included in the response because they // are not part of the setup - // i.e attributeOptionCombo, ... + // i.e. attributeOptionCombo, ... assertTrue(json.isObject()); assertFalse(json.isEmpty()); assertEquals(event.getUid(), json.getString("event").string(), "event UID"); diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipsExportControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipsExportControllerTest.java index b7d1cb0154a8..3d9ed93e2dda 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipsExportControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipsExportControllerTest.java @@ -805,7 +805,7 @@ private Relationship relationship(Event from, TrackedEntity to) { return r; } - private Relationship relationship(Enrollment from, Event to) { + private void relationship(Enrollment from, Event to) { Relationship r = new Relationship(); RelationshipItem fromItem = new RelationshipItem(); @@ -830,7 +830,6 @@ private Relationship relationship(Enrollment from, Event to) { r.setAutoFields(); r.getSharing().setOwner(owner); manager.save(r, false); - return r; } private Relationship relationship(Enrollment from, TrackedEntity to) {