use of org.kie.workbench.common.stunner.core.definition.exception.DefinitionNotFoundException in project kie-wb-common by kiegroup.
the class ProjectDiagramEditorTest method testLoadContentError.
@Test
public void testLoadContentError() {
ArgumentCaptor<ServiceCallback> callbackArgumentCaptor = forClass(ServiceCallback.class);
tested.loadContent();
verify(projectDiagramServices, times(1)).getByPath(eq(path), callbackArgumentCaptor.capture());
callbackArgumentCaptor.getValue().onError(new ClientRuntimeError(new DefinitionNotFoundException()));
verify(placeManager, times(1)).forceClosePlace(any(PathPlaceRequest.class));
ArgumentCaptor<Consumer> consumerArgumentCaptor = forClass(Consumer.class);
verify(diagramClientErrorHandler, times(1)).handleError(any(ClientRuntimeError.class), consumerArgumentCaptor.capture());
consumerArgumentCaptor.getValue().accept("error message");
verify(errorPopupPresenter, times(1)).showMessage("error message");
}
use of org.kie.workbench.common.stunner.core.definition.exception.DefinitionNotFoundException in project kie-wb-common by kiegroup.
the class DiagramClientErrorHandlerTest method handleErrorTest.
@Test
public void handleErrorTest() {
reset(clientRuntimeError);
when(clientRuntimeError.getThrowable()).thenReturn(new DefinitionNotFoundException("Error", DEFINITION_ID));
diagramClientErrorHandler.handleError(clientRuntimeError, message -> Assert.assertEquals(ERROR_MESSAGE, message));
when(clientRuntimeError.getThrowable()).thenReturn(new RuntimeException());
when(clientRuntimeError.toString()).thenReturn("runtime");
diagramClientErrorHandler.handleError(clientRuntimeError, message -> Assert.assertEquals("runtime", message));
}
use of org.kie.workbench.common.stunner.core.definition.exception.DefinitionNotFoundException in project kie-wb-common by kiegroup.
the class BPMNGraphObjectBuilderFactory method builderFor.
@Override
@SuppressWarnings("all")
public GraphObjectBuilder<?, ?> builderFor(final String oryxId) {
if (oryxId == null) {
throw new NullPointerException();
}
final Class<?> defClass = oryxManager.getMappingsManager().getDefinition(oryxId);
if (null != defClass) {
final String defId = oryxManager.getMappingsManager().getDefinitionId(oryxId);
if (ServiceTask.class.equals(defClass)) {
return new ServiceTaskNodeBuilder(defId, workItemDefinitionRegistries);
}
MorphAdapter<Object> morphAdapter = definitionManager.adapters().registry().getMorphAdapter(defClass);
BindablePropertyMorphDefinition propertyMorphDefinition = null;
if (null != morphAdapter) {
final Iterable<MorphDefinition> morphDefinitions = ((BindableMorphAdapter<Object>) morphAdapter).getMorphDefinitionsForType(defClass);
if (null != morphDefinitions && morphDefinitions.iterator().hasNext()) {
for (MorphDefinition morphDefinition : morphDefinitions) {
if (morphDefinition instanceof BindablePropertyMorphDefinition) {
propertyMorphDefinition = (BindablePropertyMorphDefinition) morphDefinition;
break;
}
}
}
}
if (null != propertyMorphDefinition) {
// Specific handle for morphing based on class inheritance.
return new NodePropertyMorphBuilderImpl(defClass, propertyMorphDefinition);
} else {
Class<? extends ElementFactory> elementFactory = BackendDefinitionAdapter.getGraphFactory(defClass);
if (isNodeFactory(elementFactory)) {
return new NodeBuilderImpl(defClass, defId);
} else if (isEdgeFactory(elementFactory)) {
return new EdgeBuilderImpl(defClass);
} else {
throw new RuntimeException("No graph element found for definition with class [" + defClass.getName() + "]");
}
}
}
throw new DefinitionNotFoundException("No definition found for oryx stencil with id [" + oryxId + "]", oryxId);
}
use of org.kie.workbench.common.stunner.core.definition.exception.DefinitionNotFoundException in project kie-wb-common by kiegroup.
the class StunnerEditor method handleError.
public void handleError(final ClientRuntimeError error) {
final Throwable e = error.getThrowable();
if (e instanceof DiagramParsingException) {
final DiagramParsingException dpe = (DiagramParsingException) e;
close();
parsingExceptionProcessor.accept(dpe);
xmlEditorView = xmlEditorViews.get();
xmlEditorView.setReadOnly(isReadOnly());
xmlEditorView.setContent(dpe.getXml(), AceEditorMode.XML);
resetContentHash();
view.setWidget(xmlEditorView.asWidget());
Scheduler.get().scheduleDeferred(xmlEditorView::onResize);
} else {
String message = null;
if (e instanceof DefinitionNotFoundException) {
final DefinitionNotFoundException dnfe = (DefinitionNotFoundException) e;
message = translationService.getValue(CoreTranslationMessages.DIAGRAM_LOAD_FAIL_UNSUPPORTED_ELEMENTS, dnfe.getDefinitionId());
} else {
message = error.getThrowable() != null ? error.getThrowable().getMessage() : error.getMessage();
}
showError(message);
exceptionProcessor.accept(error.getThrowable());
}
}
Aggregations