Skip to content
Open
Changes from 1 commit
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 @@ -23,6 +23,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class HibernateFormDAOTest extends BaseContextSensitiveTest {

Expand All @@ -49,6 +50,7 @@ public void shouldFilterAgainstFormFields() {
.getForms(null, false, Collections.emptyList(), null, formFields, formFields, Arrays.asList(new Field(3)))
.size());


}

@Test
Expand All @@ -64,4 +66,27 @@ public void shouldGetFormFieldsByForm() {
assertEquals(form.getFormId(), formField.getForm().getFormId());
}
}

@Test
public void getForms_shouldReturnFormsContainingAnyFormField() {
// Create a list with a single FormField
List<FormField> anyFormFields = Arrays.asList(new FormField(2));

// Get forms containing ANY of these form fields
List<Form> forms = dao.getForms(
null, // partialName
false, // published
Collections.emptyList(), // encounterTypes
null, // retired
anyFormFields, // containingAnyFormField
Collections.emptyList(), // containingAllFormFields
Collections.emptyList() // fields
);

// Assert that forms were found
assertNotNull(forms);

// Assert at least one form contains this form field
assertTrue(forms.size() > 0);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are there any edge cases where multiple form fields exist but none match? It might be useful to include such scenarios in the tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good point. You're right—we should cover the scenario with multiple
non-existent fields

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for the suggestion! I have committed it directly.

Copy link
Copy Markdown

@EDSONZ-WASSWA EDSONZ-WASSWA Mar 31, 2026

Choose a reason for hiding this comment

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

Nice work! @ShrutiSocrates .. I see there is thorough test coverage for the containingAnyFormField functionality as the ticket required....Looks good
Just one thing the comment "//A would-be fix for that" should be removed before merge

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for the approval and feedback! The "//A would-be fix for that" comment
has been removed.