@Test public void testConstructor() throws Exception { UploadWidget widget = new UploadWidget(); widget.setInitialValue(new Obs()); FormEntryContext formEntryContext = mock(FormEntryContext.class); when(formEntryContext.getFieldName(widget)).thenReturn("w1"); String html = widget.generateHtml(formEntryContext); assertThat(html, is("<input type=\"file\" class=\"uploadWidget\" id=\"w1\" name=\"w1\"/>")); } }
@Test public void UploadWidgetShouldProduceHtml(){ UploadWidget uw = new UploadWidget(); context.registerWidget(uw); Assert.assertEquals("<input type=\"file\" class=\"uploadWidget\" id=\"w1\" name=\"w1\"/>",uw.generateHtml(context)); }
valueWidget = new UploadWidget(); String lookFor = existingObs == null ? null : existingObs.getValueComplex(); Obs initialValue = null;
if (!((UploadWidget) valueWidget).shouldDelete(session.getContext(), submission)) { value = new ComplexData(existingObs.getValueComplex(), null);