use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode in project kie-wb-common by kiegroup.
the class DMNIncludedNodeFactoryTest method testMakeDMNIncludedModel.
@Test
public void testMakeDMNIncludedModel() {
final DMNIncludedNodeFactory factory = mock(DMNIncludedNodeFactory.class);
final String path = "path";
final IncludedModel includedModel = mock(IncludedModel.class);
final DRGElement drgElement = mock(DRGElement.class);
final DRGElement elementWithNamespace = mock(DRGElement.class);
doCallRealMethod().when(factory).makeDMNIncludeNode(path, includedModel, drgElement);
when(factory.drgElementWithNamespace(drgElement, includedModel)).thenReturn(elementWithNamespace);
final DMNIncludedNode includedNode = factory.makeDMNIncludeNode(path, includedModel, drgElement);
verify(factory).drgElementWithNamespace(drgElement, includedModel);
assertEquals(path, includedNode.getFileName());
assertEquals(elementWithNamespace, includedNode.getDrgElement());
}
use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode in project kie-wb-common by kiegroup.
the class DMNMarshallerImportsClientHelper method loadNodes.
private Promise<List<DMNIncludedNode>> loadNodes(final Map<String, JSITDefinitions> existingDefinitions, final DMNIncludedModel model, final List<DMNIncludedNode> result) {
String filePath = "";
for (final Map.Entry<String, JSITDefinitions> entry : existingDefinitions.entrySet()) {
filePath = entry.getKey();
final JSITDefinitions definitions = Js.uncheckedCast(entry.getValue());
if (Objects.equals(model.getNamespace(), definitions.getNamespace())) {
break;
}
}
if (isEmpty(filePath)) {
return promises.resolve();
}
final String path = filePath;
return dmnImportsContentService.loadFile(path).then(content -> promises.create((success, fail) -> dmnImportsService.getDRGElements(content, new ServiceCallback<List<DRGElement>>() {
@Override
public void onSuccess(final List<DRGElement> drgElements) {
final List<DMNIncludedNode> nodes = drgElements.stream().map(node -> includedModelFactory.makeDMNIncludeNode(path, model, node)).collect(Collectors.toList());
result.addAll(nodes);
success.onInvoke(nodes);
}
@Override
public void onError(final ClientRuntimeError error) {
LOGGER.log(Level.SEVERE, error.getMessage());
fail.onInvoke(error);
}
})));
}
Aggregations