GuidedRuleEditorPresenter extends KieEditor<RuleModel> { protected void loadContent() { view.showLoading(); getService().call(getModelSuccessCallback(), getNoSuchFileExceptionErrorCallback()).loadContent(getVersionRecordManager().getCurrentPath()); } @Inject  GuidedRuleEditorPresenter(final GuidedRuleEditorView view); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @Override void onSourceTabSelected(); void handleImportAddedEvent(@Observes ImportAddedEvent event); void handleImportRemovedEvent(@Observes ImportRemovedEvent event); @OnClose @Override void onClose(); @OnMayClose boolean mayClose(); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartTitleDecoration IsWidget getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); static final String EDITOR_ID; }
@Test public void testLoadContentSuccess() throws Exception { final RuleModellerActionPlugin pluginOne = mock(RuleModellerActionPlugin.class); final RuleModellerActionPlugin pluginTwo = mock(RuleModellerActionPlugin.class); doAnswer(invocationOnMock -> { final Consumer<RuleModellerActionPlugin> consumer = invocationOnMock.getArgumentAt(0, Consumer.class); consumer.accept(pluginOne); consumer.accept(pluginTwo); return null; }).when(actionPluginInstance).forEach(any()); presenter.loadContent(); verify(kieEditorWrapperView).clear(); verify(kieEditorWrapperView).addMainEditorPage(view); verify(kieEditorWrapperView).addOverviewPage(any(), any()); verify(kieEditorWrapperView).addImportsTab(eq(importsWidgetPresenter)); verify(kieEditorWrapperView).addSourcePage(any()); verify(oracleFactory).makeAsyncPackageDataModelOracle(resourcePath, ruleModel, payload); verify(overviewWidgetPresenter).setContent(overview, resourcePath); verify(importsWidgetPresenter).setContent(oracle, imports, false); verify(view).hideBusyIndicator(); verify(view).setContent(eq(ruleModel), pluginsListCaptor.capture(), eq(oracle), eq(ruleNamesServiceCaller), eq(false), eq(false)); Assertions.assertThat(pluginsListCaptor.getValue()).containsExactly(pluginOne, pluginTwo); }
@Test public void testLoadContentFail() throws Exception { doThrow(new RuntimeException()).when(service).loadContent(resourcePath); presenter.loadContent(); verify(kieEditorWrapperView, never()).clear(); verify(kieEditorWrapperView, never()).addMainEditorPage(view); verify(kieEditorWrapperView, never()).addOverviewPage(any(), any()); verify(kieEditorWrapperView, never()).addImportsTab(any()); verify(kieEditorWrapperView, never()).addSourcePage(any()); verify(oracleFactory, never()).makeAsyncPackageDataModelOracle(resourcePath, ruleModel, payload); verify(overviewWidgetPresenter, never()).setContent(overview, resourcePath); verify(importsWidgetPresenter, never()).setContent(oracle, imports, false); verify(view).hideBusyIndicator(); }