method2testcases
stringlengths 118
6.63k
|
---|
### Question:
PersistenceDescriptorEditorServiceImpl extends KieService<PersistenceDescriptorEditorContent> implements PersistenceDescriptorEditorService { @Override public Path saveAndRename(final Path path, final String newFileName, final Metadata metadata, final PersistenceDescriptorEditorContent content, final String comment) { return saveAndRenameService.saveAndRename(path, newFileName, metadata, content, comment); } @Inject PersistenceDescriptorEditorServiceImpl(final @Named("ioStrategy") IOService ioService,
final PersistenceDescriptorService descriptorService,
final RenameService renameService,
final SaveAndRenameServiceImpl<PersistenceDescriptorEditorContent, Metadata> saveAndRenameService); @PostConstruct void init(); @Override PersistenceDescriptorEditorContent loadContent(Path path, boolean createIfNotExists); @Override Path save(Path path, PersistenceDescriptorEditorContent content, Metadata metadata, String comment); Pair<Path, Boolean> createIfNotExists(Path path); @Override Path saveAndRename(final Path path,
final String newFileName,
final Metadata metadata,
final PersistenceDescriptorEditorContent content,
final String comment); @Override Path rename(final Path path,
final String newName,
final String comment); }### Answer:
@Test public void testSaveAndRename() throws Exception { final Path path = mock(Path.class); final Path expectedPath = mock(Path.class); final Metadata metadata = mock(Metadata.class); final PersistenceDescriptorEditorContent content = mock(PersistenceDescriptorEditorContent.class); final String newName = "newName"; final String comment = "comment"; doReturn(expectedPath).when(saveAndRenameService).saveAndRename(path, newName, metadata, content, comment); final Path actualPath = service.saveAndRename(path, newName, metadata, content, comment); verify(saveAndRenameService).saveAndRename(path, newName, metadata, content, comment); assertEquals(expectedPath, actualPath); } |
### Question:
PersistenceDescriptorEditorServiceImpl extends KieService<PersistenceDescriptorEditorContent> implements PersistenceDescriptorEditorService { @Override public Path rename(final Path path, final String newName, final String comment) { return renameService.rename(path, newName, comment); } @Inject PersistenceDescriptorEditorServiceImpl(final @Named("ioStrategy") IOService ioService,
final PersistenceDescriptorService descriptorService,
final RenameService renameService,
final SaveAndRenameServiceImpl<PersistenceDescriptorEditorContent, Metadata> saveAndRenameService); @PostConstruct void init(); @Override PersistenceDescriptorEditorContent loadContent(Path path, boolean createIfNotExists); @Override Path save(Path path, PersistenceDescriptorEditorContent content, Metadata metadata, String comment); Pair<Path, Boolean> createIfNotExists(Path path); @Override Path saveAndRename(final Path path,
final String newFileName,
final Metadata metadata,
final PersistenceDescriptorEditorContent content,
final String comment); @Override Path rename(final Path path,
final String newName,
final String comment); }### Answer:
@Test public void testRename() throws Exception { final Path path = mock(Path.class); final Path expectedPath = mock(Path.class); final String newName = "newName"; final String comment = "comment"; doReturn(expectedPath).when(renameService).rename(path, newName, comment); final Path actualPath = service.rename(path, newName, comment); verify(renameService).rename(path, newName, comment); assertEquals(expectedPath, actualPath); } |
### Question:
ProjectImportsScreenPresenter extends KieEditor<ProjectImports> { @Override protected Promise<Void> makeMenuBar() { if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { final ParameterizedCommand<Boolean> onSave = withComments -> { saveWithComments = withComments; saveAction(); }; this.fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(onSave)) .addCopy(versionRecordManager.getCurrentPath(), getRenameValidator()) .addRename(getSaveAndRename()) .addDelete(versionRecordManager.getPathToLatest(), getRenameValidator()); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } ProjectImportsScreenPresenter(); @Inject ProjectImportsScreenPresenter(final ProjectImportsScreenView view,
final Caller<ProjectImportsService> importsService,
final Others category); @OnStartup void init(final ObservablePath path,
final PlaceRequest place); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartView IsWidget asWidget(); @OnClose @Override void onClose(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @OnMayClose boolean mayClose(); static final String EDITOR_ID; }### Answer:
@Test public void testMakeMenuBar() { doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject(); doReturn(promises.resolve(true)).when(projectController).canUpdateProject(any()); presenter.makeMenuBar(); verify(menuBuilder).addSave(any(MenuItem.class)); verify(menuBuilder).addCopy(any(Path.class), any(AssetUpdateValidator.class)); verify(menuBuilder).addRename(any(Command.class)); verify(menuBuilder).addDelete(any(Path.class), any(AssetUpdateValidator.class)); verify(menuBuilder).addNewTopLevelMenu(alertsButtonMenuItem); verify(presenter).addDownloadMenuItem(menuBuilder); }
@Test public void testMakeMenuBarWithoutUpdateProjectPermission() { doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject(); doReturn(promises.resolve(false)).when(projectController).canUpdateProject(any()); presenter.makeMenuBar(); verify(menuBuilder, never()).addSave(any(MenuItem.class)); verify(menuBuilder, never()).addCopy(any(Path.class), any(AssetUpdateValidator.class)); verify(menuBuilder, never()).addRename(any(Command.class)); verify(menuBuilder, never()).addDelete(any(Path.class), any(AssetUpdateValidator.class)); verify(menuBuilder).addNewTopLevelMenu(alertsButtonMenuItem); } |
### Question:
ProjectImportsScreenPresenter extends KieEditor<ProjectImports> { @Override protected Supplier<ProjectImports> getContentSupplier() { return () -> model; } ProjectImportsScreenPresenter(); @Inject ProjectImportsScreenPresenter(final ProjectImportsScreenView view,
final Caller<ProjectImportsService> importsService,
final Others category); @OnStartup void init(final ObservablePath path,
final PlaceRequest place); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartView IsWidget asWidget(); @OnClose @Override void onClose(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @OnMayClose boolean mayClose(); static final String EDITOR_ID; }### Answer:
@Test public void testGetContentSupplier() { final ProjectImports content = mock(ProjectImports.class); presenter.setModel(content); final Supplier<ProjectImports> contentSupplier = presenter.getContentSupplier(); assertEquals(content, contentSupplier.get()); } |
### Question:
ProjectImportsScreenPresenter extends KieEditor<ProjectImports> { @Override protected Caller<? extends SupportsSaveAndRename<ProjectImports, Metadata>> getSaveAndRenameServiceCaller() { return importsService; } ProjectImportsScreenPresenter(); @Inject ProjectImportsScreenPresenter(final ProjectImportsScreenView view,
final Caller<ProjectImportsService> importsService,
final Others category); @OnStartup void init(final ObservablePath path,
final PlaceRequest place); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartView IsWidget asWidget(); @OnClose @Override void onClose(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @OnMayClose boolean mayClose(); static final String EDITOR_ID; }### Answer:
@Test public void testGetSaveAndRenameServiceCaller() { final Caller<? extends SupportsSaveAndRename<ProjectImports, Metadata>> serviceCaller = presenter.getSaveAndRenameServiceCaller(); assertEquals(this.serviceCaller, serviceCaller); } |
### Question:
HomePresenter { public void setup() { profilePreferences.load(loadedProfilePreferences -> { modelProvider.initialize(()->{ final HomeModel model = modelProvider.get(loadedProfilePreferences); view.setWelcome(model.getWelcome()); view.setDescription(model.getDescription()); view.setBackgroundImageUrl(model.getBackgroundImageUrl()); model.getShortcuts().forEach(shortcut -> { final ShortcutPresenter shortcutPresenter = shortcutPresenters.get(); shortcutPresenter.setup(shortcut); view.addShortcut(shortcutPresenter); }); }); }, RuntimeException::new); } @Inject HomePresenter(final View view,
final TranslationService translationService,
final HomeModelProvider modelProvider,
final ManagedInstance<ShortcutPresenter> shortcutPresenters,
final ProfilePreferences profilePreferences); void setup(); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView UberElement<HomePresenter> getView(); }### Answer:
@Test public void setupTest() { presenter.setup(); verify(view).setWelcome("welcome"); verify(view).setDescription("description"); verify(view).setBackgroundImageUrl("backgroundImageUrl"); verify(view, times(3)).addShortcut(any()); } |
### Question:
ShortcutPresenter { public void setup(final HomeShortcut shortcut) { setupIcon(shortcut); view.setHeading(shortcut.getHeading()); setupAction(shortcut); setupSubHeading(shortcut); } @Inject ShortcutPresenter(final View view,
final ShortcutHelper shortcutHelper,
final ManagedInstance<ShortcutSubHeadingLinkPresenter> linkPresenters,
final ManagedInstance<ShortcutSubHeadingTextPresenter> textPresenters); @PostConstruct void init(); void setup(final HomeShortcut shortcut); View getView(); }### Answer:
@Test public void setupTest() { final HomeShortcut shortcut = ModelUtils.makeShortcut("iconCss iconCss2", "heading", "subHeadingPrefix{0}subHeadingSuffix", mock(Command.class)); final HomeShortcutLink link = new HomeShortcutLink("label", "perspectiveIdentifier"); shortcut.addLink(link); presenter.setup(shortcut); verify(view).addIconClass("iconCss"); verify(view).addIconClass("iconCss2"); verify(view).setHeading(shortcut.getHeading()); verify(view).setAction(shortcut.getOnClickCommand()); verify(textPresenter).setup(shortcut.getSubHeading(), 1); verify(textPresenter).setup(shortcut.getSubHeading(), 2); verify(view, times(2)).addSubHeadingChild(textPresenter.getView()); verify(linkPresenter).setup(link); verify(view).addSubHeadingChild(linkPresenter.getView()); }
@Test public void setupWithNoActionPermissionTest() { doReturn(false).when(shortcutHelper).authorize(any(HomeShortcut.class)); final HomeShortcut shortcut = ModelUtils.makeShortcut("iconCss", "heading", "subHeadingPrefix", mock(Command.class)); presenter.setup(shortcut); verify(view, never()).setAction(shortcut.getOnClickCommand()); } |
### Question:
ShortcutSubHeadingLinkPresenter { public void setup(final HomeShortcutLink link) { this.link = link; view.setLabel(link.getLabel()); if (!shortcutHelper.authorize(link.getPerspectiveIdentifier())) { view.disable(); } } @Inject ShortcutSubHeadingLinkPresenter(final View view,
final ShortcutHelper shortcutHelper); @PostConstruct void init(); void setup(final HomeShortcutLink link); View getView(); }### Answer:
@Test public void setupWithPermissionTest() { doReturn(true).when(shortcutHelper).authorize("perspectiveIdentifier"); presenter.setup(new HomeShortcutLink("label", "perspectiveIdentifier")); verify(view).setLabel("label"); verify(view, never()).disable(); }
@Test public void setupWithoutPermissionTest() { doReturn(false).when(shortcutHelper).authorize("perspectiveIdentifier"); presenter.setup(new HomeShortcutLink("label", "perspectiveIdentifier")); verify(view).setLabel("label"); verify(view).disable(); } |
### Question:
ShortcutSubHeadingLinkPresenter { void goToPerspective() { shortcutHelper.goTo(link.getPerspectiveIdentifier()); } @Inject ShortcutSubHeadingLinkPresenter(final View view,
final ShortcutHelper shortcutHelper); @PostConstruct void init(); void setup(final HomeShortcutLink link); View getView(); }### Answer:
@Test public void goToPerspectiveTest() { presenter.setup(new HomeShortcutLink("label", "perspectiveIdentifier")); presenter.goToPerspective(); verify(shortcutHelper).goTo("perspectiveIdentifier"); } |
### Question:
ShortcutSubHeadingTextPresenter { public void setup(final String text, final int part) { view.setText(shortcutHelper.getPart(text, part)); } @Inject ShortcutSubHeadingTextPresenter(final View view,
final ShortcutHelper shortcutHelper); @PostConstruct void init(); void setup(final String text,
final int part); View getView(); }### Answer:
@Test public void setupTest() { doReturn("parsedText").when(shortcutHelper).getPart(anyString(), anyInt()); presenter.setup("text", 1); verify(view).setText("parsedText"); } |
### Question:
ShortcutHelper { public String getPart(final String text, final int part) { if (part < 1) { throw new RuntimeException("The first part is the number one."); } int beginIndex = 0; if (part > 1) { final int i = part - 2; final String s = "{" + i + "}"; beginIndex = text.indexOf(s); if (beginIndex < 0) { throw new RuntimeException("The translation " + text + " is missing parameters."); } else { beginIndex += String.valueOf(i).length() + 2; } } final int i2 = part - 1; final String s2 = "{" + i2 + "}"; int endIndex = text.indexOf(s2); if (endIndex < 0) { endIndex = text.length(); } return text.substring(beginIndex, endIndex); } ShortcutHelper(); @Inject ShortcutHelper(final AuthorizationManager authorizationManager,
final User user,
final PlaceManager placeManager); String getPart(final String text,
final int part); void goTo(final String perspectiveIdentifier); boolean authorize(final String perspective); boolean authorize(final HomeShortcut shortcut); }### Answer:
@Test(expected = RuntimeException.class) public void partLessThanOneTest() { shortcutHelper.getPart("text", 0); }
@Test(expected = RuntimeException.class) public void nonexistentSecondPartTest() { shortcutHelper.getPart("text", 2); }
@Test(expected = RuntimeException.class) public void nonexistentThirdPartTest() { shortcutHelper.getPart("text{0}more-text", 3); }
@Test public void onlyOnePartTest() { final String text = "first-part"; final String firstPart = shortcutHelper.getPart(text, 1); assertEquals("first-part", firstPart); }
@Test public void threeValidPartsTest() { final String text = "first-part{0}second-part{1}third-part"; final String firstPart = shortcutHelper.getPart(text, 1); assertEquals("first-part", firstPart); final String secondPart = shortcutHelper.getPart(text, 2); assertEquals("second-part", secondPart); final String thirdPart = shortcutHelper.getPart(text, 3); assertEquals("third-part", thirdPart); } |
### Question:
ShortcutHelper { public boolean authorize(final String perspective) { return authorizationManager.authorize(new ResourceRef(perspective, PERSPECTIVE), user); } ShortcutHelper(); @Inject ShortcutHelper(final AuthorizationManager authorizationManager,
final User user,
final PlaceManager placeManager); String getPart(final String text,
final int part); void goTo(final String perspectiveIdentifier); boolean authorize(final String perspective); boolean authorize(final HomeShortcut shortcut); }### Answer:
@Test public void testAuthorizePositive() throws Exception { final String perspectiveId = "perspectiveId"; final ArgumentCaptor<ResourceRef> resourceRefArgumentCaptor = ArgumentCaptor.forClass(ResourceRef.class); doReturn(true).when(authorizationManager).authorize(any(ResourceRef.class), eq(user)); assertTrue(shortcutHelper.authorize(perspectiveId)); verify(authorizationManager).authorize(resourceRefArgumentCaptor.capture(), eq(user)); assertEquals(perspectiveId, resourceRefArgumentCaptor.getValue().getIdentifier()); assertEquals(ActivityResourceType.PERSPECTIVE, resourceRefArgumentCaptor.getValue().getResourceType()); }
@Test public void testAuthorizeNegative() throws Exception { final String perspectiveId = "perspectiveId"; doReturn(false).when(authorizationManager).authorize(any(ResourceRef.class), eq(user)); assertFalse(shortcutHelper.authorize(perspectiveId)); } |
### Question:
Convert { public static ServerInstanceKey toKey( final ServerInstance serverInstance ) { return new ServerInstanceKey( serverInstance.getServerTemplateId(), serverInstance.getServerName(), serverInstance.getServerInstanceId(), serverInstance.getUrl() ); } private Convert(); static ServerInstanceKey toKey( final ServerInstance serverInstance ); }### Answer:
@Test public void testToKey() { final String serverTemplateId = "serverTemplateId"; final String serverName = "serverName"; final String serverInstanceId = "serverInstanceId"; final String url = "url"; ServerInstance serverInstance = new ServerInstance( serverTemplateId, serverName, serverInstanceId, url, "version", new ArrayList<Message>(), new ArrayList<Container>() ); ServerInstanceKey key = Convert.toKey( serverInstance ); assertEquals( serverTemplateId, key.getServerTemplateId() ); assertEquals( serverName, key.getServerName() ); assertEquals( serverInstanceId, key.getServerInstanceId() ); assertEquals( url, key.getUrl() ); } |
### Question:
ServerManagementPerspective { public void onNewContainer( @Observes final AddNewContainer addNewContainer ) { if ( addNewContainer != null && addNewContainer.getServerTemplate() != null ) { newContainerWizard.clear(); newContainerWizard.setServerTemplate( addNewContainer.getServerTemplate() ); newContainerWizard.start(); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementPerspective( final Logger logger,
final NewServerTemplateWizard newServerTemplateWizard,
final NewContainerWizard newContainerWizard ); @Perspective PerspectiveDefinition buildPerspective(); void onNewTemplate( @Observes final AddNewServerTemplate addNewServerTemplate ); void onNewContainer( @Observes final AddNewContainer addNewContainer ); }### Answer:
@Test public void testOnNewContainer() { final ServerTemplate template = mock( ServerTemplate.class ); perspective.onNewContainer( new AddNewContainer( template ) ); verify( newContainerWizard ).clear(); verify( newContainerWizard ).setServerTemplate( eq( template ) ); verify( newContainerWizard ).start(); } |
### Question:
ServerManagementPerspective { public void onNewTemplate( @Observes final AddNewServerTemplate addNewServerTemplate ) { if ( addNewServerTemplate != null ) { newServerTemplateWizard.clear(); newServerTemplateWizard.start(); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementPerspective( final Logger logger,
final NewServerTemplateWizard newServerTemplateWizard,
final NewContainerWizard newContainerWizard ); @Perspective PerspectiveDefinition buildPerspective(); void onNewTemplate( @Observes final AddNewServerTemplate addNewServerTemplate ); void onNewContainer( @Observes final AddNewContainer addNewContainer ); }### Answer:
@Test public void testOnNewTemplate() { perspective.onNewTemplate( new AddNewServerTemplate() ); verify( newServerTemplateWizard ).clear(); verify( newServerTemplateWizard ).start(); } |
### Question:
ServerEmptyPresenter { @PostConstruct public void init() { view.init( this ); } @Inject ServerEmptyPresenter( final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent ); @PostConstruct void init(); View getView(); void addTemplate(); }### Answer:
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } |
### Question:
ServerEmptyPresenter { public void addTemplate() { addNewServerTemplateEvent.fire( new AddNewServerTemplate() ); } @Inject ServerEmptyPresenter( final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent ); @PostConstruct void init(); View getView(); void addTemplate(); }### Answer:
@Test public void testAddTemplate() { presenter.addTemplate(); verify( addNewServerTemplateEvent ).fire( any( AddNewServerTemplate.class ) ); } |
### Question:
ProcessConfigPagePresenter implements WizardPage { public void clear() { processConfigPresenter.clear(); } @Inject ProcessConfigPagePresenter( final ProcessConfigPresenter processConfigPresenter ); @Override String getTitle(); @Override void isComplete( final Callback<Boolean> callback ); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); ProcessConfig buildProcessConfig(); void clear(); }### Answer:
@Test public void testClear() { presenter.clear(); verify( processConfigPresenter ).clear(); } |
### Question:
ProcessConfigPagePresenter implements WizardPage { public ProcessConfig buildProcessConfig(){ return processConfigPresenter.buildProcessConfig(); } @Inject ProcessConfigPagePresenter( final ProcessConfigPresenter processConfigPresenter ); @Override String getTitle(); @Override void isComplete( final Callback<Boolean> callback ); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); ProcessConfig buildProcessConfig(); void clear(); }### Answer:
@Test public void testBuildProcessConfig() { presenter.buildProcessConfig(); verify( processConfigPresenter ).buildProcessConfig(); } |
### Question:
ProcessConfigPagePresenter implements WizardPage { @Override public void isComplete( final Callback<Boolean> callback ) { callback.callback( true ); } @Inject ProcessConfigPagePresenter( final ProcessConfigPresenter processConfigPresenter ); @Override String getTitle(); @Override void isComplete( final Callback<Boolean> callback ); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); ProcessConfig buildProcessConfig(); void clear(); }### Answer:
@Test public void testIsComplete() { final Callback<Boolean> callback = mock( Callback.class ); presenter.isComplete( callback ); verify( callback ).callback( true ); } |
### Question:
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public String getTitle() { return newTemplatePresenter.getView().getNewServerTemplateWizardTitle(); } NewServerTemplateWizard(); @Inject NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }### Answer:
@Test public void testTitle() { final String title = "title"; when( newTemplatePresenterView.getNewServerTemplateWizardTitle() ).thenReturn( title ); assertEquals( title, newServerTemplateWizard.getTitle() ); verify( newTemplatePresenterView ).getNewServerTemplateWizardTitle(); } |
### Question:
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public void complete() { final ServerTemplate newServerTemplate = buildServerTemplate(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void o ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS ) ); clear(); NewServerTemplateWizard.super.complete(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( newServerTemplate.getId() ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveError(), NotificationEvent.NotificationType.ERROR ) ); NewServerTemplateWizard.this.pageSelected( 0 ); NewServerTemplateWizard.this.start(); return false; } } ).saveServerTemplate( newServerTemplate ); } NewServerTemplateWizard(); @Inject NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }### Answer:
@Test public void testComplete() { ServerTemplate serverTemplate = new ServerTemplate("template-name", "template-name"); serverTemplate.setMode(KieServerMode.DEVELOPMENT); serverTemplate.setCapabilities(singletonList(Capability.PROCESS.toString())); when( newTemplatePresenter.isProcessCapabilityChecked() ).thenReturn( true ); when( newContainerFormPresenter.isEmpty() ).thenReturn( true ); when( newContainerFormPresenter.isEmpty() ).thenReturn( true ); when( newTemplatePresenter.getTemplateName() ).thenReturn( "template-name" ); final String successMessage = "SUCCESS"; when( newTemplatePresenterView.getNewServerTemplateWizardSaveSuccess() ).thenReturn( successMessage ); newServerTemplateWizard.complete(); ArgumentCaptor<ServerTemplate> serverTemplateCapture = ArgumentCaptor.forClass(ServerTemplate.class); verify(specManagementService).saveServerTemplate(serverTemplateCapture.capture()); assertEquals(KieServerMode.DEVELOPMENT, serverTemplateCapture.getValue().getMode()); verify( notification ).fire( new NotificationEvent( successMessage, NotificationEvent.NotificationType.SUCCESS ) ); verifyClear(); verify( serverTemplateListRefreshEvent ).fire( new ServerTemplateListRefresh( "template-name" ) ); doThrow( new RuntimeException() ).when( specManagementService ).saveServerTemplate( any( ServerTemplate.class ) ); final String errorMessage = "ERROR"; when( newTemplatePresenterView.getNewServerTemplateWizardSaveError() ).thenReturn( errorMessage ); newServerTemplateWizard.complete(); verify( notification ).fire( new NotificationEvent( errorMessage, NotificationEvent.NotificationType.ERROR ) ); verify( newServerTemplateWizard ).pageSelected( 0 ); verify( newServerTemplateWizard ).start(); verify( newContainerFormPresenter ).initialise(); } |
### Question:
NewServerTemplateWizard extends AbstractMultiPageWizard { public void clear() { newTemplatePresenter.clear(); newContainerFormPresenter.clear(); processConfigPagePresenter.clear(); pages.clear(); pages.add( newTemplatePresenter ); pages.add( newContainerFormPresenter ); } NewServerTemplateWizard(); @Inject NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }### Answer:
@Test public void testClear() { newServerTemplateWizard.clear(); verifyClear(); } |
### Question:
FindAllDmnAssetsQuery extends AbstractFindQuery implements NamedQuery { @Override public ResponseBuilder getResponseBuilder() { return responseBuilder; } @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; }### Answer:
@Test public void testGetResponseBuilder() { assertEquals(responseBuilder, query.getResponseBuilder()); } |
### Question:
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public void close() { super.close(); clear(); } NewServerTemplateWizard(); @Inject NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }### Answer:
@Test public void testClose() { newServerTemplateWizard.close(); verifyClear(); } |
### Question:
NewContainerWizard extends AbstractMultiPageWizard { @Override public String getTitle() { return newContainerFormPresenter.getView().getNewContainerWizardTitle(); } @Inject NewContainerWizard(final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<DependencyPathSelectedEvent> dependencyPathSelectedEvent,
final Caller<M2RepoService> m2RepoService,
final ConfirmPopup confirmPopup); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void setServerTemplate( final ServerTemplate serverTemplate ); void clear(); @Override void close(); @Override void complete(); void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event); @Override void pageSelected(final int pageNumber); }### Answer:
@Test public void testTitle() { final String title = "title"; when( newContainerFormPresenterView.getNewContainerWizardTitle() ).thenReturn( title ); assertEquals( title, newContainerWizard.getTitle() ); verify( newContainerFormPresenterView ).getNewContainerWizardTitle(); } |
### Question:
NewContainerWizard extends AbstractMultiPageWizard { public void clear() { newContainerFormPresenter.clear(); processConfigPagePresenter.clear(); pages.clear(); pages.add( newContainerFormPresenter ); isSelected = false; } @Inject NewContainerWizard(final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<DependencyPathSelectedEvent> dependencyPathSelectedEvent,
final Caller<M2RepoService> m2RepoService,
final ConfirmPopup confirmPopup); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void setServerTemplate( final ServerTemplate serverTemplate ); void clear(); @Override void close(); @Override void complete(); void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event); @Override void pageSelected(final int pageNumber); }### Answer:
@Test public void testClear() { newContainerWizard.clear(); verifyClear(); } |
### Question:
NewContainerWizard extends AbstractMultiPageWizard { public void setServerTemplate( final ServerTemplate serverTemplate ) { this.serverTemplate = serverTemplate; newContainerFormPresenter.setServerTemplate( serverTemplate ); pages.clear(); pages.add( newContainerFormPresenter ); if ( serverTemplate.getCapabilities().contains( Capability.PROCESS.toString() ) ) { pages.add( processConfigPagePresenter ); } } @Inject NewContainerWizard(final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<DependencyPathSelectedEvent> dependencyPathSelectedEvent,
final Caller<M2RepoService> m2RepoService,
final ConfirmPopup confirmPopup); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void setServerTemplate( final ServerTemplate serverTemplate ); void clear(); @Override void close(); @Override void complete(); void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event); @Override void pageSelected(final int pageNumber); }### Answer:
@Test public void testSetServerTemplate() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); serverTemplate.getCapabilities().add( Capability.PROCESS.toString() ); newContainerWizard.setServerTemplate( serverTemplate ); verify( newContainerFormPresenter ).setServerTemplate( serverTemplate ); assertEquals( 2, newContainerWizard.getPages().size() ); assertTrue( newContainerWizard.getPages().contains( newContainerFormPresenter ) ); assertTrue( newContainerWizard.getPages().contains( processConfigPagePresenter ) ); } |
### Question:
NewContainerWizard extends AbstractMultiPageWizard { @Override public void close() { super.close(); clear(); } @Inject NewContainerWizard(final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<DependencyPathSelectedEvent> dependencyPathSelectedEvent,
final Caller<M2RepoService> m2RepoService,
final ConfirmPopup confirmPopup); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void setServerTemplate( final ServerTemplate serverTemplate ); void clear(); @Override void close(); @Override void complete(); void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event); @Override void pageSelected(final int pageNumber); }### Answer:
@Test public void testClose() { newContainerWizard.close(); verifyClear(); } |
### Question:
AddRelationColumnCommand 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) { if (!uiModelColumn.isPresent()) { uiModelColumn = Optional.of(uiModelColumnSupplier.get()); } uiModel.insertColumn(uiColumnIndex, uiModelColumn.get()); for (int rowIndex = 0; rowIndex < relation.getRow().size(); rowIndex++) { uiModelMapper.fromDMNModel(rowIndex, uiColumnIndex); } updateParentInformation(); executeCanvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { uiModelColumn.ifPresent(uiModel::deleteColumn); updateParentInformation(); undoCanvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } AddRelationColumnCommand(final Relation relation,
final InformationItem informationItem,
final GridData uiModel,
final Supplier<RelationColumn> uiModelColumnSupplier,
final int uiColumnIndex,
final RelationUIModelMapper uiModelMapper,
final org.uberfire.mvp.Command executeCanvasOperation,
final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation(); }### Answer:
@Test public void testCanvasCommandAllow() { final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.allow(handler)); } |
### Question:
NewContainerWizard extends AbstractMultiPageWizard { public void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event){ this.isSelected = true; } @Inject NewContainerWizard(final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<DependencyPathSelectedEvent> dependencyPathSelectedEvent,
final Caller<M2RepoService> m2RepoService,
final ConfirmPopup confirmPopup); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void setServerTemplate( final ServerTemplate serverTemplate ); void clear(); @Override void close(); @Override void complete(); void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event); @Override void pageSelected(final int pageNumber); }### Answer:
@Test public void testOnDependencyPathSelectedEvent() { assertFalse(newContainerWizard.isSelected); newContainerWizard.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent("null", "test")); assertTrue(newContainerWizard.isSelected); } |
### Question:
NewContainerFormPresenter implements WizardPage { @PostConstruct public void init() { view.init(this); view.addContentChangeHandler(new ContentChangeHandler() { @Override public void onContentChange() { wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewContainerFormPresenter.this)); } }); } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }### Answer:
@Test public void testInit() { presenter.init(); final ContentChangeHandler contentChangeHandler = mock(ContentChangeHandler.class); presenter.addContentChangeHandler(contentChangeHandler); view.setVersion("1.0"); view.setArtifactId("artifact"); view.setGroupId("group"); verify(view).init(presenter); verify(wizardPageStatusChangeEvent, times(3)).fire(any(WizardPageStatusChangeEvent.class)); verify(contentChangeHandler, times(3)).onContentChange(); } |
### Question:
NewContainerFormPresenter implements WizardPage { public void clear() { serverTemplate = null; mode = Mode.OPTIONAL; view.clear(); } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }### Answer:
@Test public void testClear() { presenter.clear(); verify(view).clear(); assertEquals(NewContainerFormPresenter.Mode.OPTIONAL, presenter.getMode()); assertNull(presenter.getServerTemplate()); } |
### Question:
NewContainerFormPresenter implements WizardPage { public boolean isEmpty() { return view.getContainerName().trim().isEmpty() && view.getGroupId().trim().isEmpty() && view.getArtifactId().trim().isEmpty() && view.getVersion().trim().isEmpty(); } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }### Answer:
@Test public void testIsEmpty() { when(view.getContainerName()).thenReturn(" "); when(view.getGroupId()).thenReturn(" "); when(view.getArtifactId()).thenReturn(" "); when(view.getVersion()).thenReturn(" "); assertTrue(presenter.isEmpty()); } |
### Question:
NewContainerFormPresenter implements WizardPage { public boolean isValid() { if (mode.equals(Mode.OPTIONAL) && isEmpty()) { view.noErrors(); return true; } boolean hasError = false; if (isContainerNameValid()) { view.noErrorOnContainerName(); } else { view.errorOnContainerName(); hasError = true; } if (isGroupIdValid()) { view.noErrorOnGroupId(); } else { view.errorOnGroupId(); hasError = true; } if (isArtifactIdValid()) { view.noErrorOnArtifactId(); } else { view.errorOnArtifactId(); hasError = true; } if (isVersionValid()) { if (isArtifactSupportedByServer()) { view.noErrorOnVersion(); } else { view.errorOnVersion(); view.errorProductionModeSupportsDoesntSnapshots(); hasError = true; } } else { view.errorOnVersion(); hasError = true; } return !hasError; } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }### Answer:
@Test public void testIsValid() { when(view.getContainerName()).thenReturn(" ").thenReturn("containerName").thenReturn(""); when(view.getGroupId()).thenReturn(" ").thenReturn("groupId").thenReturn(""); when(view.getArtifactId()).thenReturn(" ").thenReturn("artifactId").thenReturn(""); when(view.getVersion()).thenReturn(" ").thenReturn("1.0").thenReturn(""); assertTrue(presenter.isValid()); verify(view).noErrors(); presenter.setServerTemplate(new ServerTemplate()); assertTrue(presenter.isValid()); verify(view).noErrorOnContainerName(); verify(view).noErrorOnGroupId(); verify(view).noErrorOnArtifactId(); verify(view).noErrorOnVersion(); assertFalse(presenter.isValid()); verify(view).errorOnContainerName(); verify(view).errorOnGroupId(); verify(view).errorOnArtifactId(); verify(view).errorOnVersion(); } |
### Question:
NewContainerFormPresenter implements WizardPage { void onDependencyPathSelectedEvent(@Observes final DependencyPathSelectedEvent event) { if (event != null && event.getContext() != null && event.getPath() != null) { if (event.getContext().equals(artifactListWidgetPresenter)) { m2RepoService.call(new RemoteCallback<GAV>() { @Override public void callback(GAV gav) { setAValidContainerName(gav.toString()); view.setGroupId(gav.getGroupId()); view.setArtifactId(gav.getArtifactId()); view.setVersion(gav.getVersion()); wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewContainerFormPresenter.this)); } }).loadGAVFromJar(event.getPath()); } } else { logger.warn("Illegal event argument."); } } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }### Answer:
@Test public void testOnDependencyPathSelectedEvent() { final String path = "org:kie:1.0"; final GAV gav = new GAV(path); when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav); when(view.getContainerName()).thenReturn("containerName"); when(view.getContainerAlias()).thenReturn("containerAlias"); when(view.getGroupId()).thenReturn(gav.getGroupId()); when(view.getArtifactId()).thenReturn(gav.getArtifactId()); when(view.getVersion()).thenReturn(gav.getVersion()); presenter.asWidget(); presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path)); verify(m2RepoService).loadGAVFromJar(path); verify(view).setGroupId(gav.getGroupId()); verify(view).setArtifactId(gav.getArtifactId()); verify(view).setVersion(gav.getVersion()); verify(wizardPageStatusChangeEvent).fire(any(WizardPageStatusChangeEvent.class)); final ContainerSpec containerSpec = presenter.buildContainerSpec("templateId", Collections.<Capability, ContainerConfig>emptyMap()); assertEquals(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()), containerSpec.getReleasedId()); assertEquals(KieContainerStatus.STOPPED, containerSpec.getStatus()); assertEquals("containerAlias", containerSpec.getContainerName()); assertEquals("containerName", containerSpec.getId()); } |
### Question:
NewTemplatePresenter implements WizardPage { @PostConstruct public void init() { this.view.init(this); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view.asWidget(), presenter.asWidget() ); assertEquals( view, presenter.getView() ); } |
### Question:
NewTemplatePresenter implements WizardPage { public boolean isTemplateNameValid() { final String templateName = view.getTemplateName(); return templateName == null ? false : !templateName.trim().isEmpty(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testIsTemplateNameValid() { when( view.getTemplateName() ) .thenReturn( null ) .thenReturn( "" ) .thenReturn( "test" ); assertFalse( presenter.isTemplateNameValid() ); assertFalse( presenter.isTemplateNameValid() ); assertTrue( presenter.isTemplateNameValid() ); } |
### Question:
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(); }### Answer:
@Test public void testGraphCommandAllow() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); }
@Test public void testGraphCommandExecuteWithColumns() { relation.getColumn().add(new InformationItem()); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression())); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(0, relation.getRow().size()); assertEquals(1, relation.getColumn().size()); }
@Test public void testGraphCommandExecuteRemoveMiddleWithColumns() { uiModel.appendRow(new BaseGridRow()); uiModel.appendRow(new BaseGridRow()); final List firstRow = new List(); final List lastRow = new List(); relation.getRow().add(0, firstRow); relation.getRow().add(lastRow); relation.getColumn().add(new InformationItem()); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression())); makeCommand(1); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(2, relation.getRow().size()); assertEquals(firstRow, relation.getRow().get(0)); assertEquals(lastRow, relation.getRow().get(1)); assertEquals(1, relation.getColumn().size()); }
@Test public void testGraphCommandExecuteWithNoColumns() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(0, relation.getRow().size()); }
@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()); }
@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()); } |
### Question:
NewTemplatePresenter implements WizardPage { public boolean isCapabilityValid() { if (view.isPlanningCapabilityChecked() && view.isRuleCapabilityChecked()) { return true; } if (view.isProcessCapabilityChecked() || view.isRuleCapabilityChecked()) { return true; } return false; } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testIsCapabilityValid() { when( view.isPlanningCapabilityChecked() ).thenReturn( true, false, true, false ); when( view.isRuleCapabilityChecked() ).thenReturn( true, false, false ); when( view.isProcessCapabilityChecked() ).thenReturn( true, true, false ); assertTrue( presenter.isCapabilityValid() ); assertTrue( presenter.isCapabilityValid() ); assertTrue( presenter.isCapabilityValid() ); assertFalse( presenter.isCapabilityValid() ); } |
### Question:
NewTemplatePresenter implements WizardPage { public boolean isValid() { boolean hasError = false; if (isTemplateNameValid()) { view.noErrorOnTemplateName(); } else { view.errorOnTemplateName(); hasError = true; } if (isCapabilityValid()) { view.noErrorOnCapability(); } else { view.errorCapability(); hasError = true; } return !hasError; } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testIsValid() { when( view.getTemplateName() ).thenReturn( "templateName", "", "templateName" ); when( view.isRuleCapabilityChecked() ).thenReturn( true, false ); when( view.isProcessCapabilityChecked() ).thenReturn( true, false ); when( view.isPlanningCapabilityChecked() ).thenReturn( false ); assertTrue( presenter.isValid() ); verify( view ).noErrorOnTemplateName(); verify( view ).noErrorOnCapability(); assertFalse( presenter.isValid() ); verify( view ).errorOnTemplateName(); verify( view, times( 2 ) ).noErrorOnCapability(); assertFalse( presenter.isValid() ); verify( view, times( 2 ) ).noErrorOnTemplateName(); verify( view ).errorCapability(); } |
### Question:
NewTemplatePresenter implements WizardPage { @Override public void isComplete(final Callback<Boolean> callback) { if (isValid()) { specManagementService.call(new RemoteCallback<Boolean>() { @Override public void callback(final Boolean result) { if (result.equals(Boolean.FALSE)) { view.errorOnTemplateName(view.getInvalidErrorMessage()); callback.callback(false); } else { callback.callback(true); } } }).isNewServerTemplateIdValid(view.getTemplateName()); } else { callback.callback(false); } } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testIsComplete() { final Callback callback = mock( Callback.class ); final String templateName = "templateName"; when( view.getTemplateName() ).thenReturn( templateName ).thenReturn( templateName, templateName, templateName, "" ); when( view.isRuleCapabilityChecked() ).thenReturn( true ); when( view.isProcessCapabilityChecked() ).thenReturn( true ); when( specManagementService.isNewServerTemplateIdValid( templateName ) ).thenReturn( true, false ); presenter.isComplete( callback ); verify( specManagementService ).isNewServerTemplateIdValid( templateName ); verify( callback ).callback( true ); presenter.isComplete( callback ); verify( specManagementService, times( 2 ) ).isNewServerTemplateIdValid( templateName ); verify( callback ).callback( false ); presenter.isComplete( callback ); verify( callback, times( 2 ) ).callback( false ); verify( view ).errorOnTemplateName(); } |
### Question:
NewTemplatePresenter implements WizardPage { public void clear() { view.clear(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testClear() { presenter.clear(); verify( view ).clear(); } |
### Question:
NewTemplatePresenter implements WizardPage { @Override public String getTitle() { return view.getTitle(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testTitle() { final String title = "title"; when( view.getTitle() ).thenReturn( title ); assertEquals( title, presenter.getTitle() ); verify( view ).getTitle(); } |
### Question:
NewTemplatePresenter implements WizardPage { public void addContentChangeHandler(final ContentChangeHandler contentChangeHandler) { checkNotNull("contentChangeHandler", contentChangeHandler); view.addContentChangeHandler(new ContentChangeHandler() { @Override public void onContentChange() { contentChangeHandler.onContentChange(); wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewTemplatePresenter.this)); } }); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testAddContentChangeHandler() { doAnswer( new Answer() { @Override public Object answer( InvocationOnMock invocation ) throws Throwable { final ContentChangeHandler handler = (ContentChangeHandler) invocation.getArguments()[ 0 ]; if ( handler != null ) { handler.onContentChange(); } return null; } } ).when( view ).addContentChangeHandler( any( ContentChangeHandler.class ) ); presenter.addContentChangeHandler( mock( ContentChangeHandler.class ) ); final ArgumentCaptor<WizardPageStatusChangeEvent> eventCaptor = ArgumentCaptor.forClass( WizardPageStatusChangeEvent.class ); verify( wizardPageStatusChangeEvent ).fire( eventCaptor.capture() ); assertEquals( presenter, eventCaptor.getValue().getPage() ); } |
### Question:
NewTemplatePresenter implements WizardPage { public boolean isRuleCapabilityChecked() { return view.isRuleCapabilityChecked(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testIsRuleCapabilityChecked() { when( view.isRuleCapabilityChecked() ).thenReturn( true ).thenReturn( false ); assertTrue( presenter.isRuleCapabilityChecked() ); assertFalse( presenter.isRuleCapabilityChecked() ); } |
### Question:
NewTemplatePresenter implements WizardPage { public boolean isProcessCapabilityChecked() { return view.isProcessCapabilityChecked(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testIsProcessCapabilityChecked() { when( view.isProcessCapabilityChecked() ).thenReturn( true ).thenReturn( false ); assertTrue( presenter.isProcessCapabilityChecked() ); assertFalse( presenter.isProcessCapabilityChecked() ); } |
### Question:
NewTemplatePresenter implements WizardPage { public boolean isPlanningCapabilityChecked() { return view.isPlanningCapabilityChecked(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testIsPlanningCapabilityChecked() { when( view.isPlanningCapabilityChecked() ).thenReturn( true ).thenReturn( false ); assertTrue( presenter.isPlanningCapabilityChecked() ); assertFalse( presenter.isPlanningCapabilityChecked() ); } |
### Question:
NewTemplatePresenter implements WizardPage { public boolean hasProcessCapability() { return view.getProcessCapabilityCheck(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testHasProcessCapability() { when( view.getProcessCapabilityCheck() ).thenReturn( true, false ); assertTrue( presenter.hasProcessCapability() ); assertFalse( presenter.hasProcessCapability() ); verify( view, times( 2 ) ).getProcessCapabilityCheck(); } |
### Question:
NewTemplatePresenter implements WizardPage { public String getTemplateName() { return view.getTemplateName(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }### Answer:
@Test public void testTemplateName() { final String templateName = "templateName"; when( view.getTemplateName() ).thenReturn( templateName ); assertEquals( templateName, presenter.getTemplateName() ); verify( view ).getTemplateName(); } |
### Question:
ServerManagementBrowserPresenter { @PostConstruct public void init() { this.view.setNavigation( navigationPresenter.getView() ); } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }### Answer:
@Test public void testInit() { presenter.init(); verify( view ).setNavigation( navigationPresenter.getView() ); assertEquals( view, presenter.getView() ); } |
### Question:
ServerManagementBrowserPresenter { @OnOpen public void onOpen() { refreshList( new ServerTemplateListRefresh() ); } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }### Answer:
@Test public void testOnOpen() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onOpen(); verify( navigationPresenter ).setup( serverTemplateKey, serverTemplateKeys ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); } |
### Question:
ServerManagementBrowserPresenter { public void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ) { if ( serverTemplateDeleted != null ) { refreshList( new ServerTemplateListRefresh() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }### Answer:
@Test public void testOnServerDeleted() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onServerDeleted( new ServerTemplateDeleted() ); verify( navigationPresenter ).setup( serverTemplateKey, serverTemplateKeys ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); } |
### Question:
ServerManagementBrowserPresenter { public void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ) { if ( serverTemplateUpdated != null && serverTemplateUpdated.getServerTemplate() != null ) { final ServerTemplate serverTemplate = serverTemplateUpdated.getServerTemplate(); refreshList(new ServerTemplateListRefresh(serverTemplate.getId())); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }### Answer:
@Test public void testOnServerTemplateUpdated() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverInstanceKeyId", "serverName", "serverInstanceId", "url" ); final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); serverTemplate.addServerInstance( serverInstanceKey ); when( serverTemplatePresenter.getCurrentServerTemplate() ).thenReturn( serverTemplate ); final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onServerTemplateUpdated( new ServerTemplateUpdated( serverTemplate ) ); final ArgumentCaptor<Collection> serverTemplateKeysCaptor = ArgumentCaptor.forClass( Collection.class ); verify( navigationPresenter ).setup( eq( serverTemplateKey ), serverTemplateKeysCaptor.capture() ); final Collection<ServerTemplateKey> serverTemplateKeysValue = serverTemplateKeysCaptor.getValue(); assertEquals( 1, serverTemplateKeysValue.size() ); assertTrue( serverTemplateKeysValue.contains( serverTemplateKey ) ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); } |
### Question:
ServerManagementBrowserPresenter { public void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ) { if ( serverInstanceDeleted != null && serverInstanceDeleted.getServerInstanceId() != null && serverTemplatePresenter.getCurrentServerTemplate() != null ) { final String deletedServerInstanceId = serverInstanceDeleted.getServerInstanceId(); for ( final ServerInstanceKey serverInstanceKey : serverTemplatePresenter.getCurrentServerTemplate().getServerInstanceKeys() ) { if ( deletedServerInstanceId.equals( serverInstanceKey.getServerInstanceId() ) ) { refreshList( new ServerTemplateListRefresh( serverTemplatePresenter.getCurrentServerTemplate().getId() ) ); break; } } } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }### Answer:
@Test public void testOnDelete() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverInstanceKeyId", "serverName", "serverInstanceId", "url" ); final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); serverTemplate.addServerInstance( serverInstanceKey ); when( serverTemplatePresenter.getCurrentServerTemplate() ).thenReturn( serverTemplate ); final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onDelete( new ServerInstanceDeleted( serverInstanceKey.getServerInstanceId() ) ); verify( navigationPresenter ).setup( serverTemplateKey, serverTemplateKeys ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); }
@Test public void testOnDeleteWithoutCurrentServer() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverInstanceKeyId", "serverName", "serverInstanceId", "url" ); presenter.onDelete( new ServerInstanceDeleted( serverInstanceKey.getServerInstanceId() ) ); verify( specManagementService, never() ).listServerTemplateKeys(); } |
### Question:
ContainerCardPresenter { public View getView() { return view; } @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 ); }### Answer:
@Test public void testInit() { assertEquals( view, presenter.getView() ); } |
### Question:
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 ); }### Answer:
@Test public void testDelete() { presenter.delete(); verify( view ).delete(); } |
### Question:
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 ); }### Answer:
@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 ) ) ); } |
### Question:
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(); }### Answer:
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } |
### Question:
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(); }### Answer:
@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() ); } |
### Question:
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(); }### Answer:
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } |
### Question:
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(); }### Answer:
@Test public void testTemplate() { final ServerTemplate template = new ServerTemplate( "id", "name" ); presenter.setTemplate( template ); verify( view ).setTemplateName( template.getName() ); } |
### Question:
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(); }### Answer:
@Test public void testAddContainer() { presenter.addContainer(); verify( addNewContainerEvent ).fire( any( AddNewContainer.class ) ); } |
### Question:
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); }### Answer:
@Test public void testInit() { presenter.init(); verify(view).init(presenter); assertEquals(view, presenter.getView()); } |
### Question:
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); }### Answer:
@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)); } |
### Question:
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); }### Answer:
@Test public void testVersion() { final String version = "1.0"; presenter.setVersion(version); verify(view).setVersion(version); } |
### Question:
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); }### Answer:
@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)); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@Test public void testStartScannerEmpty() { presenter.startScanner("", ContainerRulesConfigPresenter.MS); verify(view).errorOnInterval(); }
@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); } |
### Question:
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); }### Answer:
@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)); } |
### Question:
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); }### Answer:
@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)); } |
### Question:
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(); }### Answer:
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); verify( view ).setProcessConfigView( processConfigPresenterView ); assertEquals( view, presenter.getView() ); } |
### Question:
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(); }### Answer:
@Test public void testDisable() { presenter.disable(); verify( view ).disable(); } |
### Question:
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(); }### Answer:
@Test public void testCancel() { presenter.cancel(); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfig ); } |
### Question:
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(); }### Answer:
@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() ); }
@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 ); } |
### Question:
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(); }### Answer:
@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 ); } |
### Question:
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(); }### Answer:
@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()); } |
### Question:
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(); }### Answer:
@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()); } |
### Question:
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(); }### Answer:
@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(); } |
### Question:
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(); }### Answer:
@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(); } |
### Question:
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(); }### Answer:
@Test public void testLoadContainersEmpty() { presenter.loadContainers(containerSpecData); verifyLoad(true, 1); }
@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); }
@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); } |
### Question:
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(); }### Answer:
@Test public void testRefresh() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.loadContainers(containerSpecData); presenter.refresh(); verifyLoad(true, 2); } |
### Question:
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(); }### Answer:
@Test public void testLoad() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.load(new ContainerSpecSelected(containerSpec)); verifyLoad(true, 1); }
@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()); } |
### Question:
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(); }### Answer:
@Test public void testOnRefresh() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.onRefresh(new RefreshRemoteServers(containerSpec)); verifyLoad(true, 1); } |
### Question:
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(); }### Answer:
@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())); } |
### Question:
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(); }### Answer:
@Test public void testUpdateStatusForStopped() { presenter.updateStatus(KieContainerStatus.STOPPED); verify(view).updateToggleActivationButton(false); }
@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(); }
@Test public void testUpdateStatusForFailed() { presenter.updateStatus(KieContainerStatus.FAILED); verify(view).enableRemoveButton(); verify(view).setContainerStartState(State.DISABLED); verify(view).setContainerStopState(State.ENABLED); verify(view).disableToggleActivationButton(); }
@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(); } |
### Question:
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(); }### Answer:
@Test public void testCanvasCommandAllow() { final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.allow(handler)); } |
### Question:
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 ); }### Answer:
@Test public void testInit() { assertEquals( view, presenter.getView() ); } |
### Question:
RemoteEmptyPresenter { public View getView() { return view; } @Inject RemoteEmptyPresenter( final View view ); View getView(); }### Answer:
@Test public void testInit() { assertEquals( view, presenter.getView() ); } |
### Question:
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 ); }### Answer:
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } |
### Question:
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 ); }### Answer:
@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 ) ); } |
### Question:
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 ); }### Answer:
@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() ); }
@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) ); } |
### Question:
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(); }### Answer:
@Test public void testGraphCommandAllow() { setupCommand(0, uiModel.getRow(0)); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); }
@Test public void testGraphCommandExecuteMoveUp() { setupCommand(0, uiModel.getRow(1)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertRelationDefinition(1, 0); }
@Test public void testGraphCommandExecuteMoveDown() { setupCommand(1, uiModel.getRow(0)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertRelationDefinition(1, 0); } |
### Question:
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(); }### Answer:
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); } |
### Question:
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(); }### Answer:
@Test public void testClear() { presenter.clear(); verify( view ).clean(); } |
### Question:
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(); }### Answer:
@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() ); } |
### Question:
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(); }### Answer:
@Test public void testRefresh() { presenter.refresh(); verify( serverTemplateListRefreshEvent ).fire( any( ServerTemplateListRefresh.class ) ); } |
### Question:
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(); }### Answer:
@Test public void testNewTemplate() { presenter.newTemplate(); verify( addNewServerTemplateEvent ).fire( any( AddNewServerTemplate.class ) ); } |
### Question:
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(); }### Answer:
@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() ); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.