From 9b75f03973c084291cf1b445b3dbb8c0ac425d5a Mon Sep 17 00:00:00 2001 From: Lemmynjash Date: Fri, 29 Mar 2024 12:17:00 +0300 Subject: [PATCH] TRUNK-6193: Create a HibernateFormDAO junit test --- .../db/hibernate/HibernateFormDAOTest.java | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/api/src/test/java/org/openmrs/api/db/hibernate/HibernateFormDAOTest.java b/api/src/test/java/org/openmrs/api/db/hibernate/HibernateFormDAOTest.java index 8460c59c2a3b..dc1c465752b4 100644 --- a/api/src/test/java/org/openmrs/api/db/hibernate/HibernateFormDAOTest.java +++ b/api/src/test/java/org/openmrs/api/db/hibernate/HibernateFormDAOTest.java @@ -12,12 +12,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.openmrs.EncounterType; import org.openmrs.Field; import org.openmrs.Form; import org.openmrs.FormField; @@ -59,4 +58,34 @@ public void shouldGetFormFieldsByForm() { assertEquals(form.getFormId(), formField.getForm().getFormId()); } } + + @Test + public void shouldGetFormFieldsByField() { + Field field = new Field(1); + FormField formField = new FormField(2); + formField.setField(field); + List formFields = dao.getFormFieldsByField(field); + assertNotNull(formFields); + assertEquals(3, formFields.size()); + } + + @Test + public void shouldGetFormCount() { + String partialName = "Basic Form"; + Boolean published = false; + Collection encounterTypes = new ArrayList<>(); + Boolean retired = false; + Collection containingAnyFormField = new ArrayList<>(); + Collection containingAllFormFields = new ArrayList<>(); + Collection fields = new ArrayList<>(); + Integer formCount = dao.getFormCount(partialName, + published, + encounterTypes, + retired, + containingAnyFormField, + containingAllFormFields, + fields); + assertNotNull(formCount); + assertEquals(2, formCount); + } }