/** * @see org.openmrs.api.FormService#getAllForms() */ @Override @Transactional(readOnly = true) public List<Form> getAllForms() throws APIException { return Context.getFormService().getAllForms(true); }
/** * @see FormService#getAllForms(boolean) */ @Test public void getAllForms_shouldReturnAllFormsWithRetiredIfParameterMentionedAsTrue() { List<Form> forms = Context.getFormService().getAllForms(true); int currentFormsSize = forms.size(); assertEquals(1, currentFormsSize); Context.getFormService().saveForm(createMockForm(true)); forms = Context.getFormService().getAllForms(true); assertEquals(currentFormsSize + 1 , forms.size()); }
/** * @see FormService#getAllForms() */ @Test public void getAllForms_shouldReturnAllForms() { List<Form> forms = Context.getFormService().getAllForms(); int currentFormsSize = forms.size(); assertEquals(1, currentFormsSize); Context.getFormService().saveForm(createMockForm(false)); forms = Context.getFormService().getAllForms(); assertEquals(currentFormsSize + 1, forms.size()); }
/** * @see FormService#getAllForms() */ @Test public void getAllForms_shouldReturnAllFormsWithRetiredForms() { List<Form> forms = Context.getFormService().getAllForms(); int currentFormsSize = forms.size(); assertEquals(1, currentFormsSize); Context.getFormService().saveForm(createMockForm(true)); forms = Context.getFormService().getAllForms(); assertEquals(currentFormsSize + 1, forms.size()); }
/** * @see FormService#getAllForms(boolean) */ @Test public void getAllForms_shouldReturnAllFormsWithOutRetiredIfParameterMentionedAsFalse() { List<Form> forms = Context.getFormService().getAllForms(false); int currentFormsSize = forms.size(); assertEquals(1, currentFormsSize); Context.getFormService().saveForm(createMockForm(true)); forms = Context.getFormService().getAllForms(false); assertEquals(currentFormsSize , forms.size()); }
/** * @see FormService#getForm(String) */ @Test public void getForm_shouldReturnNullIfFormNotFound() { List<Form> forms = Context.getFormService().getAllForms(); boolean formNameFound = false; final String formName = "Sample_Form_Not_In_List"; for (Form node:forms) { if (node.getName().equals(formName)) { formNameFound = true; } } assertFalse(formNameFound); Form form = Context.getFormService().getForm(formName); assertNull(form); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<Form> doGetAll(RequestContext context) throws ResponseException { return new NeedsPaging<Form>(Context.getFormService().getAllForms(context.getIncludeAll()), context); }
@Override public long getAllCount() { List<Form> forms = formService.getAllForms(); int count = 0; for (Form f : forms) { count += Context.getFormService().getFormResourcesForForm(f).size(); } return count; } }