TracingFormServiceImpl implements TracingFormService { public TracingTemplateForm getCPTemplate() { Blob form = tracingFormDao.getTracingForm(PrimeroAppConfiguration.getApiBaseUrl()).getForm(); String formJson = new String(form.getBlob()); if ("".equals(formJson)) { return null; } return new Gson().fromJson(formJson, TracingTemplateForm.class); } TracingFormServiceImpl(TracingFormDao tracingFormDao); boolean isReady(); TracingTemplateForm getCPTemplate(); void saveOrUpdate(TracingForm tracingForm); static final String TAG; }
@Test public void should_get_tracing_form() throws IOException { TracingForm tracingForm = new TracingForm(); tracingForm.setForm(new Blob(formForm.getBytes())); when(tracingFormDao.getTracingForm(PrimeroAppConfiguration.getApiBaseUrl())).thenReturn(tracingForm); TracingTemplateForm form = tracingFormService.getCPTemplate(); assertThat(form.getSections().size(), is(1)); Section section = form.getSections().get(0); assertThat(section.getName().get("en"), is("Record Owner")); assertThat(section.getOrder(), is(10)); assertThat(section.getHelpText().get("en"), is("")); assertThat(section.getBaseLanguage(), is("en")); Field field = section.getFields().get(0); assertThat(field.getName(), is("tracingworker_name")); assertThat(field.getDisplayName().get("en"), is("Field/Tracing/Social Worker")); assertThat(field.getHelpText().get("en"), is("")); assertThat(field.getType(), is("text_field")); assertThat(field.getOptionStringsText().get("en").size(), is(0)); assertThat(field.isShowOnMiniForm(), is(true)); assertThat(field.isMultiSelect(), is(false)); assertThat(field.isEditable(), is(true)); assertThat(field.isRequired(), is(false)); assertThat(field.getSubForm(), is(nullValue())); }