use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionMessage in project drools-wb by kiegroup.
the class DecisionTableXLSServiceImplCDITest method testConvertStaticFields.
@Test
public void testConvertStaticFields() throws Exception {
final String resourcePath = "dtables/src/main/resources/guvnor/feature/dtables/StaticFieldsTable.xls";
final ConversionResult conversionResult = convertResource(resourcePath);
final List<ConversionMessage> messages = conversionResult.getMessages();
Assertions.assertThat(messages).hasSize(2);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(messages.get(0).getMessage()).isEqualTo("Unable to convert value 'Message.GOODBYE' to NUMERIC_INTEGER. Cell (F11)");
softly.assertThat(messages.get(1).getMessage()).startsWith("Created Guided Decision Table 'StaticFieldsTable (converted on");
softly.assertThat(messages.get(1).getMessage()).endsWith(").gdst'");
});
}
use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionMessage in project drools-wb by kiegroup.
the class DecisionTableXLSServiceImplCDITest method testConvertFunctionAndBigDecimal.
/**
* Covers RHBA-48 - BigDecimal fields in table
*/
@Test
public void testConvertFunctionAndBigDecimal() throws Exception {
final String resourcePath = "dtables/src/main/resources/guvnor/feature/dtables/FunctionAndBigDecimalTable.xls";
final ConversionResult conversionResult = convertResource(resourcePath);
final List<ConversionMessage> messages = conversionResult.getMessages();
Assertions.assertThat(messages).hasSize(1);
final String message = messages.get(0).getMessage();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(message).startsWith("Created Guided Decision Table 'FunctionAndBigDecimalTable (converted on");
softly.assertThat(message).endsWith(").gdst'");
});
}
use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionMessage in project drools-wb by kiegroup.
the class DecisionTableXLSServiceImplCDITest method testConvertFunctionInSpreadhseet.
@Test
public void testConvertFunctionInSpreadhseet() throws Exception {
final String resourcePath = "dtables/src/main/resources/guvnor/feature/dtables/test_functions.xls";
final ConversionResult conversionResult = convertResource(resourcePath);
final List<ConversionMessage> messages = conversionResult.getMessages();
Assertions.assertThat(messages).hasSize(2);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(messages.get(0).getMessage()).startsWith("Created Function 'Function 1").endsWith(".drl'");
softly.assertThat(messages.get(1).getMessage()).startsWith("Created Guided Decision Table 'Hello RuleTable").endsWith(").gdst'");
});
}
use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionMessage in project drools-wb by kiegroup.
the class DecisionTableXLSToDecisionTableGuidedConverterTest method checkConversionOfXLSXFilesRHDM1159.
@Test
public void checkConversionOfXLSXFilesRHDM1159() {
final InputStream is = this.getClass().getResourceAsStream("RHDM-1159.xls");
when(ioService.newInputStream(any(org.uberfire.java.nio.file.Path.class))).thenReturn(is);
// Mock imports to match project attached to JIRA
final ProjectImports projectImports = new ProjectImports();
projectImports.getImports().addImport(new Import("com.aia.model.underWriting.Benefit"));
projectImports.getImports().addImport(new Import("com.aia.model.underWriting.Plans"));
projectImports.getImports().addImport(new Import("com.aia.model.underWriting.CaseInfo"));
projectImports.getImports().addImport(new Import("com.aia.model.underWriting.UnderwritingRuleRequest"));
projectImports.getImports().addImport(new Import("com.aia.model.underWriting.UnderwritingRuleResponse"));
doReturn(projectImports).when(converter).loadProjectImports(eq(expectedProjectImportsPath));
final ConversionResult result = converter.convert(path);
assertNotNull(result);
final List<ConversionMessage> messages = result.getMessages();
assertEquals(1, messages.size());
assertTrue(messages.get(0).getMessage().startsWith("Created Guided Decision Table 'SampleAUWRule"));
verify(guidedDecisionTableService, times(1)).create(any(Path.class), any(String.class), decisionTableArgumentCaptor.capture(), any(String.class));
final GuidedDecisionTable52 dtable = decisionTableArgumentCaptor.getValue();
assertNotNull(dtable);
// Check attributes
final List<AttributeCol52> attributes = dtable.getAttributeCols();
assertEquals(1, attributes.size());
assertEquals(Attribute.RULEFLOW_GROUP.getAttributeName(), attributes.get(0).getAttribute());
// Check LHS
final List<CompositeColumn<? extends BaseColumn>> conditions = dtable.getConditions();
assertEquals(3, conditions.size());
assertTrue(conditions.get(0) instanceof BRLConditionColumn);
final BRLConditionColumn condition0 = (BRLConditionColumn) conditions.get(0);
assertEquals(1, condition0.getDefinition().size());
assertTrue(condition0.getDefinition().get(0) instanceof FactPattern);
final FactPattern condition0FactPattern = (FactPattern) condition0.getDefinition().get(0);
assertEquals("UnderwritingRuleRequest", condition0FactPattern.getFactType());
assertEquals(1, condition0FactPattern.getNumberOfConstraints());
final FieldConstraint condition0FactPatternConstraint = condition0FactPattern.getConstraint(0);
assertTrue(condition0FactPatternConstraint instanceof SingleFieldConstraint);
final SingleFieldConstraint condition0FactPatternSingleFieldConstraint = (SingleFieldConstraint) condition0FactPattern.getConstraint(0);
assertEquals("traceId", condition0FactPatternSingleFieldConstraint.getFieldName());
assertEquals("==", condition0FactPatternSingleFieldConstraint.getOperator());
assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, condition0FactPatternSingleFieldConstraint.getConstraintValueType());
assertEquals("param1", condition0FactPatternSingleFieldConstraint.getValue());
assertEquals(1, condition0.getChildColumns().size());
final BRLConditionVariableColumn condition0Variable = condition0.getChildColumns().get(0);
assertEquals("param1", condition0Variable.getVarName());
assertEquals("UnderwritingRuleRequest", condition0Variable.getFactType());
assertEquals("traceId", condition0Variable.getFactField());
assertTrue(conditions.get(1) instanceof BRLConditionColumn);
final BRLConditionColumn condition1 = (BRLConditionColumn) conditions.get(1);
assertEquals(1, condition1.getDefinition().size());
assertTrue(condition1.getDefinition().get(0) instanceof FromCompositeFactPattern);
final FromCompositeFactPattern condition1FromCompositeFactPattern = (FromCompositeFactPattern) condition1.getDefinition().get(0);
final FactPattern condition1FactPattern = condition1FromCompositeFactPattern.getFactPattern();
assertEquals("CaseInfo", condition1FactPattern.getFactType());
assertEquals(1, condition1FactPattern.getNumberOfConstraints());
final FieldConstraint condition1FactPatternConstraint = condition1FactPattern.getConstraint(0);
assertTrue(condition1FactPatternConstraint instanceof SingleFieldConstraint);
final SingleFieldConstraint condition1FactPatternSingleFieldConstraint = (SingleFieldConstraint) condition1FactPattern.getConstraint(0);
assertEquals("channel", condition1FactPatternSingleFieldConstraint.getFieldName());
assertEquals("in", condition1FactPatternSingleFieldConstraint.getOperator());
assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, condition1FactPatternSingleFieldConstraint.getConstraintValueType());
assertEquals("param2", condition1FactPatternSingleFieldConstraint.getValue());
assertEquals(1, condition1.getChildColumns().size());
final BRLConditionVariableColumn condition1Variable = condition1.getChildColumns().get(0);
assertEquals("param2", condition1Variable.getVarName());
assertEquals("CaseInfo", condition1Variable.getFactType());
assertEquals("channel", condition1Variable.getFactField());
assertTrue(conditions.get(2) instanceof BRLConditionColumn);
final BRLConditionColumn condition2 = (BRLConditionColumn) conditions.get(2);
assertEquals(1, condition2.getDefinition().size());
assertTrue(condition2.getDefinition().get(0) instanceof FreeFormLine);
final FreeFormLine condition2FreeFormLine = (FreeFormLine) condition2.getDefinition().get(0);
assertEquals("plan :Plans();bn:Benefit(benefitCode in (\"@{param3}\")) from plan.benefit;\n", condition2FreeFormLine.getText());
assertEquals(1, condition2.getChildColumns().size());
final BRLConditionVariableColumn condition2Variable = condition2.getChildColumns().get(0);
assertEquals("param3", condition2Variable.getVarName());
assertEquals("Benefit", condition2Variable.getFactType());
assertEquals("benefitCode", condition2Variable.getFactField());
// Check RHS
final List<ActionCol52> actions = dtable.getActionCols();
assertEquals(1, actions.size());
assertTrue(actions.get(0) instanceof BRLActionColumn);
final BRLActionColumn action0 = (BRLActionColumn) actions.get(0);
assertTrue(action0.getDefinition().get(0) instanceof FreeFormLine);
final FreeFormLine action0FreeFormLine = (FreeFormLine) action0.getDefinition().get(0);
assertEquals("UnderwritingRuleResponse uwr= new UnderwritingRuleResponse();uwr.setAuwStatus(@{param4});", action0FreeFormLine.getText());
assertEquals(1, action0.getChildColumns().size());
final BRLActionVariableColumn action0Variable = action0.getChildColumns().get(0);
assertEquals("param4", action0Variable.getVarName());
// Check data
final List<List<DTCellValue52>> data = dtable.getData();
assertEquals(5, data.size());
assertRHDM1159RowData(data.get(0), "abc", "AGENT", "RB", "\"FAIL\"");
assertRHDM1159RowData(data.get(1), "sdf", "AGENT", "RB", "\"FAIL\"");
assertRHDM1159RowData(data.get(2), "dsds", "AGENT", "RB", "\"FAIL\"");
assertRHDM1159RowData(data.get(3), "sdddv", "AGENT", "RB", "\"FAIL\"");
assertRHDM1159RowData(data.get(4), "", "", "", "");
}
use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionMessage in project drools-wb by kiegroup.
the class DecisionTableXLSEditorPresenter method convert.
private void convert() {
busyIndicatorView.showBusyIndicator(DecisionTableXLSEditorConstants.INSTANCE.Converting());
decisionTableXLSService.call(new RemoteCallback<ConversionResult>() {
@Override
public void callback(final ConversionResult response) {
busyIndicatorView.hideBusyIndicator();
if (response.getMessages().size() > 0) {
final PopupListWidget popup = new PopupListWidget();
for (ConversionMessage message : response.getMessages()) {
popup.addListMessage(convertMessageType(message.getMessageType()), message.getMessage());
}
popup.show();
}
}
}).convert(versionRecordManager.getCurrentPath());
}
Aggregations