@Test public void correctMergedConditionColumnHeaders() { final ConversionResult result = new ConversionResult(); final List<DataListener> listeners = new ArrayList<>(); addModelField("org.test.Vehicle", "this", "org.test.Vehicle", DataType.TYPE_THIS); addModelField("org.test.Vehicle", "subRTO", String.class.getName(), DataType.TYPE_STRING); addModelField("org.test.Vehicle", "manufacturer", String.class.getName(), DataType.TYPE_STRING); addModelField("org.test.Vehicle", "model", String.class.getName(), DataType.TYPE_STRING); addModelField("org.test.Vehicle", "vehicleSegment", String.class.getName(), DataType.TYPE_STRING); addModelField("org.test.Vehicle", "vehicleAge", Integer.class.getName(), DataType.TYPE_NUMERIC_INTEGER); addModelField("org.test.Vehicle", "discount", Double.class.getName(), DataType.TYPE_NUMERIC_DOUBLE); final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result, dmo); listeners.add(listener); final ExcelParser parser = new ExcelParser(listeners); final InputStream is = this.getClass().getResourceAsStream("RHBPMS-856 (Merged condition columns).xls"); try { parser.parseFile(is); } finally { try { is.close(); } catch (IOException ioe) { fail(ioe.getMessage()); } } assertEquals(0, result.getMessages().size()); final List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables(); assertNotNull(dtables); assertEquals(1, dtables.size()); GuidedDecisionTable52 dtable = dtables.get(0); assertEquals("VehiclePremiumDiscount", dtable.getTableName()); assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY, dtable.getTableFormat()); List<BaseColumn> columns = dtable.getExpandedColumns(); assertNotNull(columns); assertEquals(10, columns.size()); assertTrue(columns.get(0) instanceof RowNumberCol52); assertTrue(columns.get(1) instanceof RuleNameColumn); assertTrue(columns.get(2) instanceof DescriptionCol52); assertTrue(columns.get(3) instanceof BRLConditionVariableColumn); assertTrue(columns.get(4) instanceof BRLConditionVariableColumn); assertTrue(columns.get(5) instanceof BRLConditionVariableColumn); assertTrue(columns.get(6) instanceof BRLConditionVariableColumn); assertTrue(columns.get(7) instanceof BRLConditionVariableColumn); assertTrue(columns.get(8) instanceof BRLConditionVariableColumn); assertTrue(columns.get(9) instanceof BRLActionVariableColumn); assertEquals(1, dtable.getConditions().size()); assertTrue(dtable.getConditions().get(0) instanceof BRLConditionColumn); BRLConditionColumn conditionCol0 = ((BRLConditionColumn) dtable.getConditions().get(0)); assertEquals("Converted from ['RTO', 'Manufacturer', 'Model', 'Segment', 'Age Min', 'Age Max']", conditionCol0.getHeader()); assertEquals(6, conditionCol0.getChildColumns().size()); List<IPattern> conditionCol0definition = conditionCol0.getDefinition(); assertEquals(1, conditionCol0definition.size()); assertTrue(conditionCol0definition.get(0) instanceof FactPattern); FactPattern conditionCol0fp = (FactPattern) conditionCol0definition.get(0); assertEquals("Vehicle", conditionCol0fp.getFactType()); assertEquals(6, conditionCol0fp.getNumberOfConstraints()); assertTrue(conditionCol0fp.getConstraint(0) instanceof SingleFieldConstraint); final SingleFieldConstraint conditionCol0fpsfc0 = (SingleFieldConstraint) conditionCol0fp.getConstraint(0); assertEquals("subRTO", conditionCol0fpsfc0.getFieldName()); assertEquals("==", conditionCol0fpsfc0.getOperator()); assertEquals("param1", conditionCol0fpsfc0.getValue()); assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc0.getConstraintValueType()); assertEquals(DataType.TYPE_STRING, conditionCol0fpsfc0.getFieldType()); assertTrue(conditionCol0fp.getConstraint(1) instanceof SingleFieldConstraint); final SingleFieldConstraint conditionCol0fpsfc1 = (SingleFieldConstraint) conditionCol0fp.getConstraint(1); assertEquals("manufacturer", conditionCol0fpsfc1.getFieldName()); assertEquals("==", conditionCol0fpsfc1.getOperator()); assertEquals("param2", conditionCol0fpsfc1.getValue()); assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc1.getConstraintValueType()); assertEquals(DataType.TYPE_STRING, conditionCol0fpsfc1.getFieldType()); assertTrue(conditionCol0fp.getConstraint(2) instanceof SingleFieldConstraint); final SingleFieldConstraint conditionCol0fpsfc2 = (SingleFieldConstraint) conditionCol0fp.getConstraint(2); assertEquals("model", conditionCol0fpsfc2.getFieldName()); assertEquals("==", conditionCol0fpsfc2.getOperator()); assertEquals("param3", conditionCol0fpsfc2.getValue()); assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc2.getConstraintValueType()); assertEquals(DataType.TYPE_STRING, conditionCol0fpsfc2.getFieldType()); assertTrue(conditionCol0fp.getConstraint(3) instanceof SingleFieldConstraint); final SingleFieldConstraint conditionCol0fpsfc3 = (SingleFieldConstraint) conditionCol0fp.getConstraint(3); assertEquals("vehicleSegment", conditionCol0fpsfc3.getFieldName()); assertEquals("==", conditionCol0fpsfc3.getOperator()); assertEquals("param4", conditionCol0fpsfc3.getValue()); assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc3.getConstraintValueType()); assertEquals(DataType.TYPE_STRING, conditionCol0fpsfc3.getFieldType()); assertTrue(conditionCol0fp.getConstraint(4) instanceof SingleFieldConstraint); final SingleFieldConstraint conditionCol0fpsfc4 = (SingleFieldConstraint) conditionCol0fp.getConstraint(4); assertEquals("vehicleAge", conditionCol0fpsfc4.getFieldName()); assertEquals("<=", conditionCol0fpsfc4.getOperator()); assertEquals("param5", conditionCol0fpsfc4.getValue()); assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc4.getConstraintValueType()); assertEquals(DataType.TYPE_NUMERIC_INTEGER, conditionCol0fpsfc4.getFieldType()); assertTrue(conditionCol0fp.getConstraint(5) instanceof SingleFieldConstraint); final SingleFieldConstraint conditionCol0fpsfc5 = (SingleFieldConstraint) conditionCol0fp.getConstraint(5); assertEquals("vehicleAge", conditionCol0fpsfc5.getFieldName()); assertEquals(">", conditionCol0fpsfc5.getOperator()); assertEquals("param6", conditionCol0fpsfc5.getValue()); assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc5.getConstraintValueType()); assertEquals(DataType.TYPE_NUMERIC_INTEGER, conditionCol0fpsfc5.getFieldType()); BRLConditionVariableColumn conditionCol0param0 = conditionCol0.getChildColumns().get(0); assertEquals("param1", conditionCol0param0.getVarName()); assertEquals("RTO", conditionCol0param0.getHeader()); assertEquals(DataType.TYPE_STRING, conditionCol0param0.getFieldType()); assertEquals("Vehicle", conditionCol0param0.getFactType()); assertEquals("subRTO", conditionCol0param0.getFactField()); BRLConditionVariableColumn conditionCol0param1 = conditionCol0.getChildColumns().get(1); assertEquals("param2", conditionCol0param1.getVarName()); assertEquals("Manufacturer", conditionCol0param1.getHeader()); assertEquals(DataType.TYPE_STRING, conditionCol0param1.getFieldType()); assertEquals("Vehicle", conditionCol0param1.getFactType()); assertEquals("manufacturer", conditionCol0param1.getFactField()); BRLConditionVariableColumn conditionCol0param2 = conditionCol0.getChildColumns().get(2); assertEquals("param3", conditionCol0param2.getVarName()); assertEquals("Model", conditionCol0param2.getHeader()); assertEquals(DataType.TYPE_STRING, conditionCol0param2.getFieldType()); assertEquals("Vehicle", conditionCol0param2.getFactType()); assertEquals("model", conditionCol0param2.getFactField()); BRLConditionVariableColumn conditionCol0param3 = conditionCol0.getChildColumns().get(3); assertEquals("param4", conditionCol0param3.getVarName()); assertEquals("Segment", conditionCol0param3.getHeader()); assertEquals(DataType.TYPE_STRING, conditionCol0param3.getFieldType()); assertEquals("Vehicle", conditionCol0param3.getFactType()); assertEquals("vehicleSegment", conditionCol0param3.getFactField()); BRLConditionVariableColumn conditionCol0param4 = conditionCol0.getChildColumns().get(4); assertEquals("param5", conditionCol0param4.getVarName()); assertEquals("Age Min", conditionCol0param4.getHeader()); assertEquals(DataType.TYPE_NUMERIC_INTEGER, conditionCol0param4.getFieldType()); assertEquals("Vehicle", conditionCol0param4.getFactType()); assertEquals("vehicleAge", conditionCol0param4.getFactField()); BRLConditionVariableColumn conditionCol0param5 = conditionCol0.getChildColumns().get(5); assertEquals("param6", conditionCol0param5.getVarName()); assertEquals("Age Max", conditionCol0param5.getHeader()); assertEquals(DataType.TYPE_NUMERIC_INTEGER, conditionCol0param5.getFieldType()); assertEquals("Vehicle", conditionCol0param5.getFactType()); assertEquals("vehicleAge", conditionCol0param5.getFactField()); assertEquals(1, dtable.getActionCols().size()); assertTrue(dtable.getActionCols().get(0) instanceof BRLActionColumn); BRLActionColumn actionCol0 = ((BRLActionColumn) dtable.getActionCols().get(0)); assertEquals("Converted from ['Discount(%)']", actionCol0.getHeader()); assertEquals(1, actionCol0.getChildColumns().size()); List<IAction> actionCol0definition = actionCol0.getDefinition(); assertEquals(1, actionCol0definition.size()); assertTrue(actionCol0definition.get(0) instanceof ActionSetField); ActionSetField actionCol0asf0 = (ActionSetField) actionCol0definition.get(0); assertEquals("v", actionCol0asf0.getVariable()); ActionFieldValue[] actionCol0asf0afvs = actionCol0asf0.getFieldValues(); assertEquals(1, actionCol0asf0afvs.length); ActionFieldValue actionCol0asf0afv0 = actionCol0asf0afvs[0]; assertEquals("discount", actionCol0asf0afv0.getField()); assertEquals("param7", actionCol0asf0afv0.getValue()); assertEquals(FieldNatureType.TYPE_TEMPLATE, actionCol0asf0afv0.getNature()); assertEquals(DataType.TYPE_NUMERIC_DOUBLE, actionCol0asf0afv0.getType()); BRLActionVariableColumn actionCol0param0 = actionCol0.getChildColumns().get(0); assertEquals("param7", actionCol0param0.getVarName()); assertEquals("Discount(%)", actionCol0param0.getHeader()); assertEquals(DataType.TYPE_NUMERIC_DOUBLE, actionCol0param0.getFieldType()); assertEquals("Vehicle", actionCol0param0.getFactType()); assertEquals("discount", actionCol0param0.getFactField()); assertEquals(4, dtable.getData().size()); assertTrue(isRowEquivalent(new Object[]{1, "", "1", "ALL", "XYZ", "EL", "HighEnd", 1, 0, 1.75d}, dtable.getData().get(0))); assertTrue(isRowEquivalent(new Object[]{2, "", "2", "ALL", "XYZ", "EL", "HighEnd", 5, 1, 2.00d}, dtable.getData().get(1))); assertTrue(isRowEquivalent(new Object[]{3, "", "3", "ALL", "XYZ", "EL", "HighEnd", 7, 5, 2.00d}, dtable.getData().get(2))); assertTrue(isRowEquivalent(new Object[]{4, "", "4", "ALL", "XYZ", "EL", "HighEnd", 10, 7, 1.00d}, dtable.getData().get(3))); }
public List<GuidedDecisionTable52> getGuidedDecisionTables() { return _dtables; }
GuidedDecisionTableGeneratorListener implements
        RuleSheetListener { public List<GuidedDecisionTable52> getGuidedDecisionTables() { return _dtables; } }
GuidedDecisionTableGeneratorListener implements
        RuleSheetListener { public List<GuidedDecisionTable52> getGuidedDecisionTables() { return _dtables; } GuidedDecisionTableGeneratorListener(final ConversionResult conversionResult,
                                                final PackageDataModelOracle _dmo); }
GuidedDecisionTableGeneratorListener implements
        RuleSheetListener { public List<GuidedDecisionTable52> getGuidedDecisionTables() { return _dtables; } GuidedDecisionTableGeneratorListener(final ConversionResult conversionResult,
                                                final PackageDataModelOracle _dmo); CaseInsensitiveMap getProperties(); Package getRuleSet(); List<Import> getImports(); List<Global> getGlobals(); List<String> getFunctions(); List<String> getQueries(); List<String> getTypeDeclarations(); List<GuidedDecisionTable52> getGuidedDecisionTables(); void startSheet(final String name); void finishSheet(); void newRow(final int rowNumber,
                       final int columns); void newCell(final int row,
                        final int column,
                        final String value,
                        int mergedColStart); }
GuidedDecisionTableGeneratorListener implements
        RuleSheetListener { public List<GuidedDecisionTable52> getGuidedDecisionTables() { return _dtables; } GuidedDecisionTableGeneratorListener(final ConversionResult conversionResult,
                                                final PackageDataModelOracle _dmo); CaseInsensitiveMap getProperties(); Package getRuleSet(); List<Import> getImports(); List<Global> getGlobals(); List<String> getFunctions(); List<String> getQueries(); List<String> getTypeDeclarations(); List<GuidedDecisionTable52> getGuidedDecisionTables(); void startSheet(final String name); void finishSheet(); void newRow(final int rowNumber,
                       final int columns); void newCell(final int row,
                        final int column,
                        final String value,
                        int mergedColStart);  }