Skip to content

Conversation

@VaishSiddharth
Copy link
Contributor

@VaishSiddharth VaishSiddharth commented Nov 4, 2025

@VaishSiddharth VaishSiddharth changed the title [WIP] Add scheduler to complete programs Add scheduler to complete programs Nov 5, 2025
@VaishSiddharth VaishSiddharth changed the title Add scheduler to complete programs LAMP-49: Add scheduler to complete programs Nov 5, 2025
@rbuisson
Copy link
Member

Asking review from @corneliouzbett since I'm not the best person to review this backend code.
The logic itself looks fine to me.
I can see the concepts holding the programs max duration are expected to be created by some other mean (likely OpenMRS Iniz Config) which seems fine to me.

Copy link

@corneliouzbett corneliouzbett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

import java.util.List;
import static org.junit.Assert.assertNotNull;
import org.mockito.Mockito;
import static org.mockito.Mockito.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid wildcards imports

<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<version>${openmrsPlatformVersion}</version>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you are using a lower version of OpenMRS platform v2.4.0. You should be targetting 2.7.x

import java.util.Date;

import org.junit.Before;
import org.junit.Test;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend writing tests using JUnit 5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot use JUnit5 because PowerMock is not officially supported by JUnit 5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to get rid of PowerMock in favor of mockStatic from Mockito library

<comment>Inserting CompletePrograms Task into 'schedule_task_config' table</comment>
<insert tableName="scheduler_task_config">
<column name="name" value="Complete LAMP Program Task" />
<column name="description" value="Completes open Programs in Ozone LAMP" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this module be used outside Ozone Lamp distro? If yes, let's remove 'Ozone Lamp' in the description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. This module is tied to Ozone LAMP programs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class shouldn't be a Spring bean but rather just a constants Class.

Comment on lines +16 to +25
<changeSet id="create-complete-program-task-2025-11-04" author="siddharth">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT COUNT(*) FROM scheduler_task_config
WHERE schedulable_class = 'org.openmrs.module.lamp.scheduler.CompleteProgramsTask'
And name = 'Complete LAMP Program Task'
</sqlCheck>
</preConditions>
<comment>Inserting CompletePrograms Task into 'schedule_task_config' table</comment>
<insert tableName="scheduler_task_config">
Copy link

@corneliouzbett corneliouzbett Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, I would like us to migrate from using this approach (built-in scheduled task engine). This is because if the module is removed for some reason, there will be always scheduled task configuration hanging around, which throws errors due to classes not being found

Copy link

@corneliouzbett corneliouzbett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VaishSiddharth can you revert (last commit) to using JUnit 4. Let's have a follow up task to migrate to JUnit 5.

@VaishSiddharth VaishSiddharth force-pushed the complete-program-scheduler branch from abe9f5d to 0dcf8e4 Compare November 24, 2025 10:57
@VaishSiddharth VaishSiddharth merged commit 2530bbc into main Nov 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants