target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void testDelete() { presenter.delete(); verify( view ).delete(); } | public void delete() { view.delete(); } | ContainerCardPresenter { public void delete() { view.delete(); } } | ContainerCardPresenter { public void delete() { view.delete(); } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); } | ContainerCardPresenter { public void delete() { view.delete(); } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); View getView(); void setup( final ServerInstanceKey serverInstanceKey,
final Container container ); void delete(); void updateContent( final ServerInstanceKey serverInstanceKey,
final Container container ); } | ContainerCardPresenter { public void delete() { view.delete(); } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); View getView(); void setup( final ServerInstanceKey serverInstanceKey,
final Container container ); void delete(); void updateContent( final ServerInstanceKey serverInstanceKey,
final Container container ); } |
@Test public void testSetup() { final LinkTitlePresenter linkTitlePresenter = spy( new LinkTitlePresenter( mock( LinkTitlePresenter.View.class ) ) ); when( linkTitlePresenterProvider.get() ).thenReturn( linkTitlePresenter ); final BodyPresenter bodyPresenter = mock( BodyPresenter.class ); when( bodyPresenterProvider.get() ).thenReturn( bodyPresenter ); final FooterPresenter footerPresenter = mock( FooterPresenter.class ); when( footerPresenterProvider.get() ).thenReturn( footerPresenter ); final CardPresenter.View cardPresenterView = mock( CardPresenter.View.class ); final CardPresenter cardPresenter = spy( new CardPresenter( cardPresenterView ) ); when( cardPresenterProvider.get() ).thenReturn( cardPresenter ); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "templateId", "serverName", "serverInstanceId", "url" ); final Message message = new Message( Severity.INFO, "testMessage" ); final ReleaseId resolvedReleasedId = new ReleaseId( "org.kie", "container", "1.0.0" ); final Container container = new Container( "containerSpecId", "containerName", serverInstanceKey, Collections.singletonList( message ), resolvedReleasedId, null ); presenter.setup( serverInstanceKey, container ); verify( linkTitlePresenter ).setup( eq( serverInstanceKey.getServerName() ), any( Command.class ) ); verify( bodyPresenter ).setup( Arrays.asList( message ) ); verify( footerPresenter ).setup( container.getUrl(), resolvedReleasedId.getVersion() ); verify( cardPresenter ).addTitle( linkTitlePresenter ); verify( cardPresenter ).addBody( bodyPresenter ); verify( cardPresenter ).addFooter( footerPresenter ); verify( view ).setCard( cardPresenterView ); linkTitlePresenter.onSelect(); verify( remoteServerSelectedEvent ).fire( eq( new ServerInstanceSelected( serverInstanceKey ) ) ); } | public void setup( final ServerInstanceKey serverInstanceKey, final Container container ) { linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); updateContent( serverInstanceKey, container ); final CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } | ContainerCardPresenter { public void setup( final ServerInstanceKey serverInstanceKey, final Container container ) { linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); updateContent( serverInstanceKey, container ); final CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } } | ContainerCardPresenter { public void setup( final ServerInstanceKey serverInstanceKey, final Container container ) { linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); updateContent( serverInstanceKey, container ); final CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); } | ContainerCardPresenter { public void setup( final ServerInstanceKey serverInstanceKey, final Container container ) { linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); updateContent( serverInstanceKey, container ); final CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); View getView(); void setup( final ServerInstanceKey serverInstanceKey,
final Container container ); void delete(); void updateContent( final ServerInstanceKey serverInstanceKey,
final Container container ); } | ContainerCardPresenter { public void setup( final ServerInstanceKey serverInstanceKey, final Container container ) { linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); updateContent( serverInstanceKey, container ); final CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); View getView(); void setup( final ServerInstanceKey serverInstanceKey,
final Container container ); void delete(); void updateContent( final ServerInstanceKey serverInstanceKey,
final Container container ); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init(this); } | ContainerStatusEmptyPresenter { @PostConstruct public void init() { view.init(this); } } | ContainerStatusEmptyPresenter { @PostConstruct public void init() { view.init(this); } @Inject ContainerStatusEmptyPresenter(final View view,
final Event<RefreshRemoteServers> refreshRemoteServersEvent); } | ContainerStatusEmptyPresenter { @PostConstruct public void init() { view.init(this); } @Inject ContainerStatusEmptyPresenter(final View view,
final Event<RefreshRemoteServers> refreshRemoteServersEvent); @PostConstruct void init(); View getView(); void setup(final ContainerSpecKey containerSpecKey); void refresh(); } | ContainerStatusEmptyPresenter { @PostConstruct public void init() { view.init(this); } @Inject ContainerStatusEmptyPresenter(final View view,
final Event<RefreshRemoteServers> refreshRemoteServersEvent); @PostConstruct void init(); View getView(); void setup(final ContainerSpecKey containerSpecKey); void refresh(); } |
@Test public void testRefresh() { final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "id", "name", new ServerTemplateKey() ); presenter.setup( containerSpecKey ); presenter.refresh(); final ArgumentCaptor<RefreshRemoteServers> refreshRemoteServersCaptor = ArgumentCaptor.forClass( RefreshRemoteServers.class ); verify( refreshRemoteServersEvent ).fire( refreshRemoteServersCaptor.capture() ); assertEquals( containerSpecKey, refreshRemoteServersCaptor.getValue().getContainerSpecKey() ); } | public void refresh() { refreshRemoteServersEvent.fire(new RefreshRemoteServers(containerSpecKey)); } | ContainerStatusEmptyPresenter { public void refresh() { refreshRemoteServersEvent.fire(new RefreshRemoteServers(containerSpecKey)); } } | ContainerStatusEmptyPresenter { public void refresh() { refreshRemoteServersEvent.fire(new RefreshRemoteServers(containerSpecKey)); } @Inject ContainerStatusEmptyPresenter(final View view,
final Event<RefreshRemoteServers> refreshRemoteServersEvent); } | ContainerStatusEmptyPresenter { public void refresh() { refreshRemoteServersEvent.fire(new RefreshRemoteServers(containerSpecKey)); } @Inject ContainerStatusEmptyPresenter(final View view,
final Event<RefreshRemoteServers> refreshRemoteServersEvent); @PostConstruct void init(); View getView(); void setup(final ContainerSpecKey containerSpecKey); void refresh(); } | ContainerStatusEmptyPresenter { public void refresh() { refreshRemoteServersEvent.fire(new RefreshRemoteServers(containerSpecKey)); } @Inject ContainerStatusEmptyPresenter(final View view,
final Event<RefreshRemoteServers> refreshRemoteServersEvent); @PostConstruct void init(); View getView(); void setup(final ContainerSpecKey containerSpecKey); void refresh(); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init(this); } | ServerContainerEmptyPresenter { @PostConstruct public void init() { view.init(this); } } | ServerContainerEmptyPresenter { @PostConstruct public void init() { view.init(this); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); } | ServerContainerEmptyPresenter { @PostConstruct public void init() { view.init(this); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); } | ServerContainerEmptyPresenter { @PostConstruct public void init() { view.init(this); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); } |
@Test public void testTemplate() { final ServerTemplate template = new ServerTemplate( "id", "name" ); presenter.setTemplate( template ); verify( view ).setTemplateName( template.getName() ); } | public void setTemplate(final ServerTemplate serverTemplate) { this.serverTemplate = checkNotNull("serverTemplate", serverTemplate); view.setTemplateName(serverTemplate.getName()); } | ServerContainerEmptyPresenter { public void setTemplate(final ServerTemplate serverTemplate) { this.serverTemplate = checkNotNull("serverTemplate", serverTemplate); view.setTemplateName(serverTemplate.getName()); } } | ServerContainerEmptyPresenter { public void setTemplate(final ServerTemplate serverTemplate) { this.serverTemplate = checkNotNull("serverTemplate", serverTemplate); view.setTemplateName(serverTemplate.getName()); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); } | ServerContainerEmptyPresenter { public void setTemplate(final ServerTemplate serverTemplate) { this.serverTemplate = checkNotNull("serverTemplate", serverTemplate); view.setTemplateName(serverTemplate.getName()); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); } | ServerContainerEmptyPresenter { public void setTemplate(final ServerTemplate serverTemplate) { this.serverTemplate = checkNotNull("serverTemplate", serverTemplate); view.setTemplateName(serverTemplate.getName()); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); } |
@Test public void testAddContainer() { presenter.addContainer(); verify( addNewContainerEvent ).fire( any( AddNewContainer.class ) ); } | public void addContainer() { addNewContainerEvent.fire(new AddNewContainer(serverTemplate)); } | ServerContainerEmptyPresenter { public void addContainer() { addNewContainerEvent.fire(new AddNewContainer(serverTemplate)); } } | ServerContainerEmptyPresenter { public void addContainer() { addNewContainerEvent.fire(new AddNewContainer(serverTemplate)); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); } | ServerContainerEmptyPresenter { public void addContainer() { addNewContainerEvent.fire(new AddNewContainer(serverTemplate)); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); } | ServerContainerEmptyPresenter { public void addContainer() { addNewContainerEvent.fire(new AddNewContainer(serverTemplate)); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); } |
@Test public void testGraphCommandExecuteWithNoColumns() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(0, relation.getRow().size()); } | @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } |
@Test public void testInit() { presenter.init(); verify(view).init(presenter); assertEquals(view, presenter.getView()); } | @PostConstruct public void init() { view.init(this); } | ContainerRulesConfigPresenter { @PostConstruct public void init() { view.init(this); } } | ContainerRulesConfigPresenter { @PostConstruct public void init() { view.init(this); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { @PostConstruct public void init() { view.init(this); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { @PostConstruct public void init() { view.init(this); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testSetup() { when(ruleConfig.getScannerStatus()).thenReturn(KieScannerStatus.STOPPED); when(ruleConfig.getPollInterval()).thenReturn(null); releaseId.setVersion("1.x"); presenter.setup(containerSpec, ruleConfig); verify(view).setContent(eq(""), eq("1.x"), eq(State.ENABLED), eq(State.DISABLED), eq(State.ENABLED), eq(State.ENABLED)); } | public void setup(final ContainerSpec containerSpec, final RuleConfig ruleConfig) { this.containerSpec = checkNotNull("containerSpec", containerSpec); setRuleConfig(ruleConfig, containerSpec.getReleasedId().getVersion()); } | ContainerRulesConfigPresenter { public void setup(final ContainerSpec containerSpec, final RuleConfig ruleConfig) { this.containerSpec = checkNotNull("containerSpec", containerSpec); setRuleConfig(ruleConfig, containerSpec.getReleasedId().getVersion()); } } | ContainerRulesConfigPresenter { public void setup(final ContainerSpec containerSpec, final RuleConfig ruleConfig) { this.containerSpec = checkNotNull("containerSpec", containerSpec); setRuleConfig(ruleConfig, containerSpec.getReleasedId().getVersion()); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void setup(final ContainerSpec containerSpec, final RuleConfig ruleConfig) { this.containerSpec = checkNotNull("containerSpec", containerSpec); setRuleConfig(ruleConfig, containerSpec.getReleasedId().getVersion()); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void setup(final ContainerSpec containerSpec, final RuleConfig ruleConfig) { this.containerSpec = checkNotNull("containerSpec", containerSpec); setRuleConfig(ruleConfig, containerSpec.getReleasedId().getVersion()); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testVersion() { final String version = "1.0"; presenter.setVersion(version); verify(view).setVersion(version); } | public void setVersion(final String version) { this.view.setVersion(version); } | ContainerRulesConfigPresenter { public void setVersion(final String version) { this.view.setVersion(version); } } | ContainerRulesConfigPresenter { public void setVersion(final String version) { this.view.setVersion(version); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void setVersion(final String version) { this.view.setVersion(version); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void setVersion(final String version) { this.view.setVersion(version); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testUpgrade() { final String version = "1.0"; presenter.setup(containerSpec, ruleConfig); presenter.upgrade(version); verify(view).disableActions(); final ArgumentCaptor<ReleaseId> releaseIdCaptor = ArgumentCaptor.forClass(ReleaseId.class); verify(ruleCapabilitiesService).upgradeContainer(eq(containerSpec), releaseIdCaptor.capture()); assertEquals(version, releaseIdCaptor.getValue().getVersion()); verify(view).setStartScannerState(State.ENABLED); verify(view).setStopScannerState(State.DISABLED); verify(view).setScanNowState(State.ENABLED); verify(view).setUpgradeState(State.ENABLED); verify(notification).fire(new NotificationEvent(SUCCESS_UPGRADE, NotificationEvent.NotificationType.SUCCESS)); } | public void upgrade(final String version) { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) { notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); } updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getUpgradeErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).upgradeContainer(containerSpec, new ReleaseId(containerSpec.getReleasedId().getGroupId(), containerSpec.getReleasedId().getArtifactId(), version)); } | ContainerRulesConfigPresenter { public void upgrade(final String version) { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) { notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); } updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getUpgradeErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).upgradeContainer(containerSpec, new ReleaseId(containerSpec.getReleasedId().getGroupId(), containerSpec.getReleasedId().getArtifactId(), version)); } } | ContainerRulesConfigPresenter { public void upgrade(final String version) { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) { notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); } updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getUpgradeErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).upgradeContainer(containerSpec, new ReleaseId(containerSpec.getReleasedId().getGroupId(), containerSpec.getReleasedId().getArtifactId(), version)); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void upgrade(final String version) { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) { notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); } updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getUpgradeErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).upgradeContainer(containerSpec, new ReleaseId(containerSpec.getReleasedId().getGroupId(), containerSpec.getReleasedId().getArtifactId(), version)); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void upgrade(final String version) { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) { notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); } updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getUpgradeErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).upgradeContainer(containerSpec, new ReleaseId(containerSpec.getReleasedId().getGroupId(), containerSpec.getReleasedId().getArtifactId(), version)); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testStopScanner() { presenter.stopScanner(); verify(view).disableActions(); verify(view).setStartScannerState(State.ENABLED); verify(view).setStopScannerState(State.DISABLED); verify(view).setScanNowState(State.ENABLED); verify(view).setUpgradeState(State.ENABLED); } | public void stopScanner() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).stopScanner(containerSpec); } | ContainerRulesConfigPresenter { public void stopScanner() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).stopScanner(containerSpec); } } | ContainerRulesConfigPresenter { public void stopScanner() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).stopScanner(containerSpec); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void stopScanner() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).stopScanner(containerSpec); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void stopScanner() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).stopScanner(containerSpec); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testScanNow() { presenter.scanNow(); verify(view).disableActions(); verify(view).setStartScannerState(State.ENABLED); verify(view).setStopScannerState(State.DISABLED); verify(view).setScanNowState(State.ENABLED); verify(view).setUpgradeState(State.ENABLED); } | public void scanNow() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getScanNowErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).scanNow(containerSpec); } | ContainerRulesConfigPresenter { public void scanNow() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getScanNowErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).scanNow(containerSpec); } } | ContainerRulesConfigPresenter { public void scanNow() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getScanNowErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).scanNow(containerSpec); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void scanNow() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getScanNowErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).scanNow(containerSpec); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void scanNow() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getScanNowErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).scanNow(containerSpec); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testStartScannerEmpty() { presenter.startScanner("", ContainerRulesConfigPresenter.MS); verify(view).errorOnInterval(); } | public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } | ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } } | ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testStartScanner() { presenter.setup(containerSpec, ruleConfig); final String interval = "1"; presenter.startScanner(interval, ContainerRulesConfigPresenter.MS); verify(view).disableActions(); verify(ruleCapabilitiesService).startScanner(eq(containerSpec), eq(Long.valueOf(interval))); verify(view).setStartScannerState(State.DISABLED); verify(view).setStopScannerState(State.ENABLED); verify(view).setScanNowState(State.DISABLED); verify(view).setUpgradeState(State.DISABLED); } | public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } | ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } } | ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testOnConfigUpdate() { final RuleConfigUpdated ruleConfigUpdated = new RuleConfigUpdated(); ruleConfigUpdated.setContainerSpecKey(containerSpec); ruleConfigUpdated.setRuleConfig(ruleConfig); presenter.setup(containerSpec, ruleConfig); presenter.onConfigUpdate(ruleConfigUpdated); verify(view, times(2)).setContent(anyString(), anyString(), any(State.class), any(State.class), any(State.class), any(State.class)); } | public void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated) { if (configUpdated != null && configUpdated.getContainerSpecKey() != null && configUpdated.getContainerSpecKey().equals(containerSpec)) { setup(containerSpec, configUpdated.getRuleConfig()); } else { logger.warn("Illegal event argument."); } } | ContainerRulesConfigPresenter { public void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated) { if (configUpdated != null && configUpdated.getContainerSpecKey() != null && configUpdated.getContainerSpecKey().equals(containerSpec)) { setup(containerSpec, configUpdated.getRuleConfig()); } else { logger.warn("Illegal event argument."); } } } | ContainerRulesConfigPresenter { public void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated) { if (configUpdated != null && configUpdated.getContainerSpecKey() != null && configUpdated.getContainerSpecKey().equals(containerSpec)) { setup(containerSpec, configUpdated.getRuleConfig()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated) { if (configUpdated != null && configUpdated.getContainerSpecKey() != null && configUpdated.getContainerSpecKey().equals(containerSpec)) { setup(containerSpec, configUpdated.getRuleConfig()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated) { if (configUpdated != null && configUpdated.getContainerSpecKey() != null && configUpdated.getContainerSpecKey().equals(containerSpec)) { setup(containerSpec, configUpdated.getRuleConfig()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testOnRuleConfigUpdate() { final RuleConfigUpdated ruleConfigUpdated = new RuleConfigUpdated(); ruleConfigUpdated.setRuleConfig(ruleConfig); ruleConfigUpdated.setReleasedId(releaseId); final Long poolInterval = 1l; when(ruleConfig.getPollInterval()).thenReturn(poolInterval); presenter.onRuleConfigUpdate(ruleConfigUpdated); verify(view).setContent(eq(String.valueOf(poolInterval)), anyString(), any(State.class), any(State.class), any(State.class), any(State.class)); } | public void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate) { if (configUpdate != null && configUpdate.getRuleConfig() != null && configUpdate.getReleasedId() != null) { setRuleConfig(configUpdate.getRuleConfig(), configUpdate.getReleasedId().getVersion()); } else { logger.warn("Illegal event argument."); } } | ContainerRulesConfigPresenter { public void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate) { if (configUpdate != null && configUpdate.getRuleConfig() != null && configUpdate.getReleasedId() != null) { setRuleConfig(configUpdate.getRuleConfig(), configUpdate.getReleasedId().getVersion()); } else { logger.warn("Illegal event argument."); } } } | ContainerRulesConfigPresenter { public void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate) { if (configUpdate != null && configUpdate.getRuleConfig() != null && configUpdate.getReleasedId() != null) { setRuleConfig(configUpdate.getRuleConfig(), configUpdate.getReleasedId().getVersion()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); } | ContainerRulesConfigPresenter { public void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate) { if (configUpdate != null && configUpdate.getRuleConfig() != null && configUpdate.getReleasedId() != null) { setRuleConfig(configUpdate.getRuleConfig(), configUpdate.getReleasedId().getVersion()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } | ContainerRulesConfigPresenter { public void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate) { if (configUpdate != null && configUpdate.getRuleConfig() != null && configUpdate.getReleasedId() != null) { setRuleConfig(configUpdate.getRuleConfig(), configUpdate.getReleasedId().getVersion()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); } |
@Test public void testGraphCommandUndoWithColumns() { relation.getColumn().add(new InformationItem()); final LiteralExpression literalExpression = new LiteralExpression(); literalExpression.getText().setValue(VALUE); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression)); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(1, relation.getColumn().size()); assertEquals(1, relation.getRow().size()); assertEquals(1, relation.getRow().get(0).getExpression().size()); assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0).getExpression()).getText().getValue()); } | @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); verify( view ).setProcessConfigView( processConfigPresenterView ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init( this ); view.setProcessConfigView( processConfigPresenter.getView() ); } | ContainerProcessConfigPresenter { @PostConstruct public void init() { view.init( this ); view.setProcessConfigView( processConfigPresenter.getView() ); } } | ContainerProcessConfigPresenter { @PostConstruct public void init() { view.init( this ); view.setProcessConfigView( processConfigPresenter.getView() ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); } | ContainerProcessConfigPresenter { @PostConstruct public void init() { view.init( this ); view.setProcessConfigView( processConfigPresenter.getView() ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } | ContainerProcessConfigPresenter { @PostConstruct public void init() { view.init( this ); view.setProcessConfigView( processConfigPresenter.getView() ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } |
@Test public void testDisable() { presenter.disable(); verify( view ).disable(); } | public void disable() { view.disable(); } | ContainerProcessConfigPresenter { public void disable() { view.disable(); } } | ContainerProcessConfigPresenter { public void disable() { view.disable(); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); } | ContainerProcessConfigPresenter { public void disable() { view.disable(); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } | ContainerProcessConfigPresenter { public void disable() { view.disable(); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } |
@Test public void testCancel() { presenter.cancel(); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfig ); } | public void cancel() { setupView( processConfigPresenter.getProcessConfig() ); } | ContainerProcessConfigPresenter { public void cancel() { setupView( processConfigPresenter.getProcessConfig() ); } } | ContainerProcessConfigPresenter { public void cancel() { setupView( processConfigPresenter.getProcessConfig() ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); } | ContainerProcessConfigPresenter { public void cancel() { setupView( processConfigPresenter.getProcessConfig() ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } | ContainerProcessConfigPresenter { public void cancel() { setupView( processConfigPresenter.getProcessConfig() ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } |
@Test public void testSave() { final String templateKey = "templateKey"; final String containerKey = "containerKey"; when( serverTemplateKey.getId() ).thenReturn( templateKey ); when( containerSpecKey.getId() ).thenReturn( containerKey ); when( view.getSaveSuccessMessage() ).thenReturn( "SUCCESS" ); presenter.save(); verify( notification ).fire( new NotificationEvent( "SUCCESS", NotificationEvent.NotificationType.SUCCESS ) ); verify( view ).disableActions(); verify( processConfigPresenter ).buildProcessConfig(); final ArgumentCaptor<ProcessConfig> processConfigCaptor = ArgumentCaptor.forClass( ProcessConfig.class ); verify( specManagementService ).updateContainerConfig( eq( templateKey ), eq( containerKey ), eq( Capability.PROCESS ), processConfigCaptor.capture() ); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfigCaptor.getValue() ); } | public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } | ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } } | ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); } | ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } | ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } |
@Test public void testSaveError() { final String templateKey = "templateKey"; final String containerKey = "containerKey"; when( serverTemplateKey.getId() ).thenReturn( templateKey ); when( containerSpecKey.getId() ).thenReturn( containerKey ); when( view.getSaveErrorMessage() ).thenReturn( "ERROR" ); doThrow( new RuntimeException() ).when( specManagementService ).updateContainerConfig( anyString(), anyString(), any( Capability.class ), any( ContainerConfig.class ) ); presenter.save(); verify( notification ).fire( new NotificationEvent( "ERROR", NotificationEvent.NotificationType.ERROR ) ); verify( view ).disableActions(); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfig ); } | public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } | ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } } | ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); } | ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } | ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } |
@Test public void testSetup() { final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "id", "container-name", new ServerTemplateKey( "template-id", "template-name" ) ); final ProcessConfig processConfig = new ProcessConfig( RuntimeStrategy.PER_REQUEST.toString(), "kbase", "ksession", MergeMode.KEEP_ALL.toString() ); presenter.setup( containerSpecKey, processConfig ); verify( view ).enableActions(); verify( processConfigPresenter ).setup( containerSpecKey, processConfig ); verify( processConfigPresenter ).setProcessConfig( processConfig ); } | public void setup( final ContainerSpecKey containerSpecKey, final ProcessConfig processConfig ) { this.processConfigPresenter.setup( containerSpecKey, processConfig ); setupView( processConfig ); } | ContainerProcessConfigPresenter { public void setup( final ContainerSpecKey containerSpecKey, final ProcessConfig processConfig ) { this.processConfigPresenter.setup( containerSpecKey, processConfig ); setupView( processConfig ); } } | ContainerProcessConfigPresenter { public void setup( final ContainerSpecKey containerSpecKey, final ProcessConfig processConfig ) { this.processConfigPresenter.setup( containerSpecKey, processConfig ); setupView( processConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); } | ContainerProcessConfigPresenter { public void setup( final ContainerSpecKey containerSpecKey, final ProcessConfig processConfig ) { this.processConfigPresenter.setup( containerSpecKey, processConfig ); setupView( processConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } | ContainerProcessConfigPresenter { public void setup( final ContainerSpecKey containerSpecKey, final ProcessConfig processConfig ) { this.processConfigPresenter.setup( containerSpecKey, processConfig ); setupView( processConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); } |
@Test public void testOnInstanceUpdatedWhenContainerSpecServerTemplateNotEqualServerInstanceUpdatedServerTemplate() { ServerInstanceUpdated serverInstanceUpdated = mock(ServerInstanceUpdated.class); ServerInstance serverInstance = mock(ServerInstance.class); when(serverInstanceUpdated.getServerInstance()).thenReturn(serverInstance); when(serverInstance.getServerTemplateId()).thenReturn(serverTemplateKey + "1"); presenter.onInstanceUpdated(serverInstanceUpdated); verify(runtimeManagementService, times(0)).getContainersByContainerSpec(any(), any()); } | public void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated) { if (instanceUpdated != null && containerSpec != null && containerSpec.getServerTemplateKey().getId().equals(instanceUpdated.getServerInstance().getServerTemplateId())) { load(containerSpec); } } | ContainerPresenter { public void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated) { if (instanceUpdated != null && containerSpec != null && containerSpec.getServerTemplateKey().getId().equals(instanceUpdated.getServerInstance().getServerTemplateId())) { load(containerSpec); } } } | ContainerPresenter { public void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated) { if (instanceUpdated != null && containerSpec != null && containerSpec.getServerTemplateKey().getId().equals(instanceUpdated.getServerInstance().getServerTemplateId())) { load(containerSpec); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated) { if (instanceUpdated != null && containerSpec != null && containerSpec.getServerTemplateKey().getId().equals(instanceUpdated.getServerInstance().getServerTemplateId())) { load(containerSpec); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated) { if (instanceUpdated != null && containerSpec != null && containerSpec.getServerTemplateKey().getId().equals(instanceUpdated.getServerInstance().getServerTemplateId())) { load(containerSpec); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testInit() { presenter.init(); verify(view).init(presenter); assertEquals(view, presenter.getView()); verify(view).setStatus(containerRemoteStatusPresenter.getView()); verify(view).setRulesConfig(containerRulesConfigPresenter.getView()); verify(view).setProcessConfig(containerProcessConfigPresenter.getView()); } | @PostConstruct public void init() { view.init(this); view.setStatus(containerRemoteStatusPresenter.getView()); view.setRulesConfig(containerRulesConfigPresenter.getView()); view.setProcessConfig(containerProcessConfigPresenter.getView()); } | ContainerPresenter { @PostConstruct public void init() { view.init(this); view.setStatus(containerRemoteStatusPresenter.getView()); view.setRulesConfig(containerRulesConfigPresenter.getView()); view.setProcessConfig(containerProcessConfigPresenter.getView()); } } | ContainerPresenter { @PostConstruct public void init() { view.init(this); view.setStatus(containerRemoteStatusPresenter.getView()); view.setRulesConfig(containerRulesConfigPresenter.getView()); view.setProcessConfig(containerProcessConfigPresenter.getView()); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { @PostConstruct public void init() { view.init(this); view.setStatus(containerRemoteStatusPresenter.getView()); view.setRulesConfig(containerRulesConfigPresenter.getView()); view.setProcessConfig(containerProcessConfigPresenter.getView()); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { @PostConstruct public void init() { view.init(this); view.setStatus(containerRemoteStatusPresenter.getView()); view.setRulesConfig(containerRulesConfigPresenter.getView()); view.setProcessConfig(containerProcessConfigPresenter.getView()); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testStartContainer() { presenter.loadContainers(containerSpecData); presenter.startContainer(); verify(view).setContainerStartState(State.ENABLED); verify(view).setContainerStopState(State.DISABLED); verify(view).disableRemoveButton(); verify(view).enableToggleActivationButton(); final String errorMessage = "ERROR"; when(view.getStartContainerErrorMessage()).thenReturn(errorMessage); doThrow(new RuntimeException()).when(specManagementService).startContainer(containerSpecData.getContainerSpec()); presenter.startContainer(); verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR)); verify(view, times(2)).setContainerStartState(State.DISABLED); verify(view, times(2)).setContainerStopState(State.ENABLED); verify(view, times(2)).enableRemoveButton(); } | public void startContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STARTED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STOPPED); return false; } }).startContainer(containerSpec); } | ContainerPresenter { public void startContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STARTED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STOPPED); return false; } }).startContainer(containerSpec); } } | ContainerPresenter { public void startContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STARTED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STOPPED); return false; } }).startContainer(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void startContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STARTED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STOPPED); return false; } }).startContainer(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void startContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STARTED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STOPPED); return false; } }).startContainer(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testStopContainer() { presenter.loadContainers(containerSpecData); presenter.stopContainer(); verify(view, times(2)).setContainerStartState(State.DISABLED); verify(view, times(2)).setContainerStopState(State.ENABLED); verify(view, times(2)).enableRemoveButton(); final String errorMessage = "ERROR"; when(view.getStopContainerErrorMessage()).thenReturn(errorMessage); doThrow(new RuntimeException()).when(specManagementService).stopContainer(containerSpecData.getContainerSpec()); presenter.stopContainer(); verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR)); verify(view).setContainerStartState(State.ENABLED); verify(view).setContainerStopState(State.DISABLED); verify(view).disableRemoveButton(); } | public void stopContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STOPPED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STARTED); return false; } }).stopContainer(containerSpec); } | ContainerPresenter { public void stopContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STOPPED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STARTED); return false; } }).stopContainer(containerSpec); } } | ContainerPresenter { public void stopContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STOPPED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STARTED); return false; } }).stopContainer(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void stopContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STOPPED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STARTED); return false; } }).stopContainer(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void stopContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STOPPED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STARTED); return false; } }).stopContainer(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testGraphCommandUndoWithNoColumns() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(0, relation.getColumn().size()); assertEquals(1, relation.getRow().size()); } | @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } |
@Test public void testLoadContainersEmpty() { presenter.loadContainers(containerSpecData); verifyLoad(true, 1); } | public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testRefresh() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.loadContainers(containerSpecData); presenter.refresh(); verifyLoad(true, 2); } | public void refresh() { load(containerSpec); } | ContainerPresenter { public void refresh() { load(containerSpec); } } | ContainerPresenter { public void refresh() { load(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void refresh() { load(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void refresh() { load(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testLoadContainers() { final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null); containerSpecData.getContainers().add(container); presenter.loadContainers(containerSpecData); verifyLoad(true, 1); } | public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testLoadContainersNonStoped() { final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null); container.setStatus(KieContainerStatus.STARTED); containerSpecData.getContainers().add(container); presenter.loadContainers(containerSpecData); verifyLoad(false, 1); } | public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testLoad() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.load(new ContainerSpecSelected(containerSpec)); verifyLoad(true, 1); } | public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } | ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } } | ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testOnRefresh() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.onRefresh(new RefreshRemoteServers(containerSpec)); verifyLoad(true, 1); } | public void onRefresh(@Observes final RefreshRemoteServers refresh) { if (refresh != null && refresh.getContainerSpecKey() != null) { load(refresh.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } | ContainerPresenter { public void onRefresh(@Observes final RefreshRemoteServers refresh) { if (refresh != null && refresh.getContainerSpecKey() != null) { load(refresh.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } } | ContainerPresenter { public void onRefresh(@Observes final RefreshRemoteServers refresh) { if (refresh != null && refresh.getContainerSpecKey() != null) { load(refresh.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void onRefresh(@Observes final RefreshRemoteServers refresh) { if (refresh != null && refresh.getContainerSpecKey() != null) { load(refresh.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void onRefresh(@Observes final RefreshRemoteServers refresh) { if (refresh != null && refresh.getContainerSpecKey() != null) { load(refresh.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testRemoveContainer() { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { final Command command = (Command) invocation.getArguments()[0]; if (command != null) { command.execute(); } return null; } }).when(view).confirmRemove(any(Command.class)); final String successMessage = "SUCCESS"; when(view.getRemoveContainerSuccessMessage()).thenReturn(successMessage); presenter.loadContainers(containerSpecData); presenter.removeContainer(); verify(specManagementService).deleteContainerSpec(serverTemplateKey.getId(), containerSpec.getId()); final ArgumentCaptor<NotificationEvent> notificationCaptor = ArgumentCaptor.forClass(NotificationEvent.class); verify(notification).fire(notificationCaptor.capture()); final NotificationEvent event = notificationCaptor.getValue(); assertEquals(NotificationEvent.NotificationType.SUCCESS, event.getType()); assertEquals(successMessage, event.getNotification()); final ArgumentCaptor<ServerTemplateSelected> serverTemplateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class); verify(serverTemplateSelectedEvent).fire(serverTemplateSelectedCaptor.capture()); assertEquals(serverTemplateKey.getId(), serverTemplateSelectedCaptor.getValue().getServerTemplateKey().getId()); final String errorMessage = "ERROR"; when(view.getRemoveContainerErrorMessage()).thenReturn(errorMessage); doThrow(new RuntimeException()).when(specManagementService).deleteContainerSpec(serverTemplateKey.getId(), containerSpec.getId()); presenter.removeContainer(); verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR)); verify(serverTemplateSelectedEvent, times(2)).fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); } | public void removeContainer() { view.confirmRemove(new Command() { @Override public void execute() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { notification.fire(new NotificationEvent(view.getRemoveContainerSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getRemoveContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); return false; } }).deleteContainerSpec(containerSpec.getServerTemplateKey().getId(), containerSpec.getId()); } }); } | ContainerPresenter { public void removeContainer() { view.confirmRemove(new Command() { @Override public void execute() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { notification.fire(new NotificationEvent(view.getRemoveContainerSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getRemoveContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); return false; } }).deleteContainerSpec(containerSpec.getServerTemplateKey().getId(), containerSpec.getId()); } }); } } | ContainerPresenter { public void removeContainer() { view.confirmRemove(new Command() { @Override public void execute() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { notification.fire(new NotificationEvent(view.getRemoveContainerSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getRemoveContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); return false; } }).deleteContainerSpec(containerSpec.getServerTemplateKey().getId(), containerSpec.getId()); } }); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void removeContainer() { view.confirmRemove(new Command() { @Override public void execute() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { notification.fire(new NotificationEvent(view.getRemoveContainerSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getRemoveContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); return false; } }).deleteContainerSpec(containerSpec.getServerTemplateKey().getId(), containerSpec.getId()); } }); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void removeContainer() { view.confirmRemove(new Command() { @Override public void execute() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { notification.fire(new NotificationEvent(view.getRemoveContainerSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getRemoveContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); return false; } }).deleteContainerSpec(containerSpec.getServerTemplateKey().getId(), containerSpec.getId()); } }); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testLoadWhenRuntimeManagementServiceReturnsInvalidData() { ContainerSpecData badData = new ContainerSpecData(null, null); when(runtimeManagementService.getContainersByContainerSpec(anyObject(), anyObject())).thenReturn(badData); ContainerSpecKey lookupKey = new ContainerSpecKey("dummyId", "dummyName", new ServerTemplateKey("keyId", "keyName")); presenter.load(lookupKey); verify(view, never()).setContainerName(anyString()); } | public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } | ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } } | ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testUpdateStatusForStopped() { presenter.updateStatus(KieContainerStatus.STOPPED); verify(view).updateToggleActivationButton(false); } | protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testUpdateStatusForStarted() { presenter.updateStatus(KieContainerStatus.STARTED); verify(view).disableRemoveButton(); verify(view).setContainerStartState(State.ENABLED); verify(view).setContainerStopState(State.DISABLED); verify(view).updateToggleActivationButton(false); verify(view).enableToggleActivationButton(); } | protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testCanvasCommandAllow() { final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.allow(handler)); } | @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) { uiModel.deleteRow(uiRowIndex); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { uiModel.insertRow(uiRowIndex, oldUiModelRow); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) { uiModel.deleteRow(uiRowIndex); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { uiModel.insertRow(uiRowIndex, oldUiModelRow); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) { uiModel.deleteRow(uiRowIndex); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { uiModel.insertRow(uiRowIndex, oldUiModelRow); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) { uiModel.deleteRow(uiRowIndex); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { uiModel.insertRow(uiRowIndex, oldUiModelRow); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } | DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) { uiModel.deleteRow(uiRowIndex); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { uiModel.insertRow(uiRowIndex, oldUiModelRow); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } |
@Test public void testUpdateStatusForFailed() { presenter.updateStatus(KieContainerStatus.FAILED); verify(view).enableRemoveButton(); verify(view).setContainerStartState(State.DISABLED); verify(view).setContainerStopState(State.ENABLED); verify(view).disableToggleActivationButton(); } | protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testUpdateStatusForDeactiveated() { presenter.updateStatus(KieContainerStatus.DEACTIVATED); verify(view).disableRemoveButton(); verify(view).setContainerStartState(State.ENABLED); verify(view).setContainerStopState(State.DISABLED); verify(view).updateToggleActivationButton(true); verify(view).enableToggleActivationButton(); } | protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } | ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); } |
@Test public void testInit() { assertEquals( view, presenter.getView() ); } | public org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView() { return view; } | ContainerCardPresenter { public org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView() { return view; } } | ContainerCardPresenter { public org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView() { return view; } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); } | ContainerCardPresenter { public org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView() { return view; } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView(); void setup( final Container container ); } | ContainerCardPresenter { public org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView() { return view; } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView(); void setup( final Container container ); } |
@Test public void testSetup() { final InfoTitlePresenter infoTitlePresenter = mock( InfoTitlePresenter.class ); when( infoTitlePresenterProvider.get() ).thenReturn( infoTitlePresenter ); final LinkTitlePresenter linkTitlePresenter = spy( new LinkTitlePresenter( mock( LinkTitlePresenter.View.class ) ) ); when( linkTitlePresenterProvider.get() ).thenReturn( linkTitlePresenter ); final BodyPresenter bodyPresenter = mock( BodyPresenter.class ); when( bodyPresenterProvider.get() ).thenReturn( bodyPresenter ); final FooterPresenter footerPresenter = mock( FooterPresenter.class ); when( footerPresenterProvider.get() ).thenReturn( footerPresenter ); final CardPresenter.View cardPresenterView = mock( CardPresenter.View.class ); final CardPresenter cardPresenter = spy( new CardPresenter( cardPresenterView ) ); when( cardPresenterProvider.get() ).thenReturn( cardPresenter ); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "templateId", "serverName", "serverInstanceId", "url" ); final Message message = new Message( Severity.INFO, "testMessage" ); final ReleaseId resolvedReleasedId = new ReleaseId( "org.kie", "container", "1.0.0" ); final Container container = new Container( "containerSpecId", "containerName", serverInstanceKey, Collections.singletonList( message ), resolvedReleasedId, null ); presenter.setup( container ); verify( linkTitlePresenter ).setup( eq( container.getContainerName() ), any( Command.class ) ); verify( infoTitlePresenter ).setup( container.getResolvedReleasedId() ); verify( bodyPresenter ).setup( Arrays.asList( message ) ); verify( footerPresenter ).setup( container.getUrl(), resolvedReleasedId.getVersion() ); verify( cardPresenter ).addTitle( linkTitlePresenter ); verify( cardPresenter ).addTitle( infoTitlePresenter ); verify( cardPresenter ).addBody( bodyPresenter ); verify( cardPresenter ).addFooter( footerPresenter ); verify( view ).setCard( cardPresenterView ); linkTitlePresenter.onSelect(); final ContainerSpecKey containerSpecKey = new ContainerSpecKey( container.getContainerSpecId(), container.getContainerName(), new ServerTemplateKey( container.getServerInstanceKey().getServerTemplateId(), "" ) ); verify( containerSpecSelectedEvent ).fire( eq( new ContainerSpecSelected( containerSpecKey ) ) ); } | public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } | ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } } | ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); } | ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView(); void setup( final Container container ); } | ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView(); void setup( final Container container ); } |
@Test public void testSetupWithUnNamedContainer() { final InfoTitlePresenter infoTitlePresenter = mock(InfoTitlePresenter.class); when(infoTitlePresenterProvider.get()).thenReturn(infoTitlePresenter); final LinkTitlePresenter linkTitlePresenter = spy(new LinkTitlePresenter(mock(LinkTitlePresenter.View.class))); when(linkTitlePresenterProvider.get()).thenReturn(linkTitlePresenter); final BodyPresenter bodyPresenter = mock(BodyPresenter.class); when(bodyPresenterProvider.get()).thenReturn(bodyPresenter); final FooterPresenter footerPresenter = mock(FooterPresenter.class); when(footerPresenterProvider.get()).thenReturn(footerPresenter); final CardPresenter.View cardPresenterView = mock(CardPresenter.View.class); final CardPresenter cardPresenter = spy(new CardPresenter(cardPresenterView)); when(cardPresenterProvider.get()).thenReturn(cardPresenter); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url"); final Message message = new Message(Severity.INFO, "testMessage"); final ReleaseId resolvedReleasedId = new ReleaseId("org.kie", "container", "1.0.0"); final Container container = new Container("containerSpecId", null, serverInstanceKey, Collections.singletonList(message), resolvedReleasedId, null); presenter.setup(container); verify(linkTitlePresenter).setup(eq(container.getContainerSpecId()), any(Command.class)); verify(view).setCard(cardPresenterView); linkTitlePresenter.onSelect(); final ContainerSpecKey containerSpecKey = new ContainerSpecKey(container.getContainerSpecId(), container.getContainerSpecId(), new ServerTemplateKey(container.getServerInstanceKey().getServerTemplateId(), "")); verify(containerSpecSelectedEvent).fire(eq(new ContainerSpecSelected(containerSpecKey))); } | public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } | ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } } | ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); } | ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView(); void setup( final Container container ); } | ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView(); void setup( final Container container ); } |
@Test public void testInit() { assertEquals( view, presenter.getView() ); } | public View getView() { return view; } | RemoteEmptyPresenter { public View getView() { return view; } } | RemoteEmptyPresenter { public View getView() { return view; } @Inject RemoteEmptyPresenter( final View view ); } | RemoteEmptyPresenter { public View getView() { return view; } @Inject RemoteEmptyPresenter( final View view ); View getView(); } | RemoteEmptyPresenter { public View getView() { return view; } @Inject RemoteEmptyPresenter( final View view ); View getView(); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init( this ); } | RemotePresenter { @PostConstruct public void init() { view.init( this ); } } | RemotePresenter { @PostConstruct public void init() { view.init( this ); } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); } | RemotePresenter { @PostConstruct public void init() { view.init( this ); } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); } | RemotePresenter { @PostConstruct public void init() { view.init( this ); } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); } |
@Test public void testRemove() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "templateId", "serverName", "serverInstanceId", "url" ); presenter.onSelect( new ServerInstanceSelected( serverInstanceKey ) ); presenter.remove(); verify( specManagementService ).deleteServerInstance( serverInstanceKey ); verify( notification ).fire( any( NotificationEvent.class ) ); } | public void remove() { specManagementServiceCaller.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); return false; } } ).deleteServerInstance( serverInstanceKey ); } | RemotePresenter { public void remove() { specManagementServiceCaller.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); return false; } } ).deleteServerInstance( serverInstanceKey ); } } | RemotePresenter { public void remove() { specManagementServiceCaller.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); return false; } } ).deleteServerInstance( serverInstanceKey ); } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); } | RemotePresenter { public void remove() { specManagementServiceCaller.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); return false; } } ).deleteServerInstance( serverInstanceKey ); } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); } | RemotePresenter { public void remove() { specManagementServiceCaller.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); return false; } } ).deleteServerInstance( serverInstanceKey ); } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); } |
@Test public void testOnInstanceUpdate() { final ServerInstance serverInstance = new ServerInstance( "templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList() ); presenter.onSelect( new ServerInstanceSelected( serverInstance ) ); presenter.onInstanceUpdate( new ServerInstanceUpdated( serverInstance ) ); verify( view, times( 2 ) ).clear(); verify( view, times( 2 ) ).setServerName( serverInstance.getServerName() ); verify( view, times( 2 ) ).setServerURL( serverInstance.getUrl() ); verify( view, times( 2 ) ).setEmptyView( remoteEmptyPresenter.getView() ); } | public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } | RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } } | RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); } | RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); } | RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); } |
@Test public void testOnInstanceUpdateWithoutSelect() { final ServerInstance serverInstance = new ServerInstance( "templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList() ); presenter.onInstanceUpdate( new ServerInstanceUpdated( serverInstance ) ); verify( view, never() ).clear(); verify( view, never() ).setServerName( anyString() ); verify( view, never() ).setServerURL( anyString() ); verify( view, never() ).setEmptyView( any(RemoteEmptyView.class) ); } | public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } | RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } } | RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); } | RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); } | RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); } |
@Test public void testGraphCommandAllow() { setupCommand(0, uiModel.getRow(0)); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); } | @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init(this); } | ServerNavigationPresenter { @PostConstruct public void init() { view.init(this); } } | ServerNavigationPresenter { @PostConstruct public void init() { view.init(this); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); } | ServerNavigationPresenter { @PostConstruct public void init() { view.init(this); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } | ServerNavigationPresenter { @PostConstruct public void init() { view.init(this); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } |
@Test public void testClear() { presenter.clear(); verify( view ).clean(); } | public void clear() { view.clean(); } | ServerNavigationPresenter { public void clear() { view.clean(); } } | ServerNavigationPresenter { public void clear() { view.clean(); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); } | ServerNavigationPresenter { public void clear() { view.clean(); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } | ServerNavigationPresenter { public void clear() { view.clean(); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } |
@Test public void testSelect() { final String serverId = "serverId"; presenter.select( serverId ); final ArgumentCaptor<ServerTemplateSelected> serverTemplateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( serverTemplateSelectedCaptor.capture() ); assertEquals( serverId, serverTemplateSelectedCaptor.getValue().getServerTemplateKey().getId() ); } | public void select(final String id) { serverTemplateSelectedEvent.fire(new ServerTemplateSelected(new ServerTemplateKey(id, ""))); } | ServerNavigationPresenter { public void select(final String id) { serverTemplateSelectedEvent.fire(new ServerTemplateSelected(new ServerTemplateKey(id, ""))); } } | ServerNavigationPresenter { public void select(final String id) { serverTemplateSelectedEvent.fire(new ServerTemplateSelected(new ServerTemplateKey(id, ""))); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); } | ServerNavigationPresenter { public void select(final String id) { serverTemplateSelectedEvent.fire(new ServerTemplateSelected(new ServerTemplateKey(id, ""))); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } | ServerNavigationPresenter { public void select(final String id) { serverTemplateSelectedEvent.fire(new ServerTemplateSelected(new ServerTemplateKey(id, ""))); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } |
@Test public void testRefresh() { presenter.refresh(); verify( serverTemplateListRefreshEvent ).fire( any( ServerTemplateListRefresh.class ) ); } | public void refresh() { serverTemplateListRefreshEvent.fire(new ServerTemplateListRefresh()); } | ServerNavigationPresenter { public void refresh() { serverTemplateListRefreshEvent.fire(new ServerTemplateListRefresh()); } } | ServerNavigationPresenter { public void refresh() { serverTemplateListRefreshEvent.fire(new ServerTemplateListRefresh()); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); } | ServerNavigationPresenter { public void refresh() { serverTemplateListRefreshEvent.fire(new ServerTemplateListRefresh()); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } | ServerNavigationPresenter { public void refresh() { serverTemplateListRefreshEvent.fire(new ServerTemplateListRefresh()); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } |
@Test public void testNewTemplate() { presenter.newTemplate(); verify( addNewServerTemplateEvent ).fire( any( AddNewServerTemplate.class ) ); } | public void newTemplate() { addNewServerTemplateEvent.fire(new AddNewServerTemplate()); } | ServerNavigationPresenter { public void newTemplate() { addNewServerTemplateEvent.fire(new AddNewServerTemplate()); } } | ServerNavigationPresenter { public void newTemplate() { addNewServerTemplateEvent.fire(new AddNewServerTemplate()); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); } | ServerNavigationPresenter { public void newTemplate() { addNewServerTemplateEvent.fire(new AddNewServerTemplate()); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } | ServerNavigationPresenter { public void newTemplate() { addNewServerTemplateEvent.fire(new AddNewServerTemplate()); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } |
@Test public void testSetup() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.setup( serverTemplateKey, Collections.singletonList( serverTemplateKey ) ); verify( view ).clean(); verify( view ).addTemplate( serverTemplateKey.getId(), serverTemplateKey.getName() ); } | public void setup(final ServerTemplateKey firstTemplate, final Collection<ServerTemplateKey> serverTemplateKeys) { view.clean(); serverTemplates.clear(); addTemplate(checkNotNull("serverTemplate2BeSelected", firstTemplate)); for (final ServerTemplateKey serverTemplateKey : serverTemplateKeys) { if (!serverTemplateKey.equals(firstTemplate)) { addTemplate(serverTemplateKey); } } } | ServerNavigationPresenter { public void setup(final ServerTemplateKey firstTemplate, final Collection<ServerTemplateKey> serverTemplateKeys) { view.clean(); serverTemplates.clear(); addTemplate(checkNotNull("serverTemplate2BeSelected", firstTemplate)); for (final ServerTemplateKey serverTemplateKey : serverTemplateKeys) { if (!serverTemplateKey.equals(firstTemplate)) { addTemplate(serverTemplateKey); } } } } | ServerNavigationPresenter { public void setup(final ServerTemplateKey firstTemplate, final Collection<ServerTemplateKey> serverTemplateKeys) { view.clean(); serverTemplates.clear(); addTemplate(checkNotNull("serverTemplate2BeSelected", firstTemplate)); for (final ServerTemplateKey serverTemplateKey : serverTemplateKeys) { if (!serverTemplateKey.equals(firstTemplate)) { addTemplate(serverTemplateKey); } } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); } | ServerNavigationPresenter { public void setup(final ServerTemplateKey firstTemplate, final Collection<ServerTemplateKey> serverTemplateKeys) { view.clean(); serverTemplates.clear(); addTemplate(checkNotNull("serverTemplate2BeSelected", firstTemplate)); for (final ServerTemplateKey serverTemplateKey : serverTemplateKeys) { if (!serverTemplateKey.equals(firstTemplate)) { addTemplate(serverTemplateKey); } } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } | ServerNavigationPresenter { public void setup(final ServerTemplateKey firstTemplate, final Collection<ServerTemplateKey> serverTemplateKeys) { view.clean(); serverTemplates.clear(); addTemplate(checkNotNull("serverTemplate2BeSelected", firstTemplate)); for (final ServerTemplateKey serverTemplateKey : serverTemplateKeys) { if (!serverTemplateKey.equals(firstTemplate)) { addTemplate(serverTemplateKey); } } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } |
@Test public void testOnSelect() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.onSelect( new ServerTemplateSelected( serverTemplateKey ) ); verify( view ).select( serverTemplateKey.getId() ); } | public void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected) { if (serverTemplateSelected != null && serverTemplateSelected.getServerTemplateKey() != null && serverTemplateSelected.getServerTemplateKey().getId() != null) { view.select(serverTemplateSelected.getServerTemplateKey().getId()); } else { logger.warn("Illegal event argument."); } } | ServerNavigationPresenter { public void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected) { if (serverTemplateSelected != null && serverTemplateSelected.getServerTemplateKey() != null && serverTemplateSelected.getServerTemplateKey().getId() != null) { view.select(serverTemplateSelected.getServerTemplateKey().getId()); } else { logger.warn("Illegal event argument."); } } } | ServerNavigationPresenter { public void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected) { if (serverTemplateSelected != null && serverTemplateSelected.getServerTemplateKey() != null && serverTemplateSelected.getServerTemplateKey().getId() != null) { view.select(serverTemplateSelected.getServerTemplateKey().getId()); } else { logger.warn("Illegal event argument."); } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); } | ServerNavigationPresenter { public void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected) { if (serverTemplateSelected != null && serverTemplateSelected.getServerTemplateKey() != null && serverTemplateSelected.getServerTemplateKey().getId() != null) { view.select(serverTemplateSelected.getServerTemplateKey().getId()); } else { logger.warn("Illegal event argument."); } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } | ServerNavigationPresenter { public void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected) { if (serverTemplateSelected != null && serverTemplateSelected.getServerTemplateKey() != null && serverTemplateSelected.getServerTemplateKey().getId() != null) { view.select(serverTemplateSelected.getServerTemplateKey().getId()); } else { logger.warn("Illegal event argument."); } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } |
@Test public void testOnServerTemplateUpdated() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.onServerTemplateUpdated( new ServerTemplateUpdated( serverTemplate ) ); verify( view ).addTemplate( serverTemplate.getId(), serverTemplate.getName() ); } | public void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated) { if (serverTemplateUpdated != null && serverTemplateUpdated.getServerTemplate() != null) { final ServerTemplate serverTemplate = serverTemplateUpdated.getServerTemplate(); if (!serverTemplates.contains(serverTemplate.getId())) { addTemplate(serverTemplate); } } else { logger.warn("Illegal event argument."); } } | ServerNavigationPresenter { public void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated) { if (serverTemplateUpdated != null && serverTemplateUpdated.getServerTemplate() != null) { final ServerTemplate serverTemplate = serverTemplateUpdated.getServerTemplate(); if (!serverTemplates.contains(serverTemplate.getId())) { addTemplate(serverTemplate); } } else { logger.warn("Illegal event argument."); } } } | ServerNavigationPresenter { public void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated) { if (serverTemplateUpdated != null && serverTemplateUpdated.getServerTemplate() != null) { final ServerTemplate serverTemplate = serverTemplateUpdated.getServerTemplate(); if (!serverTemplates.contains(serverTemplate.getId())) { addTemplate(serverTemplate); } } else { logger.warn("Illegal event argument."); } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); } | ServerNavigationPresenter { public void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated) { if (serverTemplateUpdated != null && serverTemplateUpdated.getServerTemplate() != null) { final ServerTemplate serverTemplate = serverTemplateUpdated.getServerTemplate(); if (!serverTemplates.contains(serverTemplate.getId())) { addTemplate(serverTemplate); } } else { logger.warn("Illegal event argument."); } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } | ServerNavigationPresenter { public void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated) { if (serverTemplateUpdated != null && serverTemplateUpdated.getServerTemplate() != null) { final ServerTemplate serverTemplate = serverTemplateUpdated.getServerTemplate(); if (!serverTemplates.contains(serverTemplate.getId())) { addTemplate(serverTemplate); } } else { logger.warn("Illegal event argument."); } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init(this); } | CopyPopupPresenter { @PostConstruct public void init() { view.init(this); } } | CopyPopupPresenter { @PostConstruct public void init() { view.init(this); } @Inject CopyPopupPresenter(final View view); } | CopyPopupPresenter { @PostConstruct public void init() { view.init(this); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } | CopyPopupPresenter { @PostConstruct public void init() { view.init(this); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } |
@Test public void testHide() { presenter.hide(); verify( view ).hide(); } | public void hide() { view.hide(); } | CopyPopupPresenter { public void hide() { view.hide(); } } | CopyPopupPresenter { public void hide() { view.hide(); } @Inject CopyPopupPresenter(final View view); } | CopyPopupPresenter { public void hide() { view.hide(); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } | CopyPopupPresenter { public void hide() { view.hide(); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } |
@Test public void testGraphCommandExecuteMoveUp() { setupCommand(0, uiModel.getRow(1)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertRelationDefinition(1, 0); } | @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } |
@Test public void testValidateTerms() { final Set<ValueIndexTerm> queryTerms = new HashSet<>(); final String[] requiredTermNames = new String[]{}; final Predicate<ValueIndexTerm> fileExtensionIndexTermPredicate = (t) -> true; final Predicate<ValueIndexTerm> repositoryRootIndexTermPredicate = (t) -> true; doReturn(requiredTermNames).when(query).requiredTermNames(); doReturn(fileExtensionIndexTermPredicate).when(query).repositoryRootIndexTermPredicate(); doReturn(repositoryRootIndexTermPredicate).when(query).fileExtensionIndexTermPredicate(); query.validateTerms(queryTerms); verify(query).checkTermsSize(2, queryTerms); verify(query).checkTerms(queryTerms, NAME, requiredTermNames, fileExtensionIndexTermPredicate, repositoryRootIndexTermPredicate); } | @Override public void validateTerms(final Set<ValueIndexTerm> queryTerms) throws IllegalArgumentException { checkTerms(queryTerms, NAME, requiredTermNames(), repositoryRootIndexTermPredicate(), fileExtensionIndexTermPredicate()); checkTermsSize(2, queryTerms); } | FindAllDmnAssetsQuery extends AbstractFindQuery implements NamedQuery { @Override public void validateTerms(final Set<ValueIndexTerm> queryTerms) throws IllegalArgumentException { checkTerms(queryTerms, NAME, requiredTermNames(), repositoryRootIndexTermPredicate(), fileExtensionIndexTermPredicate()); checkTermsSize(2, queryTerms); } } | FindAllDmnAssetsQuery extends AbstractFindQuery implements NamedQuery { @Override public void validateTerms(final Set<ValueIndexTerm> queryTerms) throws IllegalArgumentException { checkTerms(queryTerms, NAME, requiredTermNames(), repositoryRootIndexTermPredicate(), fileExtensionIndexTermPredicate()); checkTermsSize(2, queryTerms); } @Inject FindAllDmnAssetsQuery(final FileDetailsResponseBuilder responseBuilder); } | FindAllDmnAssetsQuery extends AbstractFindQuery implements NamedQuery { @Override public void validateTerms(final Set<ValueIndexTerm> queryTerms) throws IllegalArgumentException { checkTerms(queryTerms, NAME, requiredTermNames(), repositoryRootIndexTermPredicate(), fileExtensionIndexTermPredicate()); checkTermsSize(2, queryTerms); } @Inject FindAllDmnAssetsQuery(final FileDetailsResponseBuilder responseBuilder); @Override String getName(); @Override Query toQuery(final Set<ValueIndexTerm> terms); @Override Sort getSortOrder(); @Override ResponseBuilder getResponseBuilder(); @Override void validateTerms(final Set<ValueIndexTerm> queryTerms); } | FindAllDmnAssetsQuery extends AbstractFindQuery implements NamedQuery { @Override public void validateTerms(final Set<ValueIndexTerm> queryTerms) throws IllegalArgumentException { checkTerms(queryTerms, NAME, requiredTermNames(), repositoryRootIndexTermPredicate(), fileExtensionIndexTermPredicate()); checkTermsSize(2, queryTerms); } @Inject FindAllDmnAssetsQuery(final FileDetailsResponseBuilder responseBuilder); @Override String getName(); @Override Query toQuery(final Set<ValueIndexTerm> terms); @Override Sort getSortOrder(); @Override ResponseBuilder getResponseBuilder(); @Override void validateTerms(final Set<ValueIndexTerm> queryTerms); static String NAME; } |
@Test public void testCopy() { final String newTemplateName = "NewTemplateName"; when( view.getNewTemplateName() ).thenReturn( newTemplateName ); final ParameterizedCommand command = mock( ParameterizedCommand.class ); presenter.copy( command ); verify( view ).clear(); verify( view ).display(); presenter.save(); verify( command ).execute( newTemplateName ); } | public void copy(final ParameterizedCommand<String> command) { this.command = checkNotNull("command", command); view.clear(); view.display(); } | CopyPopupPresenter { public void copy(final ParameterizedCommand<String> command) { this.command = checkNotNull("command", command); view.clear(); view.display(); } } | CopyPopupPresenter { public void copy(final ParameterizedCommand<String> command) { this.command = checkNotNull("command", command); view.clear(); view.display(); } @Inject CopyPopupPresenter(final View view); } | CopyPopupPresenter { public void copy(final ParameterizedCommand<String> command) { this.command = checkNotNull("command", command); view.clear(); view.display(); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } | CopyPopupPresenter { public void copy(final ParameterizedCommand<String> command) { this.command = checkNotNull("command", command); view.clear(); view.display(); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } |
@Test public void testCopyError() { when( view.getNewTemplateName() ).thenReturn( "" ); presenter.save(); verify( view ).errorOnTemplateNameFromGroup(); } | public void save() { if (view.getNewTemplateName().trim().isEmpty()) { view.errorOnTemplateNameFromGroup(); return; } command.execute(view.getNewTemplateName()); } | CopyPopupPresenter { public void save() { if (view.getNewTemplateName().trim().isEmpty()) { view.errorOnTemplateNameFromGroup(); return; } command.execute(view.getNewTemplateName()); } } | CopyPopupPresenter { public void save() { if (view.getNewTemplateName().trim().isEmpty()) { view.errorOnTemplateNameFromGroup(); return; } command.execute(view.getNewTemplateName()); } @Inject CopyPopupPresenter(final View view); } | CopyPopupPresenter { public void save() { if (view.getNewTemplateName().trim().isEmpty()) { view.errorOnTemplateNameFromGroup(); return; } command.execute(view.getNewTemplateName()); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } | CopyPopupPresenter { public void save() { if (view.getNewTemplateName().trim().isEmpty()) { view.errorOnTemplateNameFromGroup(); return; } command.execute(view.getNewTemplateName()); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } |
@Test public void testErrorOnTemplateNameFromGroup() { final String errorMessage = "errorMessage"; presenter.errorDuringProcessing( errorMessage ); verify( view ).errorOnTemplateNameFromGroup( errorMessage ); } | public void errorDuringProcessing(final String message) { view.errorOnTemplateNameFromGroup(message); } | CopyPopupPresenter { public void errorDuringProcessing(final String message) { view.errorOnTemplateNameFromGroup(message); } } | CopyPopupPresenter { public void errorDuringProcessing(final String message) { view.errorOnTemplateNameFromGroup(message); } @Inject CopyPopupPresenter(final View view); } | CopyPopupPresenter { public void errorDuringProcessing(final String message) { view.errorOnTemplateNameFromGroup(message); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } | CopyPopupPresenter { public void errorDuringProcessing(final String message) { view.errorOnTemplateNameFromGroup(message); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init( this ); } | ServerTemplatePresenter { @PostConstruct public void init() { view.init( this ); } } | ServerTemplatePresenter { @PostConstruct public void init() { view.init( this ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); } | ServerTemplatePresenter { @PostConstruct public void init() { view.init( this ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } | ServerTemplatePresenter { @PostConstruct public void init() { view.init( this ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } |
@Test public void testOnContainerSelect() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "containerId", "containerName", serverTemplateKey ); presenter.onContainerSelect( new ContainerSpecSelected( containerSpecKey ) ); verify( view ).selectContainer( serverTemplateKey.getId(), containerSpecKey.getId() ); } | public void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ) { if ( containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId() != null && containerSpecSelected.getContainerSpecKey().getId() != null ) { view.selectContainer( containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId(), containerSpecSelected.getContainerSpecKey().getId() ); } else { logger.warn( "Illegal event argument." ); } } | ServerTemplatePresenter { public void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ) { if ( containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId() != null && containerSpecSelected.getContainerSpecKey().getId() != null ) { view.selectContainer( containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId(), containerSpecSelected.getContainerSpecKey().getId() ); } else { logger.warn( "Illegal event argument." ); } } } | ServerTemplatePresenter { public void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ) { if ( containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId() != null && containerSpecSelected.getContainerSpecKey().getId() != null ) { view.selectContainer( containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId(), containerSpecSelected.getContainerSpecKey().getId() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); } | ServerTemplatePresenter { public void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ) { if ( containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId() != null && containerSpecSelected.getContainerSpecKey().getId() != null ) { view.selectContainer( containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId(), containerSpecSelected.getContainerSpecKey().getId() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } | ServerTemplatePresenter { public void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ) { if ( containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId() != null && containerSpecSelected.getContainerSpecKey().getId() != null ) { view.selectContainer( containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId(), containerSpecSelected.getContainerSpecKey().getId() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } |
@Test public void testOnServerInstanceSelect() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverInstanceKeyId", "serverName", "serverInstanceId", "url" ); presenter.onServerInstanceSelect( new ServerInstanceSelected( serverInstanceKey ) ); verify( view ).selectServerInstance( serverInstanceKey.getServerTemplateId(), serverInstanceKey.getServerInstanceId() ); } | public void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ) { if ( serverInstanceSelected != null && serverInstanceSelected.getServerInstanceKey() != null && serverInstanceSelected.getServerInstanceKey().getServerTemplateId() != null && serverInstanceSelected.getServerInstanceKey().getServerInstanceId() != null ) { view.selectServerInstance( serverInstanceSelected.getServerInstanceKey().getServerTemplateId(), serverInstanceSelected.getServerInstanceKey().getServerInstanceId() ); } else { logger.warn( "Illegal event argument." ); } } | ServerTemplatePresenter { public void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ) { if ( serverInstanceSelected != null && serverInstanceSelected.getServerInstanceKey() != null && serverInstanceSelected.getServerInstanceKey().getServerTemplateId() != null && serverInstanceSelected.getServerInstanceKey().getServerInstanceId() != null ) { view.selectServerInstance( serverInstanceSelected.getServerInstanceKey().getServerTemplateId(), serverInstanceSelected.getServerInstanceKey().getServerInstanceId() ); } else { logger.warn( "Illegal event argument." ); } } } | ServerTemplatePresenter { public void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ) { if ( serverInstanceSelected != null && serverInstanceSelected.getServerInstanceKey() != null && serverInstanceSelected.getServerInstanceKey().getServerTemplateId() != null && serverInstanceSelected.getServerInstanceKey().getServerInstanceId() != null ) { view.selectServerInstance( serverInstanceSelected.getServerInstanceKey().getServerTemplateId(), serverInstanceSelected.getServerInstanceKey().getServerInstanceId() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); } | ServerTemplatePresenter { public void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ) { if ( serverInstanceSelected != null && serverInstanceSelected.getServerInstanceKey() != null && serverInstanceSelected.getServerInstanceKey().getServerTemplateId() != null && serverInstanceSelected.getServerInstanceKey().getServerInstanceId() != null ) { view.selectServerInstance( serverInstanceSelected.getServerInstanceKey().getServerTemplateId(), serverInstanceSelected.getServerInstanceKey().getServerInstanceId() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } | ServerTemplatePresenter { public void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ) { if ( serverInstanceSelected != null && serverInstanceSelected.getServerInstanceKey() != null && serverInstanceSelected.getServerInstanceKey().getServerTemplateId() != null && serverInstanceSelected.getServerInstanceKey().getServerInstanceId() != null ) { view.selectServerInstance( serverInstanceSelected.getServerInstanceKey().getServerTemplateId(), serverInstanceSelected.getServerInstanceKey().getServerInstanceId() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } |
@Test public void testOnServerInstanceUpdated() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); presenter.setup( serverTemplate, null ); assertEquals( serverTemplate, presenter.getCurrentServerTemplate() ); final ServerInstance serverInstance = new ServerInstance( serverTemplate.getId(), "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList() ); presenter.onServerInstanceUpdated( new ServerInstanceUpdated( serverInstance ) ); presenter.onServerInstanceUpdated( new ServerInstanceUpdated( serverInstance ) ); verify( view ).addServerInstance( eq( serverInstance.getServerTemplateId() ), eq( serverInstance.getServerInstanceId() ), eq( serverInstance.getServerName() ), any( Command.class ) ); presenter.onServerInstanceDeleted( new ServerInstanceDeleted( serverInstance.getServerInstanceId() ) ); presenter.onServerInstanceUpdated( new ServerInstanceUpdated( serverInstance ) ); verify( view, times( 2 ) ).addServerInstance( eq( serverInstance.getServerTemplateId() ), eq( serverInstance.getServerInstanceId() ), eq( serverInstance.getServerName() ), any( Command.class ) ); } | public void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstance updatedServerInstance = serverInstanceUpdated.getServerInstance(); if ( serverTemplate != null && updatedServerInstance.getServerTemplateId().equals( serverTemplate.getId() ) && !serverInstances.contains( updatedServerInstance.getServerInstanceId() ) ) { addServerInstance( updatedServerInstance ); } } else { logger.warn( "Illegal event argument." ); } } | ServerTemplatePresenter { public void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstance updatedServerInstance = serverInstanceUpdated.getServerInstance(); if ( serverTemplate != null && updatedServerInstance.getServerTemplateId().equals( serverTemplate.getId() ) && !serverInstances.contains( updatedServerInstance.getServerInstanceId() ) ) { addServerInstance( updatedServerInstance ); } } else { logger.warn( "Illegal event argument." ); } } } | ServerTemplatePresenter { public void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstance updatedServerInstance = serverInstanceUpdated.getServerInstance(); if ( serverTemplate != null && updatedServerInstance.getServerTemplateId().equals( serverTemplate.getId() ) && !serverInstances.contains( updatedServerInstance.getServerInstanceId() ) ) { addServerInstance( updatedServerInstance ); } } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); } | ServerTemplatePresenter { public void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstance updatedServerInstance = serverInstanceUpdated.getServerInstance(); if ( serverTemplate != null && updatedServerInstance.getServerTemplateId().equals( serverTemplate.getId() ) && !serverInstances.contains( updatedServerInstance.getServerInstanceId() ) ) { addServerInstance( updatedServerInstance ); } } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } | ServerTemplatePresenter { public void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstance updatedServerInstance = serverInstanceUpdated.getServerInstance(); if ( serverTemplate != null && updatedServerInstance.getServerTemplateId().equals( serverTemplate.getId() ) && !serverInstances.contains( updatedServerInstance.getServerInstanceId() ) ) { addServerInstance( updatedServerInstance ); } } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } |
@Test public void testAddNewContainer() { presenter.addNewContainer(); verify( addNewContainerEvent ).fire( any( AddNewContainer.class ) ); } | public void addNewContainer() { addNewContainerEvent.fire( new AddNewContainer( serverTemplate ) ); } | ServerTemplatePresenter { public void addNewContainer() { addNewContainerEvent.fire( new AddNewContainer( serverTemplate ) ); } } | ServerTemplatePresenter { public void addNewContainer() { addNewContainerEvent.fire( new AddNewContainer( serverTemplate ) ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); } | ServerTemplatePresenter { public void addNewContainer() { addNewContainerEvent.fire( new AddNewContainer( serverTemplate ) ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } | ServerTemplatePresenter { public void addNewContainer() { addNewContainerEvent.fire( new AddNewContainer( serverTemplate ) ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } |
@Test public void testRemoveTemplate() { when( view.getRemoveTemplateErrorMessage() ).thenReturn( "ERROR" ); doAnswer( new Answer<Void>() { @Override public Void answer( final InvocationOnMock invocation ) throws Throwable { Command command = (Command) invocation.getArguments()[ 0 ]; if ( command != null ) { command.execute(); } return null; } } ).when( view ).confirmRemove( any( Command.class ) ); final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.setup( serverTemplate, null ); presenter.removeTemplate(); verify( specManagementService ).deleteServerTemplate( serverTemplate.getId() ); verify( serverTemplateListRefreshEvent ).fire( any( ServerTemplateListRefresh.class ) ); doThrow( new RuntimeException() ).when( specManagementService ).deleteServerTemplate( serverTemplate.getId() ); presenter.removeTemplate(); verify( specManagementService, times( 2 ) ).deleteServerTemplate( serverTemplate.getId() ); verify( serverTemplateListRefreshEvent, times( 2 ) ).fire( any( ServerTemplateListRefresh.class ) ); verify( notification ).fire( new NotificationEvent( "ERROR", NotificationEvent.NotificationType.ERROR ) ); } | public void removeTemplate() { view.confirmRemove( new Command() { @Override public void execute() { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoveTemplateErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); return false; } } ).deleteServerTemplate( serverTemplate.getId() ); } } ); } | ServerTemplatePresenter { public void removeTemplate() { view.confirmRemove( new Command() { @Override public void execute() { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoveTemplateErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); return false; } } ).deleteServerTemplate( serverTemplate.getId() ); } } ); } } | ServerTemplatePresenter { public void removeTemplate() { view.confirmRemove( new Command() { @Override public void execute() { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoveTemplateErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); return false; } } ).deleteServerTemplate( serverTemplate.getId() ); } } ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); } | ServerTemplatePresenter { public void removeTemplate() { view.confirmRemove( new Command() { @Override public void execute() { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoveTemplateErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); return false; } } ).deleteServerTemplate( serverTemplate.getId() ); } } ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } | ServerTemplatePresenter { public void removeTemplate() { view.confirmRemove( new Command() { @Override public void execute() { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoveTemplateErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); return false; } } ).deleteServerTemplate( serverTemplate.getId() ); } } ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } |
@Test public void testCopyTemplate() { final String newTemplateName = "NewTemplateName"; doAnswer( new Answer<Void>() { @Override public Void answer( final InvocationOnMock invocation ) throws Throwable { final ParameterizedCommand command = (ParameterizedCommand) invocation.getArguments()[ 0 ]; if ( command != null ) { command.execute( newTemplateName ); } return null; } } ).when( copyPresenter ).copy( any( ParameterizedCommand.class ) ); final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.setup( serverTemplate, null ); assertEquals( serverTemplate, presenter.getCurrentServerTemplate() ); presenter.copyTemplate(); verify( specManagementService ).copyServerTemplate( serverTemplate.getId(), newTemplateName, newTemplateName ); verify( copyPresenter ).hide(); final ArgumentCaptor<ServerTemplateListRefresh> serverTemplateCaptor = ArgumentCaptor.forClass( ServerTemplateListRefresh.class ); verify( serverTemplateListRefreshEvent ).fire( serverTemplateCaptor.capture() ); assertEquals( newTemplateName, serverTemplateCaptor.getValue().getSelectServerTemplateId() ); doThrow( new RuntimeException() ).when( specManagementService ).copyServerTemplate( serverTemplate.getId(), newTemplateName, newTemplateName ); presenter.copyTemplate(); verify( specManagementService, times( 2 ) ).copyServerTemplate( serverTemplate.getId(), newTemplateName, newTemplateName ); verify( copyPresenter ).errorDuringProcessing( anyString() ); } | public void copyTemplate() { copyPresenter.copy( new ParameterizedCommand<String>() { @Override public void execute( final String value ) { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { copyPresenter.hide(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( value ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { copyPresenter.errorDuringProcessing( view.getCopyTemplateErrorMessage() ); return false; } } ).copyServerTemplate( serverTemplate.getId(), value, value ); } } ); } | ServerTemplatePresenter { public void copyTemplate() { copyPresenter.copy( new ParameterizedCommand<String>() { @Override public void execute( final String value ) { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { copyPresenter.hide(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( value ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { copyPresenter.errorDuringProcessing( view.getCopyTemplateErrorMessage() ); return false; } } ).copyServerTemplate( serverTemplate.getId(), value, value ); } } ); } } | ServerTemplatePresenter { public void copyTemplate() { copyPresenter.copy( new ParameterizedCommand<String>() { @Override public void execute( final String value ) { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { copyPresenter.hide(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( value ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { copyPresenter.errorDuringProcessing( view.getCopyTemplateErrorMessage() ); return false; } } ).copyServerTemplate( serverTemplate.getId(), value, value ); } } ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); } | ServerTemplatePresenter { public void copyTemplate() { copyPresenter.copy( new ParameterizedCommand<String>() { @Override public void execute( final String value ) { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { copyPresenter.hide(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( value ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { copyPresenter.errorDuringProcessing( view.getCopyTemplateErrorMessage() ); return false; } } ).copyServerTemplate( serverTemplate.getId(), value, value ); } } ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } | ServerTemplatePresenter { public void copyTemplate() { copyPresenter.copy( new ParameterizedCommand<String>() { @Override public void execute( final String value ) { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { copyPresenter.hide(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( value ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { copyPresenter.errorDuringProcessing( view.getCopyTemplateErrorMessage() ); return false; } } ).copyServerTemplate( serverTemplate.getId(), value, value ); } } ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } |
@Test public void testGraphCommandExecuteMoveDown() { setupCommand(1, uiModel.getRow(0)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertRelationDefinition(1, 0); } | @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } |
@Test public void testSetup() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverTemplateId", "serverName", "serverInstanceId", "url" ); serverTemplate.addServerInstance( serverInstanceKey ); final ReleaseId releaseId = new ReleaseId( "org.kie", "container", "1.0.0" ); final ContainerSpec containerSpec = new ContainerSpec( "containerId", "containerName", serverTemplate, releaseId, KieContainerStatus.CREATING, null ); serverTemplate.addContainerSpec( containerSpec ); final ContainerSpec containerSpec1 = new ContainerSpec( "containerId1", "containerName1", serverTemplate, new ReleaseId( "org.kie", "container2", "1.0.0" ), KieContainerStatus.CREATING, null ); serverTemplate.addContainerSpec( containerSpec1 ); presenter.setup( serverTemplate, containerSpec ); assertEquals( serverTemplate, presenter.getCurrentServerTemplate() ); verify( view ).clear(); verify( view ).setTemplate( serverTemplate.getId(), serverTemplate.getName() ); verify( view ).setProcessCapability( false ); verify( view ).setRulesCapability( false ); verify( view ).setPlanningCapability( false ); verify( view ).addContainer( eq( containerSpec.getServerTemplateKey().getId() ), eq( containerSpec.getId() ), eq( containerSpec.getContainerName() ), any( Command.class ) ); verify( view ).addContainer( eq( containerSpec1.getServerTemplateKey().getId() ), eq( containerSpec1.getId() ), eq( containerSpec1.getContainerName() ), any( Command.class ) ); final ArgumentCaptor<ContainerSpecSelected> selectedCaptor = ArgumentCaptor.forClass( ContainerSpecSelected.class ); verify( containerSpecSelectedEvent ).fire( selectedCaptor.capture() ); assertEquals( containerSpec, selectedCaptor.getValue().getContainerSpecKey() ); verify( view ).addServerInstance( eq( serverInstanceKey.getServerTemplateId() ), eq( serverInstanceKey.getServerInstanceId() ), eq( serverInstanceKey.getServerName() ), any( Command.class ) ); } | public void setup( final ServerTemplate serverTemplate, final ContainerSpec firstContainerSpec ) { view.clear(); this.serverTemplate = serverTemplate; view.setTemplate( serverTemplate.getId(), serverTemplate.getName() ); view.setProcessCapability( serverTemplate.getCapabilities().contains( Capability.PROCESS.toString() ) ); view.setRulesCapability( serverTemplate.getCapabilities().contains( Capability.RULE.toString() ) ); view.setPlanningCapability( serverTemplate.getCapabilities().contains( Capability.PLANNING.toString() ) ); if ( firstContainerSpec != null ) { addContainer( firstContainerSpec ); for ( final ContainerSpec containerSpec : serverTemplate.getContainersSpec() ) { if ( !containerSpec.getId().equals( firstContainerSpec.getId() ) ) { addContainer( containerSpec ); } } containerSpecSelectedEvent.fire( new ContainerSpecSelected( firstContainerSpec ) ); } for ( final ServerInstanceKey serverInstanceKey : serverTemplate.getServerInstanceKeys() ) { addServerInstance( serverInstanceKey ); } } | ServerTemplatePresenter { public void setup( final ServerTemplate serverTemplate, final ContainerSpec firstContainerSpec ) { view.clear(); this.serverTemplate = serverTemplate; view.setTemplate( serverTemplate.getId(), serverTemplate.getName() ); view.setProcessCapability( serverTemplate.getCapabilities().contains( Capability.PROCESS.toString() ) ); view.setRulesCapability( serverTemplate.getCapabilities().contains( Capability.RULE.toString() ) ); view.setPlanningCapability( serverTemplate.getCapabilities().contains( Capability.PLANNING.toString() ) ); if ( firstContainerSpec != null ) { addContainer( firstContainerSpec ); for ( final ContainerSpec containerSpec : serverTemplate.getContainersSpec() ) { if ( !containerSpec.getId().equals( firstContainerSpec.getId() ) ) { addContainer( containerSpec ); } } containerSpecSelectedEvent.fire( new ContainerSpecSelected( firstContainerSpec ) ); } for ( final ServerInstanceKey serverInstanceKey : serverTemplate.getServerInstanceKeys() ) { addServerInstance( serverInstanceKey ); } } } | ServerTemplatePresenter { public void setup( final ServerTemplate serverTemplate, final ContainerSpec firstContainerSpec ) { view.clear(); this.serverTemplate = serverTemplate; view.setTemplate( serverTemplate.getId(), serverTemplate.getName() ); view.setProcessCapability( serverTemplate.getCapabilities().contains( Capability.PROCESS.toString() ) ); view.setRulesCapability( serverTemplate.getCapabilities().contains( Capability.RULE.toString() ) ); view.setPlanningCapability( serverTemplate.getCapabilities().contains( Capability.PLANNING.toString() ) ); if ( firstContainerSpec != null ) { addContainer( firstContainerSpec ); for ( final ContainerSpec containerSpec : serverTemplate.getContainersSpec() ) { if ( !containerSpec.getId().equals( firstContainerSpec.getId() ) ) { addContainer( containerSpec ); } } containerSpecSelectedEvent.fire( new ContainerSpecSelected( firstContainerSpec ) ); } for ( final ServerInstanceKey serverInstanceKey : serverTemplate.getServerInstanceKeys() ) { addServerInstance( serverInstanceKey ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); } | ServerTemplatePresenter { public void setup( final ServerTemplate serverTemplate, final ContainerSpec firstContainerSpec ) { view.clear(); this.serverTemplate = serverTemplate; view.setTemplate( serverTemplate.getId(), serverTemplate.getName() ); view.setProcessCapability( serverTemplate.getCapabilities().contains( Capability.PROCESS.toString() ) ); view.setRulesCapability( serverTemplate.getCapabilities().contains( Capability.RULE.toString() ) ); view.setPlanningCapability( serverTemplate.getCapabilities().contains( Capability.PLANNING.toString() ) ); if ( firstContainerSpec != null ) { addContainer( firstContainerSpec ); for ( final ContainerSpec containerSpec : serverTemplate.getContainersSpec() ) { if ( !containerSpec.getId().equals( firstContainerSpec.getId() ) ) { addContainer( containerSpec ); } } containerSpecSelectedEvent.fire( new ContainerSpecSelected( firstContainerSpec ) ); } for ( final ServerInstanceKey serverInstanceKey : serverTemplate.getServerInstanceKeys() ) { addServerInstance( serverInstanceKey ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } | ServerTemplatePresenter { public void setup( final ServerTemplate serverTemplate, final ContainerSpec firstContainerSpec ) { view.clear(); this.serverTemplate = serverTemplate; view.setTemplate( serverTemplate.getId(), serverTemplate.getName() ); view.setProcessCapability( serverTemplate.getCapabilities().contains( Capability.PROCESS.toString() ) ); view.setRulesCapability( serverTemplate.getCapabilities().contains( Capability.RULE.toString() ) ); view.setPlanningCapability( serverTemplate.getCapabilities().contains( Capability.PLANNING.toString() ) ); if ( firstContainerSpec != null ) { addContainer( firstContainerSpec ); for ( final ContainerSpec containerSpec : serverTemplate.getContainersSpec() ) { if ( !containerSpec.getId().equals( firstContainerSpec.getId() ) ) { addContainer( containerSpec ); } } containerSpecSelectedEvent.fire( new ContainerSpecSelected( firstContainerSpec ) ); } for ( final ServerInstanceKey serverInstanceKey : serverTemplate.getServerInstanceKeys() ) { addServerInstance( serverInstanceKey ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init(this); } | BodyPresenter { @PostConstruct public void init() { view.init(this); } } | BodyPresenter { @PostConstruct public void init() { view.init(this); } @Inject BodyPresenter(final View view,
final ManagedInstance<NotificationPresenter> presenterProvider); } | BodyPresenter { @PostConstruct public void init() { view.init(this); } @Inject BodyPresenter(final View view,
final ManagedInstance<NotificationPresenter> presenterProvider); @PostConstruct void init(); View getView(); void setup(final Collection<Message> messages); } | BodyPresenter { @PostConstruct public void init() { view.init(this); } @Inject BodyPresenter(final View view,
final ManagedInstance<NotificationPresenter> presenterProvider); @PostConstruct void init(); View getView(); void setup(final Collection<Message> messages); } |
@Test public void testSetup() { final Message message = mock( Message.class ); presenter.setup( Arrays.asList( message ) ); verify( notificationPresenter ).setup( message ); verify(view).clear(); verify( view ).addNotification( notificationPresenter.getView() ); } | public void setup(final Collection<Message> messages) { checkNotNull("messages", messages); view.clear(); if (messages.isEmpty()) { view.addNotification(setupNotification(null).getView()); } else { for (final Message message : messages) { view.addNotification(setupNotification(message).getView()); } } } | BodyPresenter { public void setup(final Collection<Message> messages) { checkNotNull("messages", messages); view.clear(); if (messages.isEmpty()) { view.addNotification(setupNotification(null).getView()); } else { for (final Message message : messages) { view.addNotification(setupNotification(message).getView()); } } } } | BodyPresenter { public void setup(final Collection<Message> messages) { checkNotNull("messages", messages); view.clear(); if (messages.isEmpty()) { view.addNotification(setupNotification(null).getView()); } else { for (final Message message : messages) { view.addNotification(setupNotification(message).getView()); } } } @Inject BodyPresenter(final View view,
final ManagedInstance<NotificationPresenter> presenterProvider); } | BodyPresenter { public void setup(final Collection<Message> messages) { checkNotNull("messages", messages); view.clear(); if (messages.isEmpty()) { view.addNotification(setupNotification(null).getView()); } else { for (final Message message : messages) { view.addNotification(setupNotification(message).getView()); } } } @Inject BodyPresenter(final View view,
final ManagedInstance<NotificationPresenter> presenterProvider); @PostConstruct void init(); View getView(); void setup(final Collection<Message> messages); } | BodyPresenter { public void setup(final Collection<Message> messages) { checkNotNull("messages", messages); view.clear(); if (messages.isEmpty()) { view.addNotification(setupNotification(null).getView()); } else { for (final Message message : messages) { view.addNotification(setupNotification(message).getView()); } } } @Inject BodyPresenter(final View view,
final ManagedInstance<NotificationPresenter> presenterProvider); @PostConstruct void init(); View getView(); void setup(final Collection<Message> messages); } |
@Test public void testInit() { assertEquals( view, presenter.getView() ); } | public View getView() { return view; } | NotificationPresenter { public View getView() { return view; } } | NotificationPresenter { public View getView() { return view; } @Inject NotificationPresenter(final View view); } | NotificationPresenter { public View getView() { return view; } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } | NotificationPresenter { public View getView() { return view; } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } |
@Test public void testSetup() { presenter.setupOk(); verify( view ).setupOk(); } | public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } |
@Test public void testSetupOk() { final Message message = new Message(); message.setSeverity( Severity.INFO ); presenter.setup( message ); verify( view ).setupOk(); } | public void setupOk() { view.setupOk(); } | NotificationPresenter { public void setupOk() { view.setupOk(); } } | NotificationPresenter { public void setupOk() { view.setupOk(); } @Inject NotificationPresenter(final View view); } | NotificationPresenter { public void setupOk() { view.setupOk(); } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } | NotificationPresenter { public void setupOk() { view.setupOk(); } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } |
@Test public void testSetupEmptyMessage() { final Message message = new Message(); message.setSeverity( Severity.ERROR ); presenter.setup( message ); verify( view ).setup( NotificationType.ERROR, "0" ); } | public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } |
@Test public void testSetupSingleMessage() { final Message message = new Message( Severity.ERROR, "single error" ); presenter.setup( message ); verify( view ).setup( NotificationType.ERROR, "1", "1: single error" ); } | public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } |
@Test public void testSetupSingleEmptyMessage() { final Message message = new Message( Severity.ERROR, "" ); presenter.setup( message ); verify( view ).setup( NotificationType.ERROR, "0", "" ); } | public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } |
@Test public void testSetupMultiMessage() { final Message message = new Message( Severity.WARN, Arrays.asList( "first error", "second error" ) ); presenter.setup( message ); verify( view ).setup( NotificationType.WARNING, "2", "1: first error\n2: second error" ); } | public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } | NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message); } |
@Test public void testCanvasCommandAllow() { setupCommand(0, uiModel.getRow(0)); final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.allow(handler)); } | @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler context) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { uiModel.moveRowsTo(index, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context) { uiModel.moveRowsTo(oldIndex, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler context) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { uiModel.moveRowsTo(index, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context) { uiModel.moveRowsTo(oldIndex, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler context) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { uiModel.moveRowsTo(index, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context) { uiModel.moveRowsTo(oldIndex, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler context) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { uiModel.moveRowsTo(index, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context) { uiModel.moveRowsTo(oldIndex, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } | MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler context) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { uiModel.moveRowsTo(index, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context) { uiModel.moveRowsTo(oldIndex, rows); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); } |
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } | @PostConstruct public void init() { view.init( this ); } | CardPresenter { @PostConstruct public void init() { view.init( this ); } } | CardPresenter { @PostConstruct public void init() { view.init( this ); } @Inject CardPresenter( final View view ); } | CardPresenter { @PostConstruct public void init() { view.init( this ); } @Inject CardPresenter( final View view ); @PostConstruct void init(); View getView(); void addTitle( final TitlePresenter titlePresenter ); void addBody( final BodyPresenter bodyPresenter ); void addFooter( final FooterPresenter footerPresenter ); } | CardPresenter { @PostConstruct public void init() { view.init( this ); } @Inject CardPresenter( final View view ); @PostConstruct void init(); View getView(); void addTitle( final TitlePresenter titlePresenter ); void addBody( final BodyPresenter bodyPresenter ); void addFooter( final FooterPresenter footerPresenter ); } |
@Test public void testAddTitle() { TitlePresenter titlePresenter = mock( TitlePresenter.class ); presenter.addTitle( titlePresenter ); verify( titlePresenter ).getView(); verify( view ).add( titlePresenter.getView() ); } | public void addTitle( final TitlePresenter titlePresenter ) { view.add( titlePresenter.getView() ); } | CardPresenter { public void addTitle( final TitlePresenter titlePresenter ) { view.add( titlePresenter.getView() ); } } | CardPresenter { public void addTitle( final TitlePresenter titlePresenter ) { view.add( titlePresenter.getView() ); } @Inject CardPresenter( final View view ); } | CardPresenter { public void addTitle( final TitlePresenter titlePresenter ) { view.add( titlePresenter.getView() ); } @Inject CardPresenter( final View view ); @PostConstruct void init(); View getView(); void addTitle( final TitlePresenter titlePresenter ); void addBody( final BodyPresenter bodyPresenter ); void addFooter( final FooterPresenter footerPresenter ); } | CardPresenter { public void addTitle( final TitlePresenter titlePresenter ) { view.add( titlePresenter.getView() ); } @Inject CardPresenter( final View view ); @PostConstruct void init(); View getView(); void addTitle( final TitlePresenter titlePresenter ); void addBody( final BodyPresenter bodyPresenter ); void addFooter( final FooterPresenter footerPresenter ); } |
@Test public void testAddBody() { BodyPresenter bodyPresenter = mock( BodyPresenter.class ); presenter.addBody( bodyPresenter ); verify( bodyPresenter ).getView(); verify( view ).add( bodyPresenter.getView() ); } | public void addBody( final BodyPresenter bodyPresenter ) { view.add( bodyPresenter.getView() ); } | CardPresenter { public void addBody( final BodyPresenter bodyPresenter ) { view.add( bodyPresenter.getView() ); } } | CardPresenter { public void addBody( final BodyPresenter bodyPresenter ) { view.add( bodyPresenter.getView() ); } @Inject CardPresenter( final View view ); } | CardPresenter { public void addBody( final BodyPresenter bodyPresenter ) { view.add( bodyPresenter.getView() ); } @Inject CardPresenter( final View view ); @PostConstruct void init(); View getView(); void addTitle( final TitlePresenter titlePresenter ); void addBody( final BodyPresenter bodyPresenter ); void addFooter( final FooterPresenter footerPresenter ); } | CardPresenter { public void addBody( final BodyPresenter bodyPresenter ) { view.add( bodyPresenter.getView() ); } @Inject CardPresenter( final View view ); @PostConstruct void init(); View getView(); void addTitle( final TitlePresenter titlePresenter ); void addBody( final BodyPresenter bodyPresenter ); void addFooter( final FooterPresenter footerPresenter ); } |
@Test public void testAddFooter() { FooterPresenter footerPresenter = mock( FooterPresenter.class ); presenter.addFooter( footerPresenter ); verify( footerPresenter ).getView(); verify( view ).add( footerPresenter.getView() ); } | public void addFooter( final FooterPresenter footerPresenter ) { view.add( footerPresenter.getView() ); } | CardPresenter { public void addFooter( final FooterPresenter footerPresenter ) { view.add( footerPresenter.getView() ); } } | CardPresenter { public void addFooter( final FooterPresenter footerPresenter ) { view.add( footerPresenter.getView() ); } @Inject CardPresenter( final View view ); } | CardPresenter { public void addFooter( final FooterPresenter footerPresenter ) { view.add( footerPresenter.getView() ); } @Inject CardPresenter( final View view ); @PostConstruct void init(); View getView(); void addTitle( final TitlePresenter titlePresenter ); void addBody( final BodyPresenter bodyPresenter ); void addFooter( final FooterPresenter footerPresenter ); } | CardPresenter { public void addFooter( final FooterPresenter footerPresenter ) { view.add( footerPresenter.getView() ); } @Inject CardPresenter( final View view ); @PostConstruct void init(); View getView(); void addTitle( final TitlePresenter titlePresenter ); void addBody( final BodyPresenter bodyPresenter ); void addFooter( final FooterPresenter footerPresenter ); } |
@Test public void testInit() { assertEquals(view, presenter.getView()); } | public View getView() { return view; } | FooterPresenter { public View getView() { return view; } } | FooterPresenter { public View getView() { return view; } @Inject FooterPresenter(final View view); } | FooterPresenter { public View getView() { return view; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { public View getView() { return view; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
@Test public void testSetup() { final String url = "url"; final String version = "1.0.1"; presenter.setup(url, version); verify(presenter).setupVersion(version); verify(presenter).setupUrl(url); } | public void setup(final String url, final String version) { setupVersion(version); setupUrl(url); } | FooterPresenter { public void setup(final String url, final String version) { setupVersion(version); setupUrl(url); } } | FooterPresenter { public void setup(final String url, final String version) { setupVersion(version); setupUrl(url); } @Inject FooterPresenter(final View view); } | FooterPresenter { public void setup(final String url, final String version) { setupVersion(version); setupUrl(url); } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { public void setup(final String url, final String version) { setupVersion(version); setupUrl(url); } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
@Test public void testSetupVersion() { final String version = "1.0.1"; presenter.setupVersion(version); verify(view).setupVersion(version); } | void setupVersion(final String version) { view.setupVersion(version); } | FooterPresenter { void setupVersion(final String version) { view.setupVersion(version); } } | FooterPresenter { void setupVersion(final String version) { view.setupVersion(version); } @Inject FooterPresenter(final View view); } | FooterPresenter { void setupVersion(final String version) { view.setupVersion(version); } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { void setupVersion(final String version) { view.setupVersion(version); } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
@Test public void testMakeOnSuccess() { final String url = "http: doCallRealMethod().when(presenter).makeOnSuccess(url); presenter.makeOnSuccess(url).execute(); verify(view).setupUrl(url); } | Command makeOnSuccess(final String url) { return () -> view.setupUrl(url); } | FooterPresenter { Command makeOnSuccess(final String url) { return () -> view.setupUrl(url); } } | FooterPresenter { Command makeOnSuccess(final String url) { return () -> view.setupUrl(url); } @Inject FooterPresenter(final View view); } | FooterPresenter { Command makeOnSuccess(final String url) { return () -> view.setupUrl(url); } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { Command makeOnSuccess(final String url) { return () -> view.setupUrl(url); } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
@Test public void testMakeOnError() { doCallRealMethod().when(presenter).makeOnError(); presenter.makeOnError().execute(); verify(view).hideUrlElements(); } | Command makeOnError() { return view::hideUrlElements; } | FooterPresenter { Command makeOnError() { return view::hideUrlElements; } } | FooterPresenter { Command makeOnError() { return view::hideUrlElements; } @Inject FooterPresenter(final View view); } | FooterPresenter { Command makeOnError() { return view::hideUrlElements; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { Command makeOnError() { return view::hideUrlElements; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
@Test public void testMakeRequest() { final String url = "http: final String none = "none"; final RequestCallback callback = mock(RequestCallback.class); final String expectedHTTPMethod = RequestBuilder.GET.toString(); doReturn(callback).when(presenter).makeCallback(onSuccess, onError); final RequestBuilder builder = presenter.makeRequest(url, onSuccess, onError); assertEquals(expectedHTTPMethod, builder.getHTTPMethod()); assertEquals(url, builder.getUrl()); assertEquals(none, builder.getUser()); assertEquals(none, builder.getPassword()); assertEquals(callback, builder.getCallback()); assertEquals("*/*", builder.getHeader("Accept")); } | RequestBuilder makeRequest(final String url, final Command onSuccess, final Command onError) { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); final String none = "none"; builder.setUser(none); builder.setPassword(none); builder.setCallback(makeCallback(onSuccess, onError)); builder.setHeader("Accept", "*/*"); return builder; } | FooterPresenter { RequestBuilder makeRequest(final String url, final Command onSuccess, final Command onError) { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); final String none = "none"; builder.setUser(none); builder.setPassword(none); builder.setCallback(makeCallback(onSuccess, onError)); builder.setHeader("Accept", "*/*"); return builder; } } | FooterPresenter { RequestBuilder makeRequest(final String url, final Command onSuccess, final Command onError) { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); final String none = "none"; builder.setUser(none); builder.setPassword(none); builder.setCallback(makeCallback(onSuccess, onError)); builder.setHeader("Accept", "*/*"); return builder; } @Inject FooterPresenter(final View view); } | FooterPresenter { RequestBuilder makeRequest(final String url, final Command onSuccess, final Command onError) { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); final String none = "none"; builder.setUser(none); builder.setPassword(none); builder.setCallback(makeCallback(onSuccess, onError)); builder.setHeader("Accept", "*/*"); return builder; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { RequestBuilder makeRequest(final String url, final Command onSuccess, final Command onError) { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); final String none = "none"; builder.setUser(none); builder.setPassword(none); builder.setCallback(makeCallback(onSuccess, onError)); builder.setHeader("Accept", "*/*"); return builder; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
@Test public void testGraphCommandAllow() { makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); } | @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } | DeleteRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } } | DeleteRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationColumnCommand(final Relation relation,
final GridData uiModel,
final int uiColumnIndex,
final RelationUIModelMapper uiModelMapper,
final org.uberfire.mvp.Command executeCanvasOperation,
final org.uberfire.mvp.Command undoCanvasOperation); } | DeleteRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationColumnCommand(final Relation relation,
final GridData uiModel,
final int uiColumnIndex,
final RelationUIModelMapper uiModelMapper,
final org.uberfire.mvp.Command executeCanvasOperation,
final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation(); } | DeleteRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationColumnCommand(final Relation relation,
final GridData uiModel,
final int uiColumnIndex,
final RelationUIModelMapper uiModelMapper,
final org.uberfire.mvp.Command executeCanvasOperation,
final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation(); } |
@Test public void testCallbackOnError() { final Throwable throwable = mock(Throwable.class); final RequestCallback callback = presenter.makeCallback(onSuccess, onError); callback.onError(request, throwable); verify(onError).execute(); verify(onSuccess, never()).execute(); } | RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } | FooterPresenter { RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } } | FooterPresenter { RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } @Inject FooterPresenter(final View view); } | FooterPresenter { RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
@Test public void testIsKieServerAccessibleWhenStatusCodeIs200() { when(response.getStatusCode()).thenReturn(200); assertTrue(presenter.isKieServerAccessible(response)); } | boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } | FooterPresenter { boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } } | FooterPresenter { boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } @Inject FooterPresenter(final View view); } | FooterPresenter { boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
@Test public void testIsKieServerAccessibleWhenStatusCodeIs401() { when(response.getStatusCode()).thenReturn(401); assertTrue(presenter.isKieServerAccessible(response)); } | boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } | FooterPresenter { boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } } | FooterPresenter { boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } @Inject FooterPresenter(final View view); } | FooterPresenter { boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } | FooterPresenter { boolean isKieServerAccessible(final Response response) { final int statusCode = response.getStatusCode(); return statusCode == SC_OK || statusCode == SC_UNAUTHORIZED; } @Inject FooterPresenter(final View view); View getView(); void setup(final String url,
final String version); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.