@Test public void testGenerateQuestionPaper() throws Exception{ String itemSet = "{\"id\":986983,\"graphId\":\"domain\",\"identifier\":\"do_11292667205373132811\",\"nodeType\":\"DATA_NODE\",\"objectType\":\"ItemSet\",\"metadata\":{\"owner\":\"Ilimi\",\"lastStatusChangedOn\":\"2020-01-02T16:31:37.174+0530\",\"code\":\"akshara.grade5.ws1.test\",\"previewUrl\":\"https: Map<String, Object> nodeMap = mapper.readValue(itemSet, Map.class); DefinitionDTO d = new ControllerUtil().getDefinition("domain", "ItemSet"); Node node = ConvertToGraphNode.convertToGraphNode(nodeMap, d, null); Relation r = new Relation("do_11292667205373132811", "hasSequenceMember", "test.mcq_test_mcq_101"); Map<String, Object> relationMataData = new HashMap<>(); relationMataData.put("IL_SEQUENCE_INDEX", 1); r.setMetadata(relationMataData); r.setStartNodeObjectType("ItemSet"); r.setEndNodeObjectType("AssessmentItem"); node.setOutRelations(Arrays.asList(r)); System.out.println(node.getOutRelations().size()); PowerMockito.mockStatic(QuestionPaperGeneratorUtil.class); try { String questionNodeMapString = "{\"outRelations\":\"[{\\\"endNodeId\\\":\\\"Num:C1:SC1\\\",\\\"relationType\\\":\\\"associatedTo\\\"},{\\\"endNodeId\\\":\\\"Num:C1:SC1\\\",\\\"relationType\\\":\\\"associatedTo\\\"}]\",\"inRelations\":[{\"id\":824419,\"graphId\":\"domain\",\"relationType\":\"hasSequenceMember\",\"startNodeId\":\"do_11292667205373132811\",\"endNodeId\":\"test.mcq_test_mcq_101\",\"startNodeName\":\"Akshara Worksheet Grade 5 Item Set\",\"endNodeName\":\"Mmcq Question 2\",\"startNodeType\":\"DATA_NODE\",\"endNodeType\":\"DATA_NODE\",\"startNodeObjectType\":\"ItemSet\",\"endNodeObjectType\":\"AssessmentItem\",\"metadata\":{\"IL_SEQUENCE_INDEX\":1},\"startNodeMetadata\":{\"owner\":\"Ilimi\",\"lastStatusChangedOn\":\"2020-01-02T16:31:37.174+0530\",\"code\":\"akshara.grade5.ws1.test\",\"previewUrl\":\"https: Map<String, Object> questionNodeMap = mapper.readValue(questionNodeMapString, HashMap.class); d = new ControllerUtil().getDefinition("domain", "AssessmentItem"); Node assessmentItemNode = ConvertToGraphNode.convertToGraphNode(questionNodeMap, d, null); Map<String, Object> questionMap = new HashMap<>(); questionMap.put("test.mcq_test_mcq_101", assessmentItemNode); PowerMockito.when(QuestionPaperGeneratorUtil.getMetadataFromNeo4j(Mockito.anyList())).thenReturn(questionMap); String questionNodeBodyString = "{\"test.mcq_test_mcq_101\":{\"body\":\"<div class='mcq-vertical cheveron-helper'><div class='mcq-title'><p>Which of the following sets of tests would be LEAST urgently indicated for a patient presenting with intraocular pressures of R 22mmHg and L 46mmHg?</p></div><i class='chevron down icon'></i><div class='mcq-options'><div data-simple-choice-interaction data-response-variable='responseValue' value=0 class='mcq-option'><p>Visual field examination and dilated optic nerve head assessment</p></div><div data-simple-choice-interaction data-response-variable='responseValue' value=1 class='mcq-option'><p>Examination of the irides and anterior chamber assessment for cells and flare</p></div><div data-simple-choice-interaction data-response-variable='responseValue' value=2 class='mcq-option'><p>Gonioscopy and assessment of the lens capsule</p></div><div data-simple-choice-interaction data-response-variable='responseValue' value=3 class='mcq-option'><p>Assessment of the corneal endothelium and iris transillumination</p></div></div></div>\"}}"; Map<String, Object> questionBodyMap = mapper.readValue(questionNodeBodyString, HashMap.class); PowerMockito.when(QuestionPaperGeneratorUtil.getExternalPropsData(Mockito.anyList())).thenReturn(questionBodyMap); File file = QuestionPaperGenerator.generateQuestionPaper(node); System.out.println(file.getAbsolutePath()); }catch(Exception e) { e.printStackTrace(); } }
public static File generateQuestionPaper(Node node) throws JsonParseException, JsonMappingException, IOException { Map<String, Object> childDetails = fetchChildDetails(node); if (MapUtils.isNotEmpty(childDetails)) { Map<String, Object> assessmentData = getAssessmentDataMap(childDetails); Map<String, Object> htmlData = populateAssessmentData(assessmentData); Map<String, Object> sortedHtmlData = sortByIndex(htmlData); String htmlString = generateHtmlString(null, sortedHtmlData, node); if ( StringUtils.isNotBlank(htmlString)) return generateHtmlFile(htmlString, node.getIdentifier()); TelemetryManager.error("HTML String is not generated for ItemSet :: " + node.getIdentifier() + " :: " + htmlString); } TelemetryManager.error("ItemSet childDetails are empty for Itemset :: " + node.getIdentifier() + childDetails); return null; }
QuestionPaperGenerator { public static File generateQuestionPaper(Node node) throws JsonParseException, JsonMappingException, IOException { Map<String, Object> childDetails = fetchChildDetails(node); if (MapUtils.isNotEmpty(childDetails)) { Map<String, Object> assessmentData = getAssessmentDataMap(childDetails); Map<String, Object> htmlData = populateAssessmentData(assessmentData); Map<String, Object> sortedHtmlData = sortByIndex(htmlData); String htmlString = generateHtmlString(null, sortedHtmlData, node); if ( StringUtils.isNotBlank(htmlString)) return generateHtmlFile(htmlString, node.getIdentifier()); TelemetryManager.error("HTML String is not generated for ItemSet :: " + node.getIdentifier() + " :: " + htmlString); } TelemetryManager.error("ItemSet childDetails are empty for Itemset :: " + node.getIdentifier() + childDetails); return null; } }
QuestionPaperGenerator { public static File generateQuestionPaper(Node node) throws JsonParseException, JsonMappingException, IOException { Map<String, Object> childDetails = fetchChildDetails(node); if (MapUtils.isNotEmpty(childDetails)) { Map<String, Object> assessmentData = getAssessmentDataMap(childDetails); Map<String, Object> htmlData = populateAssessmentData(assessmentData); Map<String, Object> sortedHtmlData = sortByIndex(htmlData); String htmlString = generateHtmlString(null, sortedHtmlData, node); if ( StringUtils.isNotBlank(htmlString)) return generateHtmlFile(htmlString, node.getIdentifier()); TelemetryManager.error("HTML String is not generated for ItemSet :: " + node.getIdentifier() + " :: " + htmlString); } TelemetryManager.error("ItemSet childDetails are empty for Itemset :: " + node.getIdentifier() + childDetails); return null; }  }
QuestionPaperGenerator { public static File generateQuestionPaper(Node node) throws JsonParseException, JsonMappingException, IOException { Map<String, Object> childDetails = fetchChildDetails(node); if (MapUtils.isNotEmpty(childDetails)) { Map<String, Object> assessmentData = getAssessmentDataMap(childDetails); Map<String, Object> htmlData = populateAssessmentData(assessmentData); Map<String, Object> sortedHtmlData = sortByIndex(htmlData); String htmlString = generateHtmlString(null, sortedHtmlData, node); if ( StringUtils.isNotBlank(htmlString)) return generateHtmlFile(htmlString, node.getIdentifier()); TelemetryManager.error("HTML String is not generated for ItemSet :: " + node.getIdentifier() + " :: " + htmlString); } TelemetryManager.error("ItemSet childDetails are empty for Itemset :: " + node.getIdentifier() + childDetails); return null; }  static File generateQuestionPaper(Node node); static Map<String, Object> fetchChildDetails(Node node); static Map<String, Object> getAssessmentDataMap(Map<String, Object> childData); static String getFileName(String prefix); }
QuestionPaperGenerator { public static File generateQuestionPaper(Node node) throws JsonParseException, JsonMappingException, IOException { Map<String, Object> childDetails = fetchChildDetails(node); if (MapUtils.isNotEmpty(childDetails)) { Map<String, Object> assessmentData = getAssessmentDataMap(childDetails); Map<String, Object> htmlData = populateAssessmentData(assessmentData); Map<String, Object> sortedHtmlData = sortByIndex(htmlData); String htmlString = generateHtmlString(null, sortedHtmlData, node); if ( StringUtils.isNotBlank(htmlString)) return generateHtmlFile(htmlString, node.getIdentifier()); TelemetryManager.error("HTML String is not generated for ItemSet :: " + node.getIdentifier() + " :: " + htmlString); } TelemetryManager.error("ItemSet childDetails are empty for Itemset :: " + node.getIdentifier() + childDetails); return null; }  static File generateQuestionPaper(Node node); static Map<String, Object> fetchChildDetails(Node node); static Map<String, Object> getAssessmentDataMap(Map<String, Object> childData); static String getFileName(String prefix);  }