本文整理汇总了Java中org.javarosa.core.model.QuestionDef.getID方法的典型用法代码示例。如果您正苦于以下问题:Java QuestionDef.getID方法的具体用法?Java QuestionDef.getID怎么用?Java QuestionDef.getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.QuestionDef
的用法示例。
在下文中一共展示了QuestionDef.getID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAccessorsModifiers
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void testAccessorsModifiers () {
QuestionDef q = new QuestionDef();
q.setID(45);
if (q.getID() != 45) {
fail("ID getter/setter broken");
}
testSerialize(q, "c");
IDataReference ref = newRef("/data");
q.setBind(ref);
if (q.getBind() != ref) {
fail("Ref getter/setter broken");
}
testSerialize(q, "e");
q.setControlType(Constants.CONTROL_SELECT_ONE);
if (q.getControlType() != Constants.CONTROL_SELECT_ONE) {
fail("Control type getter/setter broken");
}
testSerialize(q, "g");
q.setAppearanceAttr("minimal");
if (!"minimal".equals(q.getAppearanceAttr())) {
fail("Appearance getter/setter broken");
}
testSerialize(q, "h");
}
示例2: testAccessorsModifiers
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
@Test
public void testAccessorsModifiers() {
QuestionDef q = new QuestionDef();
q.setID(45);
if (q.getID() != 45) {
fail("ID getter/setter broken");
}
testSerialize(q, "c");
XPathReference ref = newRef("/data");
q.setBind(ref);
if (q.getBind() != ref) {
fail("Ref getter/setter broken");
}
testSerialize(q, "e");
q.setControlType(Constants.CONTROL_SELECT_ONE);
if (q.getControlType() != Constants.CONTROL_SELECT_ONE) {
fail("Control type getter/setter broken");
}
testSerialize(q, "g");
q.setAppearanceAttr("minimal");
if (!"minimal".equals(q.getAppearanceAttr())) {
fail("Appearance getter/setter broken");
}
testSerialize(q, "h");
}
示例3: testCurrentFuncInTriggers
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
* Make sure that 'current()' expands correctly when used in conditionals
* such as in 'relevant' tags. The test answers a question and expects the
* correct elements to be re-evaluated and set to not relevant.
*/
@Test
public void testCurrentFuncInTriggers() {
FormParseInit fpi = new FormParseInit("/trigger_and_current_tests.xml");
FormEntryController fec = initFormEntry(fpi);
do {
QuestionDef q = fpi.getCurrentQuestion();
if (q == null) {
continue;
}
// get the reference of question
TreeReference qRef = q.getBind().getReference();
// are we changing the value of /data/show?
if (qRef.toString().equals("/data/show")) {
int response = fec.answerQuestion(new StringData("no"));
if (response != FormEntryController.ANSWER_OK) {
fail("Bad response from fec.answerQuestion()");
}
} else if (q.getID() == 2) {
// check (sketchily) if the second question is shown, which
// shouldn't happen after answering "no" to the first, unless
// triggers aren't working properly.
fail("shouldn't be relevant after answering no before");
}
} while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
示例4: testRelativeRefInTriggers
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
* Make sure that relative references in <bind> elements are correctly
* contextualized.
*/
@Test
public void testRelativeRefInTriggers() {
FormParseInit fpi = new FormParseInit("/test_nested_preds_with_rel_refs.xml");
FormEntryController fec = fpi.getFormEntryController();
fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
FormDef fd = fpi.getFormDef();
// run initialization to ensure xforms-ready event and binds are
// triggered.
fd.initialize(true, new DummyInstanceInitializationFactory());
FormInstance instance = fd.getMainInstance();
String errorMsg;
errorMsg = ExprEvalUtils.expectedEval("/data/query-one", instance, null, "0", null);
assertTrue(errorMsg, "".equals(errorMsg));
boolean[] shouldBePresent = {true, true};
do {
QuestionDef q = fpi.getCurrentQuestion();
if (q == null) {
continue;
}
if (q.getID() <= shouldBePresent.length && !shouldBePresent[q.getID() - 1]) {
fail("question with id " + q.getID() + " shouldn't be relevant");
}
} while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
示例5: testFormOverride
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
* Test overriding of built-in functions.
* Behaviour should be:
* - Use overridden function but if there's an arity mismatch fall through
* to the default.
* - Makes sure falling through to default still raises additional arity
* mismatches.
*/
@Test
public void testFormOverride() {
fpi = new FormParseInit("/CustomFunctionTestOverride.xhtml");
// Override true to take in one argument and return 4.0
IFunctionHandler myTrue = new IFunctionHandler() {
public String getName() {
return "true";
}
public Object eval(Object[] args, EvaluationContext ec) {
if (args.length != 1) {
throw new XPathArityException(getName(), 1, args.length);
}
return 4.0;
}
public Vector getPrototypes() {
Class[] proto = {Double.class};
Vector<Class[]> v = new Vector<Class[]>();
v.addElement(proto);
return v;
}
public boolean rawArgs() {
return false;
}
};
fpi.getFormDef().exprEvalContext.addFunctionHandler(myTrue);
FormEntryController fec = fpi.getFormEntryController();
boolean sawQuestionThree = false;
do {
QuestionDef q = fpi.getCurrentQuestion();
if (q == null) {
continue;
}
if ("qOne".equals(q.getTextID())) {
fec.answerQuestion(new IntegerData(1));
} else if ("qTwo".equals(q.getTextID())) {
try {
fec.answerQuestion(new IntegerData(2));
} catch (XPathArityException e) {
// we expect the test to fail on parsing, since it triggers
// a calculation that sends too many args to the overriden
// 'true' function
}
} else if (q.getID() == 3) {
// we expect calling "true()" will default to old behavior
sawQuestionThree = true;
} else if (q.getID() == 4 && sawQuestionThree) {
// we should've seen the last 2 question in the form
return;
}
} while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
fail("error in form expression calculation; the last form" +
" question should be relevant");
}