Wikum Weerakutti

GSOC-2023: Coding Week 05

In the fifth week of the Google Summer of Code (GSoC) coding period, I made significant progress on several fronts. Here is a detailed breakdown them:

Addressing Mentor Feedback for PRs

Switching to the new Date and Time API

As part of this PR, tests were requested by my mentors to ensure the reliability and correctness of the code.

    private boolean checkIfOneWeekFromLastReport(){
        LocalDate lastReport = getLastReported();
        LocalDate currentDate = LocalDate.now();
        if (lastReport != null) {
            return ChronoUnit.DAYS.between(lastReport, currentDate) > 7;
        } else {
            return true;
        }
    }

To address my mentors' request for tests, I initially examined the calling method, which was responsible for sending data to a Google form. However, due to the specific nature of its functionality, I struggled to identify a suitable approach for writing tests.

To overcome the challenge, I resorted to an unconventional hack. I extracted the relevant code block from checkIfOneWeekFromLastReport() and created a separate public method to encapsulate it. This extracted code block was as follows:

if (lastReport != null) {
    return ChronoUnit.DAYS.between(lastReport, currentDate) > 7;
} else {
    return true;
}

My mentor advised me to not because making a method public only for the sake of tests is not good. So I decided to go back and write tests using Java reflections to access private members of the class. After I added the tests this PR got merged: https://github.com/openmrs/openmrs-sdk/commit/c7db8a1fd5f9c48a65cce2348ff6383257dd29bb

Using Java 8 Optional Class

Using Optional classes is something new for me. Initially, I perceived Optional as a replacement for if (val == null) statements with if (val.isPresent()). However, my mentor shared two invaluable articles that shed light on the true potential of Optional. These articles provided a comprehensive guide on best practices and effective use cases, enabling me to enhance my code accordingly

Here is a summary of the key takeaways from those articles

After reading this article I made changes to the code accordingly.

Updating the SDK to Java 11:

So our initial plan for this GSOC project was to update the SDK to use Java 8. After some considerations I decided that using Java 11 is going to be better than Java 8. So with mentor's permissions I updated the SDK to use Java 11.

PR: https://github.com/openmrs/openmrs-sdk/pull/230

Updating Maven to the Latest Version:

Upgrading the SDK to the latest version of Maven is necessary to improve its reliability and performance. I updated all the maven plugins to latest version in this PR: https://github.com/openmrs/openmrs-sdk/pull/231/files

Enhancing the Documentation System:

The output from mvn openmrs-sdk:help is outdated. To make it up to date I had to

This was a meticulous and comprehensive task that involved reviewing each plugin's and parameter's functionality and updating the documentation accordingly. Here is the PR for this: https://github.com/openmrs/openmrs-sdk/pull/232](https://github.com/openmrs/openmrs-sdk/pull/232

Bumping the SDK Version to 5.0.0-SNAPSHOT:

As we were having both the master branch and the 4.0.X branch producing the same version of the snapshot artifacts, we decided to bump the SDK version of the master branch to 5.0.0-SNAPSHOT.

PR: https://github.com/openmrs/openmrs-sdk/pull/229

Future

Because of some recent changes, we are having some trouble building the O3 front end. My main objective now is to find a way to mitigate these errors and add O3 support to the build-distro plugin. Thank you for reading,