Skip to content

Instantly share code, notes, and snippets.

@samuelmale
Created September 12, 2018 11:05
Show Gist options
  • Save samuelmale/11578bd738ff39a3d8427bbfcfa57869 to your computer and use it in GitHub Desktop.
Save samuelmale/11578bd738ff39a3d8427bbfcfa57869 to your computer and use it in GitHub Desktop.
package org.openmrs.api.db.hibernate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.poi.util.SystemOutLogger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.EncounterType;
import org.openmrs.Form;
import org.openmrs.FormField;
import org.openmrs.test.BaseContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
public class HibernateFormDAOTest extends BaseContextSensitiveTest {
private static final String FORM_XML = "org/openmrs/api/db/hibernate/include/HibernateFormDAOTestDataSet.xml";
@Autowired
HibernateFormDAO dao;
@Before
public void setup() {
executeDataSet(FORM_XML);
}
//@Test
public void shouldFilterAgainstPartialName() {
Assert.assertEquals(3, (Object)dao.getForms("Basic", false, Collections.emptyList(), false, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()).size());
}
//@Test
public void shouldFilterAgainstEncounterTypes() {
List<EncounterType> encTypes = new ArrayList<>();
encTypes.add(new EncounterType(1));
Assert.assertEquals(2, (Object)dao.getForms(null, false, encTypes, null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()).size());
}
@Test
public void shouldFilterAgainstFormFields() {
List<FormField> formFields = Arrays.asList(new FormField(2));
//Assert.assertEquals(3, (Object)dao.getForms(null, false, Collections.emptyList(), null, formFields, Collections.emptyList(), Collections.emptyList()).size());
Assert.assertEquals(0, (Object)dao.getForms(null, false, Collections.emptyList(), null, Collections.emptyList(), formFields, Collections.emptyList()).size());
for (Form form : dao.getForms(null, false, Collections.emptyList(), null, Collections.emptyList(), formFields, Collections.emptyList())) {
System.out.println(form.getName());
}
formFields = new ArrayList<>();
formFields.add(new FormField(2));
formFields.add(new FormField(3));
//Assert.assertEquals(1, (Object)dao.getForms(null, false, Collections.emptyList(), null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()).size());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment