Skip to content

Commit

Permalink
fix: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaCambi77 committed Nov 28, 2023
1 parent e434a0b commit 423a0e7
Show file tree
Hide file tree
Showing 24 changed files with 38 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private Set<TrackedEntityAttributeValue> getTrackedEntityAttributeValues(

@Override
public List<Enrollment> getEnrollments(EnrollmentOperationParams params)
throws ForbiddenException, BadRequestException, NotFoundException {
throws ForbiddenException, BadRequestException {
EnrollmentQueryParams queryParams = paramsMapper.map(params);

decideAccess(queryParams);
Expand All @@ -218,7 +218,7 @@ public List<Enrollment> getEnrollments(EnrollmentOperationParams params)

@Override
public Page<Enrollment> getEnrollments(EnrollmentOperationParams params, PageParams pageParams)
throws ForbiddenException, BadRequestException, NotFoundException {
throws ForbiddenException, BadRequestException {
EnrollmentQueryParams queryParams = paramsMapper.map(params);

decideAccess(queryParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class EnrollmentOperationParams {

public static class EnrollmentOperationParamsBuilder {

private List<Order> order = new ArrayList<>();
private final List<Order> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Enrollment getEnrollment(Enrollment enrollment, EnrollmentParams params, boolean

/** Get all enrollments matching given params. */
List<Enrollment> getEnrollments(EnrollmentOperationParams params)
throws BadRequestException, ForbiddenException, NotFoundException;
throws BadRequestException, ForbiddenException;

/** Get a page of enrollments matching given params. */
Page<Enrollment> getEnrollments(EnrollmentOperationParams params, PageParams pageParams)
throws BadRequestException, ForbiddenException, NotFoundException;
throws BadRequestException, ForbiddenException;

/**
* Fields the {@link #getEnrollments(EnrollmentOperationParams)} can order enrollments by.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public class EventOperationParams {

public static class EventOperationParamsBuilder {

private List<Order> order = new ArrayList<>();
private final List<Order> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class RelationshipOperationParams {

public static class RelationshipOperationParamsBuilder {

private List<Order> order = new ArrayList<>();
private final List<Order> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public class TrackedEntityOperationParams {

public static class TrackedEntityOperationParamsBuilder {

private List<Order> order = new ArrayList<>();
private final List<Order> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Luciano Fiandesio
*/
public abstract class AbstractMapper<T> implements RowCallbackHandler {
Multimap<String, T> items;
final Multimap<String, T> items;

protected AbstractMapper() {
this.items = ArrayListMultimap.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ public enum TrackerBundleReportMode {
ERRORS,

/** Returns tracker bundle report with warnings but without errors and timings. */
WARNINGS;
WARNINGS
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public MetadataIdentifier getCategoryOptionComboIdentifier(
private List<String> enrollmentsWithOneOrMoreNonDeletedEvent = Lists.newArrayList();

/** A list of Program Stage UID having 1 or more Events */
private List<Pair<String, String>> programStageWithEvents = Lists.newArrayList();
private final List<Pair<String, String>> programStageWithEvents = Lists.newArrayList();

/** idScheme map */
@Getter @Setter private TrackerIdSchemeParams idSchemes = new TrackerIdSchemeParams();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@
* @author Morten Olav Hansen <[email protected]>
*/
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
/** The type of an issue. @Author Enrico Colasante */
public enum IssueType {
WARNING,
ERROR;
ERROR
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static <T extends ValueTypedDimensionalItemObject> void validateOptionSet
return;
}

boolean isValid = true;
boolean isValid;

if (optionalObject.getValueType().isMultiText()) {
isValid = optionalObject.getOptionSet().hasAllOptions(ValueType.splitMultiText(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ private Enrollment enrollment(Attribute... attributes) {

private List<Attribute> attributes(Attribute[] attributes) {
List<Attribute> attrs = new ArrayList<>();
for (Attribute at : attributes) {
attrs.add(at);
}
Collections.addAll(attrs, attributes);
return attrs;
}

Expand All @@ -237,9 +235,7 @@ private Event event(DataValue... dataValues) {

private Set<DataValue> dataValues(DataValue[] dataValues) {
Set<DataValue> dvs = new HashSet<>();
for (DataValue dv : dataValues) {
dvs.add(dv);
}
Collections.addAll(dvs, dataValues);
return dvs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ private Enrollment enrollment(Attribute... attributes) {

private List<Attribute> attributes(Attribute[] attributes) {
List<Attribute> attrs = new ArrayList<>();
for (Attribute at : attributes) {
attrs.add(at);
}
Collections.addAll(attrs, attributes);
return attrs;
}

Expand All @@ -233,9 +231,7 @@ private Event event(DataValue... dataValues) {

private Set<DataValue> dataValues(DataValue[] dataValues) {
Set<DataValue> dvs = new HashSet<>();
for (DataValue dv : dataValues) {
dvs.add(dv);
}
Collections.addAll(dvs, dataValues);
return dvs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down

0 comments on commit 423a0e7

Please sign in to comment.