Author: vjrj Date: 2008-12-23 04:59:57 +0100 (Tue, 23 Dec 2008) New Revision: 1014 Removed: trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessage.java trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessagePanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessagePresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessageView.java trunk/src/test/java/org/ourproject/kune/workspace/client/sitebar/msg/SiteMessagePresenterTest.java Modified: trunk/pom.xml trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableIconLabel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/KuneUiUtils.java trunk/src/main/java/org/ourproject/kune/workspace/client/licensefoot/EntityLicensePanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/newgroup/NewGroupPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInForm.java trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SimpleMessagePanel.java trunk/src/test/java/org/ourproject/kune/platf/server/access/FinderTest.java Log: Incomplete - task Rename issue Complete - task SignIn focus problem Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/pom.xml 2008-12-23 03:59:57 UTC (rev 1014) @@ -273,18 +273,6 @@ --> </dependency> <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <version>2.2</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <version>1.2</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.openqa.selenium.client-drivers</groupId> <artifactId>selenium-java-client-driver</artifactId> <version>1.0-beta-1</version> @@ -392,8 +380,8 @@ <version>2.0-beta26</version> <configuration> <logLevel>INFO</logLevel> - <style>OBF</style> - <!-- <style>PRETTY</style> --> + <style>PRETTY</style> + <!-- <style>OBF PRETTY</style> --> <runTarget> org.ourproject.kune.app.Kune/Kune.html </runTarget> Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableIconLabel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableIconLabel.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/EditableIconLabel.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -221,7 +221,7 @@ }); } editor.setReadOnly(false); - editor.setPixelSize(hpWidth < 40 ? 40 : hpWidth, 21); + editor.setPixelSize(hpWidth < 100 ? 100 : hpWidth, 21); editor.setText(currentText); editor.setVisible(true); editor.setFocus(true); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/KuneUiUtils.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/KuneUiUtils.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/KuneUiUtils.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -21,10 +21,12 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.AbstractImagePrototype; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Widget; import com.gwtext.client.widgets.ToolTip; +import com.gwtext.client.widgets.form.Field; public class KuneUiUtils { @@ -32,6 +34,15 @@ left, right } + public static void focusOnField(final Field field) { + new Timer() { + @Override + public void run() { + field.focus(true); + } + }.schedule(50); + } + public static String genQuickTipLabel(final String labelText, final String tipTitle, final String tipText) { String tipHtml = "<span style=\"vertical-align: middle;\" ext:qtip=\"" + tipText + "\""; if (tipTitle != null && tipTitle.length() > 0) { Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/licensefoot/EntityLicensePanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/licensefoot/EntityLicensePanel.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/licensefoot/EntityLicensePanel.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -76,7 +76,6 @@ }; licenseImage.addMouseListener(mouseListenerAdapter); - licenseLabel.addMouseListener(mouseListenerAdapter); licenseLabel.addStyleName("kune-Margin-Large-l"); licenseLabel.setStyleName("k-elp-limg"); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/newgroup/NewGroupPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/newgroup/NewGroupPanel.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/newgroup/NewGroupPanel.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -39,10 +39,12 @@ import com.gwtext.client.core.EventObject; import com.gwtext.client.core.Position; import com.gwtext.client.widgets.Button; +import com.gwtext.client.widgets.Component; import com.gwtext.client.widgets.PaddedPanel; import com.gwtext.client.widgets.Panel; import com.gwtext.client.widgets.ToolTip; import com.gwtext.client.widgets.event.ButtonListenerAdapter; +import com.gwtext.client.widgets.event.WindowListenerAdapter; import com.gwtext.client.widgets.form.Field; import com.gwtext.client.widgets.form.FieldSet; import com.gwtext.client.widgets.form.FormPanel; @@ -95,7 +97,18 @@ public void onEvent() { presenter.onRegister(); } - }, 0); + }, 9); + super.addListener(new WindowListenerAdapter() { + @Override + public void onHide(Component component) { + presenter.onClose(); + } + + @Override + public void onShow(Component component) { + KuneUiUtils.focusOnField(shortNameField); + } + }); this.i18n = i18n; this.licenseWizard = licenseWizard; Field.setMsgTarget("side"); @@ -181,6 +194,7 @@ form.add(intro); shortNameField = new TextField(); + shortNameField.setValidationEvent(false); shortNameField.setTabIndex(1); shortNameField.setFieldLabel(i18n.t("Short name")); shortNameField.setName(SHORTNAME_FIELD); @@ -243,6 +257,7 @@ licenseImagePanel.add(licenseImage); Button changeLicenseButton = new Button(i18n.t("Change")); + changeLicenseButton.setTabIndex(5); changeLicenseButton.addListener(new ButtonListenerAdapter() { @Override public void onClick(Button button, EventObject e) { @@ -281,20 +296,20 @@ + "is moderated by the project administrators. " + "An administrator is the person who creates the project " + "and other people she/he chooses to be administrator as well."), PROJ_GROUP_TYPE_ID); - projectRadio.setTabIndex(5); + projectRadio.setTabIndex(6); projectRadio.setChecked(true); orgRadio = DefaultFormUtils.createRadio(groupTypeFieldSet, i18n.t("Organization"), TYPEOFGROUP_FIELD, i18n.t("An organization works as a project, " + "but organizations must be a legal entity."), ORG_GROUP_TYPE_ID); - orgRadio.setTabIndex(6); + orgRadio.setTabIndex(7); communityRadio = DefaultFormUtils.createRadio(groupTypeFieldSet, i18n.t("Community"), TYPEOFGROUP_FIELD, i18n.t("Communities are social groups of persons " + "with shared interests, which are open to new members " + "(for instance the environmental community or the LGBT community). " + "They rarely are a legal entity."), COMM_GROUP_TYPE_ID); - communityRadio.setTabIndex(7); + communityRadio.setTabIndex(8); return form; } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterForm.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -26,6 +26,7 @@ import com.gwtext.client.data.SimpleStore; import com.gwtext.client.data.Store; import com.gwtext.client.widgets.form.ComboBox; +import com.gwtext.client.widgets.form.Field; import com.gwtext.client.widgets.form.FieldSet; import com.gwtext.client.widgets.form.Radio; import com.gwtext.client.widgets.form.TextField; @@ -224,8 +225,8 @@ createRadio(personalSpaceFieldSet, wantPersonalHomePage, i18n.t("Yes, I want a homepage for publish my contents."), WANNAPERSONALHOMEPAGE_ID); wantPersonalHomePage.setChecked(true); - createRadio(personalSpaceFieldSet, noPersonalHomePage, i18n.t("No, I do not want. Maybe in the future i will."), - NOPERSONALHOMEPAGE_ID); + createRadio(personalSpaceFieldSet, noPersonalHomePage, + i18n.t("No, I do not want. Maybe in the future i will."), NOPERSONALHOMEPAGE_ID); add(personalSpaceFieldSet); } @@ -257,6 +258,10 @@ return shortNameRegField.getValueAsString(); } + public Field getShortNameField() { + return shortNameRegField; + } + public String getTimezone() { return timezoneCombo.getValueAsString(); } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterPanel.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/RegisterPanel.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -3,6 +3,7 @@ import org.ourproject.kune.platf.client.PlatfMessages; import org.ourproject.kune.platf.client.services.Images; import org.ourproject.kune.platf.client.state.Session; +import org.ourproject.kune.platf.client.ui.KuneUiUtils; import org.ourproject.kune.platf.client.ui.dialogs.InfoDialog; import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; @@ -45,9 +46,19 @@ }, images, ERRMSG, 11); super.addListener(new WindowListenerAdapter() { @Override + public void onActivate(Panel panel) { + KuneUiUtils.focusOnField(registerForm.getShortNameField()); + } + + @Override public void onHide(Component component) { presenter.onClose(); } + + @Override + public void onShow(Component component) { + KuneUiUtils.focusOnField(registerForm.getShortNameField()); + } }); Panel panel = new Panel(); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInForm.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInForm.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInForm.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -78,4 +78,8 @@ public String getNickOrEmail() { return loginNickOrEmailField.getValueAsString(); } + + public Field getNickOrEmailField() { + return loginNickOrEmailField; + } } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPanel.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/signin/SignInPanel.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -2,6 +2,7 @@ import org.ourproject.kune.platf.client.PlatfMessages; import org.ourproject.kune.platf.client.services.Images; +import org.ourproject.kune.platf.client.ui.KuneUiUtils; import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; @@ -13,6 +14,7 @@ import com.gwtext.client.widgets.Component; import com.gwtext.client.widgets.Panel; import com.gwtext.client.widgets.event.WindowListenerAdapter; +import com.gwtext.client.widgets.form.Field; public class SignInPanel extends SignInAbstractPanel implements SignInView { @@ -50,7 +52,7 @@ @Override public void onShow(Component component) { - focusOnNickname(); + KuneUiUtils.focusOnField(getNickname()); } }); @@ -104,4 +106,8 @@ return noAccRegisterPanel; } + private Field getNickname() { + return signInForm.getNickOrEmailField(); + } + } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SimpleMessagePanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SimpleMessagePanel.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SimpleMessagePanel.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -27,7 +27,7 @@ import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.VerticalPanel; -public class SimpleMessagePanel extends HorizontalPanel implements SiteMessageView { +public class SimpleMessagePanel extends HorizontalPanel { HTML message = null; Image messageIcon = null; private final Images images; Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessage.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessage.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessage.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -1,29 +0,0 @@ -/* - * - * Copyright (C) 2007-2008 The kune development team (see CREDITS for details) - * This file is part of kune. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.ourproject.kune.workspace.client.site.msg; - -import org.ourproject.kune.platf.client.View; -import org.ourproject.kune.workspace.client.newgroup.SiteErrorType; - -public interface SiteMessage extends View { - - void setMessage(String message, SiteErrorType type); - -} Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessagePanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessagePanel.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessagePanel.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -1,122 +0,0 @@ -/* - * - * Copyright (C) 2007-2008 The kune development team (see CREDITS for details) - * This file is part of kune. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.ourproject.kune.workspace.client.site.msg; - -import org.ourproject.kune.platf.client.services.Images; -import org.ourproject.kune.platf.client.ui.KuneUiUtils; -import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService; - -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.WindowResizeListener; -import com.google.gwt.user.client.ui.ClickListener; -import com.google.gwt.user.client.ui.PushButton; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Widget; -import com.gwtext.client.core.ExtElement; - -public class SiteMessagePanel extends SimpleMessagePanel implements SiteMessageView { - private static final int TIMEVISIBLE = 4000; - - private final Timer timer; - - private final ExtElement extElem; - - public SiteMessagePanel(final MessagePresenter presenter, final boolean closable, - final I18nUITranslationService i18n, Images images) { - super(images); - timer = new Timer() { - @Override - public void run() { - hide(); - if (presenter != null) { - presenter.resetMessage(); - } - } - }; - - if (closable) { - final PushButton closeIcon = new PushButton(images.cross().createImage(), images.crossDark().createImage()); - KuneUiUtils.setQuickTip(closeIcon, i18n.t("Click to close")); - add(closeIcon); - closeIcon.addClickListener(new ClickListener() { - public void onClick(final Widget sender) { - if (sender == closeIcon) { - setVisible(false); - hide(); - if (presenter != null) { - presenter.resetMessage(); - } - } - } - }); - setCellVerticalAlignment(closeIcon, VerticalPanel.ALIGN_BOTTOM); - } - extElem = new ExtElement(this.getElement()); - final int clientWidth = Window.getClientWidth(); - adjustWidth(clientWidth); - Window.addWindowResizeListener(new WindowResizeListener() { - public void onWindowResized(final int width, final int height) { - // Log.debug("Window width: " + width + ", height: " + height); - setXY(width); - adjustWidth(width); - } - }); - super.reset(); - super.show(); - extElem.setVisible(false, false); - RootPanel.get().add(this, calculateX(clientWidth), calculateY()); - } - - @Override - public void adjustWidth(final int windowWidth) { - super.adjustWidth(windowWidth); - } - - @Override - public void hide() { - extElem.hide(true); - super.reset(); - timer.cancel(); - } - - @Override - public void show() { - extElem.show(false); - // super.show(); - timer.schedule(TIMEVISIBLE); - } - - private int calculateX(final int clientWidth) { - final int x = clientWidth * 20 / 100 - 10; - // Log.debug("X: " + x); - return x; - } - - private int calculateY() { - return 2; - } - - private void setXY(final int clientWidth) { - extElem.setXY(calculateX(clientWidth), calculateY(), false); - } - -} Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessagePresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessagePresenter.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessagePresenter.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -1,80 +0,0 @@ -/* - * - * Copyright (C) 2007-2008 The kune development team (see CREDITS for details) - * This file is part of kune. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.ourproject.kune.workspace.client.site.msg; - -import org.ourproject.kune.platf.client.View; -import org.ourproject.kune.workspace.client.newgroup.SiteErrorType; - -public class SiteMessagePresenter implements SiteMessage, MessagePresenter { - private SiteMessageView view; - private boolean isVisible; - private String message; - private SiteErrorType lastMessageType; - - public SiteMessagePresenter() { - } - - public View getView() { - return view; - } - - public void init(final SiteMessageView siteMessageView) { - this.view = siteMessageView; - this.lastMessageType = SiteErrorType.info; - resetMessage(); - } - - public void resetMessage() { - this.message = ""; - this.isVisible = false; - view.hide(); - } - - public void setMessage(final String message, final SiteErrorType type) { - if (isVisible) { - if (!this.message.equals(message)) { - // Concatenate message (if not is the same) - this.message = this.message + "<br>" + message; - } - } else { - // New message - this.message = message; - } - if (lastMessageType != type) { - if (isVisible) { - if (type.compareTo(lastMessageType) < 0) { - // more severe message - view.setMessage(this.message, lastMessageType, type); - lastMessageType = type; - } else { - view.setMessage(this.message); - } - } else { - // Was closed, and different message level - view.setMessage(this.message, lastMessageType, type); - lastMessageType = type; - } - } else { - view.setMessage(this.message); - } - isVisible = true; - view.show(); - } -} Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessageView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessageView.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/site/msg/SiteMessageView.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -1,37 +0,0 @@ -/* - * - * Copyright (C) 2007-2008 The kune development team (see CREDITS for details) - * This file is part of kune. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.ourproject.kune.workspace.client.site.msg; - -import org.ourproject.kune.platf.client.View; -import org.ourproject.kune.workspace.client.newgroup.SiteErrorType; - -public interface SiteMessageView extends View { - - void adjustWidth(int windowWidth); - - void hide(); - - void setMessage(String message); - - void setMessage(String message, SiteErrorType oldStyle, SiteErrorType newStyle); - - void show(); - -} Modified: trunk/src/test/java/org/ourproject/kune/platf/server/access/FinderTest.java =================================================================== --- trunk/src/test/java/org/ourproject/kune/platf/server/access/FinderTest.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/test/java/org/ourproject/kune/platf/server/access/FinderTest.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -1,14 +1,11 @@ package org.ourproject.kune.platf.server.access; -import static org.easymock.EasyMock.createStrictMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.ourproject.kune.platf.client.dto.StateToken; import org.ourproject.kune.platf.client.errors.ContentNotFoundException; import org.ourproject.kune.platf.server.TestDomainHelper; @@ -36,11 +33,9 @@ final Content descriptor = new Content(); final Container container = TestDomainHelper.createFolderWithIdAndToolName(5, "toolName2"); descriptor.setContainer(container); - expect(contentManager.find(1L)).andReturn(descriptor); - replay(contentManager); + Mockito.stub(contentManager.find(1L)).toReturn(descriptor); finder.getContent(new StateToken("groupShortName", "toolName", "5", "1"), null); - verify(contentManager); } @Test(expected = ContentNotFoundException.class) @@ -48,11 +43,9 @@ final Content descriptor = new Content(); final Container container = TestDomainHelper.createFolderWithIdAndGroupAndTool(5, "groupOther", "toolName"); descriptor.setContainer(container); - expect(contentManager.find(1L)).andReturn(descriptor); - replay(contentManager); + Mockito.stub(contentManager.find(1L)).toReturn(descriptor); finder.getContent(new StateToken("groupShortName", "toolName", "5", "1"), null); - verify(contentManager); } @Test(expected = ContentNotFoundException.class) @@ -60,20 +53,18 @@ final Content descriptor = new Content(); final Container container = TestDomainHelper.createFolderWithId(1); descriptor.setContainer(container); - expect(contentManager.find(1L)).andReturn(descriptor); - replay(contentManager); + Mockito.stub(contentManager.find(1L)).toReturn(descriptor); finder.getContent(new StateToken("groupShortName", "toolName", "5", "1"), null); - verify(contentManager); } @Before public void createSession() { - this.groupManager = createStrictMock(GroupManager.class); - this.containerManager = createStrictMock(ContainerManager.class); - this.contentManager = createStrictMock(ContentManager.class); - this.rateManager = createStrictMock(RateManager.class); - this.commentManager = createStrictMock(CommentManager.class); + this.groupManager = Mockito.mock(GroupManager.class); + this.containerManager = Mockito.mock(ContainerManager.class); + this.contentManager = Mockito.mock(ContentManager.class); + this.rateManager = Mockito.mock(RateManager.class); + this.commentManager = Mockito.mock(CommentManager.class); this.finder = new FinderServiceDefault(groupManager, containerManager, contentManager, rateManager, commentManager); } @@ -83,12 +74,10 @@ final Group group = new Group(); final Content descriptor = new Content(); group.setDefaultContent(descriptor); - expect(groupManager.findByShortName("groupShortName")).andReturn(group); - replay(groupManager); + Mockito.stub(groupManager.findByShortName("groupShortName")).toReturn(group); final Content content = finder.getContent(new StateToken("groupShortName", null, null, null), null); assertSame(descriptor, content); - verify(groupManager); } @Test @@ -98,12 +87,10 @@ descriptor.setId(1L); descriptor.setContainer(container); - expect(contentManager.find(2L)).andReturn(descriptor); - replay(contentManager); + Mockito.stub(contentManager.find(2L)).toReturn(descriptor); final Content content = finder.getContent(new StateToken("groupShortName", "toolName", "1", "2"), null); assertSame(descriptor, content); - verify(contentManager); } @Test(expected = ContentNotFoundException.class) @@ -143,13 +130,11 @@ @Test public void testDocMissing() throws Exception { final Container container = new Container(); - expect(containerManager.find(1L)).andReturn(container); + Mockito.stub(containerManager.find(1L)).toReturn(container); - replay(containerManager); final Content content = finder.getContent(new StateToken("groupShortName", "toolName", "1", null), null); assertNotNull(content); assertSame(container, content.getContainer()); - verify(containerManager); } @Test @@ -157,13 +142,11 @@ final Group group = new Group(); final ToolConfiguration config = group.setToolConfig("toolName", new ToolConfiguration()); final Container container = config.setRoot(new Container()); - expect(groupManager.findByShortName("groupShortName")).andReturn(group); - replay(groupManager); + Mockito.stub(groupManager.findByShortName("groupShortName")).toReturn(group); final StateToken token = new StateToken("groupShortName", "toolName", null, null); final Content content = finder.getContent(token, null); assertSame(container, content.getContainer()); - verify(groupManager); } @Test(expected = ContentNotFoundException.class) @@ -171,11 +154,9 @@ final Content descriptor = new Content(); final Container container = TestDomainHelper.createFolderWithIdAndToolName(5, "toolName"); descriptor.setContainer(container); - expect(contentManager.find(1L)).andReturn(descriptor); - replay(contentManager); + Mockito.stub(contentManager.find(1L)).toReturn(descriptor); finder.getContent(new StateToken("groupShortName", "toolName", "5", "1a"), null); - verify(contentManager); } @Test(expected = ContentNotFoundException.class) Deleted: trunk/src/test/java/org/ourproject/kune/workspace/client/sitebar/msg/SiteMessagePresenterTest.java =================================================================== --- trunk/src/test/java/org/ourproject/kune/workspace/client/sitebar/msg/SiteMessagePresenterTest.java 2008-12-23 01:01:04 UTC (rev 1013) +++ trunk/src/test/java/org/ourproject/kune/workspace/client/sitebar/msg/SiteMessagePresenterTest.java 2008-12-23 03:59:57 UTC (rev 1014) @@ -1,68 +0,0 @@ -package org.ourproject.kune.workspace.client.sitebar.msg; - -import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; -import org.ourproject.kune.workspace.client.newgroup.SiteErrorType; -import org.ourproject.kune.workspace.client.site.msg.SiteMessagePresenter; -import org.ourproject.kune.workspace.client.site.msg.SiteMessageView; - -public class SiteMessagePresenterTest { - - private SiteMessagePresenter presenter; - private SiteMessageView view; - - @Before - public void createObjects() { - view = EasyMock.createStrictMock(SiteMessageView.class); - presenter = new SiteMessagePresenter(); - } - - @Test - public void testMessage() { - view.hide(); - view.setMessage("test 1", SiteErrorType.info, SiteErrorType.error); - view.show(); - EasyMock.replay(view); - presenter.init(view); - presenter.setMessage("test 1", SiteErrorType.error); - EasyMock.verify(view); - } - - @Test - public void testTwoMessagesDifTypes() { - view.hide(); - view.setMessage("test 1", SiteErrorType.info, SiteErrorType.veryimp); - view.show(); - view.setMessage("test 1<br>test 2", SiteErrorType.veryimp, SiteErrorType.error); - view.show(); - EasyMock.replay(view); - presenter.init(view); - presenter.setMessage("test 1", SiteErrorType.veryimp); - presenter.setMessage("test 2", SiteErrorType.error); - EasyMock.verify(view); - } - - @Test - public void testTwoMessagesSameType() { - view.hide(); - view.setMessage("test 1", SiteErrorType.info, SiteErrorType.error); - view.show(); - view.setMessage("test 1<br>test 2"); - view.show(); - EasyMock.replay(view); - presenter.init(view); - presenter.setMessage("test 1", SiteErrorType.error); - presenter.setMessage("test 2", SiteErrorType.error); - EasyMock.verify(view); - } - - @Test - public void testViewInitialization() { - view.hide(); - EasyMock.replay(view); - presenter.init(view); - EasyMock.verify(view); - } - -}