/** Test creation with default value. */ @Test public void testCreation_withDefault() { descriptor.setHasDefault(true); descriptor.setDefaultValue(StringConstants.EMPTY); tester.startPage(getTestPage()); @SuppressWarnings("unchecked") TextArea<String> tf = (TextArea<String>) getTestSubject(); Assert.assertNotNull(tf.getModelObject()); Assert.assertEquals(StringConstants.EMPTY, tf.getModelObject()); Assert.assertFalse(getFeedbackPanel().anyErrorMessage()); Assert.assertFalse(tester.getLastResponse().getDocument().contains(MarkupConstants.READONLY)); }
/** Test creation with no default. */ @Test public void testCreation_nodefault() { tester.startPage(getTestPage()); @SuppressWarnings("unchecked") TextArea<String> tf = (TextArea<String>) getTestSubject(); Assert.assertNull(tf.getModelObject()); Assert.assertFalse(getFeedbackPanel().anyErrorMessage()); Assert.assertFalse(tester.getLastResponse().getDocument().contains(MarkupConstants.READONLY)); }
private void insertFormFieldsIntoQuestion(Question question) { question.setTitle((String) questionTitleField.getModelObject()); question.setPrompt((String) questionPromptField.getModelObject()); question.setPreface((String) questionPrefaceField.getModelObject()); question.setCitation((String) questionCitationField.getModelObject()); question.setAnswerType((Answer.AnswerType) questionResponseTypeModel.getObject()); Object answerReason = questionAnswerReasonModel.getObject(); question.setAnswerReasonExpressionId( answerReason == null || answerReason.equals(answerAlways) ? null : ((Expression) answerReason).getId()); Boolean askingStyle = (Boolean) askingStyleModel.getObject(); String msg = "Asking style in insertFormFields (model=" + askingStyle + "): " + question.getAskingStyleList(); question.setAskingStyleList(askingStyle); // TODO: need to trace what happens in this method msg += " -> " + question.getAskingStyleList(); // throw new RuntimeException(msg); /// question.setUseIfExpression((String) questionUseIfField.getModelObject()); question.setOtherSpecify((Boolean) otherSpecifyCheckBox.getModelObject()); question.setNoneButton((Boolean) noneButtonCheckBox.getModelObject()); question.setTimeUnits((Integer) timeUnitsPanel.getTimeUnits()); if (question.getAnswerType() == Answer.AnswerType.NUMERICAL) { question.setMinLimitType(numericLimitsPanel.getMinLimitType()); question.setMinLiteral(numericLimitsPanel.getMinLiteral()); question.setMinPrevQues(numericLimitsPanel.getMinPrevQues()); question.setMaxLimitType(numericLimitsPanel.getMaxLimitType()); question.setMaxLiteral(numericLimitsPanel.getMaxLiteral()); question.setMaxPrevQues(numericLimitsPanel.getMaxPrevQues()); } else if (question.getAnswerType() == Answer.AnswerType.MULTIPLE_SELECTION) { question.setMinCheckableBoxes(multipleSelectionLimitsPanel.getMinCheckableBoxes()); question.setMaxCheckableBoxes(multipleSelectionLimitsPanel.getMaxCheckableBoxes()); } if (askingStyle) { question.setWithListRange(listLimitsPanel.getWithListRange()); question.setListRangeString(listLimitsPanel.getListRangeString()); question.setMinListRange(listLimitsPanel.getMinListRange()); question.setMaxListRange(listLimitsPanel.getMaxListRange()); } }