@Override public String loadQuestionClassId( NetworkId networkId, QuestionId questionId, AnalysisId analysisId) throws IOException { return Question.parseQuestion(loadQuestion(networkId, questionId, analysisId)).getName(); }
@VisibleForTesting void uploadQuestion(String network, String question, String questionJson, boolean validate) { if (validate) { // Validate the question before saving it to disk. try { Question.parseQuestion(questionJson); } catch (Exception e) { throw new BatfishException( String.format("Invalid question %s/%s: %s", network, question, e.getMessage()), e); } } NetworkId networkId; try { networkId = _idManager.getNetworkId(network); } catch (IllegalArgumentException e) { throw new InternalServerErrorException( String.format("Error uploading question: network=%s, question=%s", network, question), e); } QuestionId questionId = _idManager.generateQuestionId(); _storage.storeQuestion(questionJson, networkId, questionId, null); _idManager.assignQuestion(question, networkId, questionId, null); }
return Question.parseQuestion(fillTemplate(questionJson, parsedParameters, "qname").toString());
Question questionObj = Question.parseQuestion(questionStr);
checkClientVersion(clientVersion); Question inputQuestion = Question.parseQuestion(questionTemplate); Question outputQuestion = inputQuestion.configureTemplate(exceptions, assertion); String outputQuestionStr = BatfishObjectMapper.writePrettyString(outputQuestion);
@Test public void fillTemplate() throws JSONException, IOException { JSONObject template = new JSONObject(CommonUtil.readResource("org/batfish/client/goodTemplate.json")); JSONObject filledTempate = QuestionHelper.fillTemplate( template, ImmutableSortedMap.of("parameter1", new IntNode(2)), "qname"); QuestionHelperTestQuestion question = (QuestionHelperTestQuestion) Question.parseQuestion(filledTempate.toString()); // the mandatory parameter should get the value we gave, and the optional one should get default assertThat(question.getParameterMandatory(), equalTo(2)); assertThat(question.getParameterOptional(), equalTo(QuestionHelperTestQuestion.DEFAULT_VALUE)); }
Question.parseQuestion( getQuestion( workItem.getContainerName(), for (String qName : qNames) { Question question = Question.parseQuestion(getQuestion(workItem.getContainerName(), qName, aName)); if (question.getDataPlane()) { workType = WorkType.DATAPLANE_DEPENDENT_ANSWERING;
question = Question.parseQuestion(rawQuestionStr); } catch (Exception e) { Answer answer = new Answer();