use of org.drools.workbench.screens.guided.dtable.shared.XLSConversionResult in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorPresenterTest method showConversionMessage.
@Test
public void showConversionMessage() {
doReturn(new XLSConversionResult("failed")).when(dtService).convert(any());
presenter.onConvert();
verify(view, never()).showConversionSuccess(anySet());
verify(view).showConversionErrorMessage("failed");
}
use of org.drools.workbench.screens.guided.dtable.shared.XLSConversionResult in project drools-wb by kiegroup.
the class DecisionTableGuidedToDecisionTableXLSConverterTest method failureOnConversion.
@Test
public void failureOnConversion() throws IOException {
final Path path = PathFactory.newPath("file.gdst", "file:///contextpath/file.gdst");
final GuidedDecisionTable52 table52 = new GuidedDecisionTable52();
final AttributeCol52 attributeCol52 = new AttributeCol52();
attributeCol52.setAttribute(Attribute.NEGATE_RULE.getAttributeName());
table52.getAttributeCols().add(attributeCol52);
doReturn(mock(PackageDataModelOracle.class)).when(dataModelService).getDataModel(any());
doReturn(table52).when(guidedDecisionTableEditorService).load(path);
final XLSConversionResult convert = converter.convert(path);
assertNotNull(convert);
verify(decisionTableXLSService, never()).create(any(), any(ByteArrayInputStream.class), any(), any());
assertFalse(convert.isConverted());
}
use of org.drools.workbench.screens.guided.dtable.shared.XLSConversionResult in project drools-wb by kiegroup.
the class DecisionTableGuidedToDecisionTableXLSConverterTest method fileExists.
@Test
public void fileExists() throws IOException {
final Path path = PathFactory.newPath("file.gdst", "file:///contextpath/file.gdst");
final GuidedDecisionTable52 table52 = new GuidedDecisionTable52();
doReturn(mock(PackageDataModelOracle.class)).when(dataModelService).getDataModel(any());
doReturn(table52).when(guidedDecisionTableEditorService).load(path);
doReturn("id").when(sessionInfo).getId();
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
final org.uberfire.java.nio.file.Path proposedPath = (org.uberfire.java.nio.file.Path) invocation.getArguments()[0];
return Objects.equals("file.gdst export.xls", Paths.convert(proposedPath).getFileName());
}
}).when(ioService).exists(any());
final XLSConversionResult convert = converter.convert(path);
assertNotNull(convert);
verify(decisionTableXLSService).create(pathArgumentCaptor.capture(), any(ByteArrayInputStream.class), any(), any());
final Path value = pathArgumentCaptor.getValue();
assertEquals("file.gdst export (1).xls", value.getFileName());
}
use of org.drools.workbench.screens.guided.dtable.shared.XLSConversionResult in project drools-wb by kiegroup.
the class DecisionTableGuidedToDecisionTableXLSConverterTest method convertEmptyTable.
@Test
public void convertEmptyTable() throws IOException {
final Path path = PathFactory.newPath("file.gdst", "file:///contextpath/file.gdst");
final GuidedDecisionTable52 table52 = new GuidedDecisionTable52();
doReturn(mock(PackageDataModelOracle.class)).when(dataModelService).getDataModel(any());
doReturn(table52).when(guidedDecisionTableEditorService).load(path);
doReturn("id").when(sessionInfo).getId();
final XLSConversionResult convert = converter.convert(path);
assertNotNull(convert);
verify(decisionTableXLSService).create(any(), any(ByteArrayInputStream.class), eq("id"), eq("Converted from file.gdst"));
}
use of org.drools.workbench.screens.guided.dtable.shared.XLSConversionResult in project drools-wb by kiegroup.
the class XLSBuilder method build.
public BuildResult build() {
try {
checkHitPolicy();
makeRuleSet();
makeImports();
makeDeclare();
makeTable();
} catch (final UnsupportedOperationException e) {
return new BuildResult(workbook, new XLSConversionResult(e.getMessage()));
} catch (final Exception e) {
return new BuildResult(workbook, new XLSConversionResult(e.toString() + " : " + e.getMessage()));
}
final XLSConversionResult conversionResult = new XLSConversionResult();
for (final XLSConversionResultMessage notification : notifications) {
conversionResult.addInfoMessage(notification);
}
return new BuildResult(workbook, conversionResult);
}
Aggregations