Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcvs2git2008-09-17 22:33:26 -0400
committercvs2git2008-09-17 22:33:26 -0400
commit2dd38c08dcd1a7674bd9b655fc0235b8b6b609a3 (patch)
treeba4e4931544a696248426c8490ae1e91061cd290
parent33d17b56b3e5dc96395881e17d2fa76a409cdc72 (diff)
downloadorg.eclipse.mylyn.tasks-2dd38c08dcd1a7674bd9b655fc0235b8b6b609a3.tar.gz
org.eclipse.mylyn.tasks-2dd38c08dcd1a7674bd9b655fc0235b8b6b609a3.tar.xz
org.eclipse.mylyn.tasks-2dd38c08dcd1a7674bd9b655fc0235b8b6b609a3.zip
This commit was manufactured by cvs2svn to create branch 'e_3_3_m_3_0_x'.R_3_0_2_e_3_3
Sprout from master 2008-09-18 02:33:24 UTC spingel 'NEW - bug 237552: [api] remove deprecated classes' Cherrypick from master 2008-09-17 07:44:17 UTC spingel 'NEW - bug 237552: [api] remove deprecated classes': org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java Cherrypick from e_3_3_m_3_x 2008-09-17 19:26:51 UTC spingel 'NEW - bug 194157: update copyright notices to 2008': org.eclipse.mylyn-feature/.settings/org.eclipse.jdt.core.prefs org.eclipse.mylyn-feature/.settings/org.eclipse.jdt.ui.prefs org.eclipse.mylyn-feature/about.html org.eclipse.mylyn-feature/feature.xml org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.jdt.core.prefs org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.jdt.ui.prefs org.eclipse.mylyn.bugzilla-feature/about.html org.eclipse.mylyn.bugzilla-feature/build.properties org.eclipse.mylyn.bugzilla-feature/feature.xml org.eclipse.mylyn.tasks.bugs/.classpath org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.jdt.core.prefs org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.jdt.ui.prefs org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF org.eclipse.mylyn.tasks.bugs/about.html org.eclipse.mylyn.tasks.bugs/build.properties org.eclipse.mylyn.tasks.bugs/plugin.xml org.eclipse.mylyn.tasks.bugs/schema/pluginRepositoryMappings.exsd org.eclipse.mylyn.tasks.bugs/schema/taskContributors.exsd org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/AbstractTaskContributor.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/AttributeTaskMapper.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/DefaultTaskContributor.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/IRepositoryConstants.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMapping.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMappingManager.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskContributorManager.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskErrorReporter.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TasksBugsPlugin.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/ReportBugAction.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/BundleGroupContainer.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ErrorLogStatus.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureGroup.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureStatus.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportBugOrEnhancementWizard.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorPage.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorWizard.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java Delete: org.eclipse.mylyn.tasks.bugs/icons/etool16/task-new.gif org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java
-rw-r--r--org.eclipse.mylyn-feature/feature.xml22
-rw-r--r--org.eclipse.mylyn.bugzilla-feature/feature.xml9
-rw-r--r--org.eclipse.mylyn.tasks.bugs/.classpath2
-rw-r--r--org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.mylyn.tasks.bugs/icons/etool16/task-new.gifbin334 -> 0 bytes
-rw-r--r--org.eclipse.mylyn.tasks.bugs/plugin.xml83
-rw-r--r--org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java78
-rw-r--r--org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java79
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java478
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java106
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java1006
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java54
12 files changed, 1709 insertions, 212 deletions
diff --git a/org.eclipse.mylyn-feature/feature.xml b/org.eclipse.mylyn-feature/feature.xml
index 62866ba6d..8058af09b 100644
--- a/org.eclipse.mylyn-feature/feature.xml
+++ b/org.eclipse.mylyn-feature/feature.xml
@@ -60,15 +60,20 @@ Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in t
</license>
<url>
- <update label="Mylyn for Eclipse 3.4" url="http://download.eclipse.org/tools/mylyn/update/e3.4"/>
+ <update label="Mylyn for Eclipse 3.3" url="http://download.eclipse.org/tools/mylyn/update/e3.3"/>
<discovery label="Mylyn Extras" url="http://download.eclipse.org/tools/mylyn/update/extras"/>
- <discovery label="Mylyn" url="http://download.eclipse.org/tools/mylyn/update/e3.4"/>
+ <discovery label="Mylyn" url="http://download.eclipse.org/tools/mylyn/update/e3.3"/>
</url>
<requires>
<import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.ui" version="3.4.0.I20070918" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.ui" version="3.3.0" match="equivalent"/>
<import plugin="org.eclipse.ui.forms"/>
+ <import plugin="org.eclipse.mylyn.tasks.core" version="3.0.0" match="compatible"/>
+ <import plugin="org.eclipse.mylyn.tasks.ui" version="3.0.0" match="compatible"/>
+ <import plugin="org.eclipse.mylyn.commons.ui" version="3.0.0" match="compatible"/>
+ <import plugin="org.eclipse.mylyn.commons.core" version="3.0.0" match="compatible"/>
+ <import plugin="org.eclipse.mylyn.monitor.core" version="3.0.0" match="compatible"/>
<import plugin="org.eclipse.compare"/>
<import plugin="org.eclipse.core.expressions"/>
<import plugin="org.eclipse.core.net"/>
@@ -80,19 +85,10 @@ Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in t
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.ui.views"/>
<import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.apache.commons.codec" version="1.3.0" match="greaterOrEqual"/>
- <import plugin="org.apache.commons.httpclient" version="3.1.0" match="greaterOrEqual"/>
- <import plugin="org.apache.commons.lang" version="2.3.0" match="greaterOrEqual"/>
- <import plugin="org.apache.commons.logging" version="1.0.4" match="greaterOrEqual"/>
- <import plugin="org.eclipse.mylyn.tasks.core" version="3.0.0" match="compatible"/>
- <import plugin="org.eclipse.mylyn.tasks.ui" version="3.0.0" match="compatible"/>
- <import plugin="org.eclipse.mylyn.commons.ui" version="3.0.0" match="compatible"/>
- <import plugin="org.eclipse.mylyn.commons.core" version="3.0.0" match="compatible"/>
- <import plugin="org.eclipse.mylyn.monitor.core" version="3.0.0" match="compatible"/>
<import plugin="org.eclipse.mylyn.context.core" version="3.0.0" match="compatible"/>
<import plugin="org.eclipse.mylyn.monitor.ui" version="3.0.0" match="compatible"/>
<import plugin="org.eclipse.mylyn.commons.net" version="3.0.0" match="compatible"/>
- <import feature="org.eclipse.rcp" version="3.4.0" match="compatible"/>
+ <import feature="org.eclipse.rcp" version="3.3.0" match="equivalent"/>
</requires>
<plugin
diff --git a/org.eclipse.mylyn.bugzilla-feature/feature.xml b/org.eclipse.mylyn.bugzilla-feature/feature.xml
index 033d3022e..a90036dcf 100644
--- a/org.eclipse.mylyn.bugzilla-feature/feature.xml
+++ b/org.eclipse.mylyn.bugzilla-feature/feature.xml
@@ -60,12 +60,14 @@ Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in t
</license>
<url>
- <update label="Mylyn for Eclipse 3.4" url="http://download.eclipse.org/tools/mylyn/update/e3.4"/>
+ <update label="Mylyn for Eclipse 3.3" url="http://download.eclipse.org/tools/mylyn/update/e3.3"/>
</url>
<requires>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.mylyn.tasks.core" version="3.0.0" match="compatible"/>
+ <import plugin="org.eclipse.mylyn.commons.net" version="3.0.0" match="compatible"/>
+ <import plugin="org.eclipse.mylyn.commons.core" version="3.0.0" match="compatible"/>
<import plugin="org.eclipse.core.net"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.core.resources"/>
@@ -76,10 +78,9 @@ Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in t
<import plugin="org.eclipse.ui.editors"/>
<import plugin="org.eclipse.ui.workbench.texteditor"/>
<import plugin="org.eclipse.mylyn.tasks.ui" version="3.0.0" match="compatible"/>
- <import feature="org.eclipse.mylyn_feature" version="3.0.2.qualifier" match="perfect"/>
- <import plugin="org.eclipse.mylyn.commons.net" version="3.0.0" match="compatible"/>
- <import plugin="org.eclipse.mylyn.commons.core" version="3.0.0" match="compatible"/>
<import plugin="org.eclipse.mylyn.commons.ui" version="3.0.0" match="compatible"/>
+ <import feature="org.eclipse.mylyn_feature" version="3.0.2.qualifier" match="perfect"/>
+ <import plugin="org.eclipse.mylyn.bugzilla.core" version="3.0.0" match="compatible"/>
</requires>
<plugin
diff --git a/org.eclipse.mylyn.tasks.bugs/.classpath b/org.eclipse.mylyn.tasks.bugs/.classpath
index 6a357762a..40856a70b 100644
--- a/org.eclipse.mylyn.tasks.bugs/.classpath
+++ b/org.eclipse.mylyn.tasks.bugs/.classpath
@@ -3,7 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
<accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/ui/internal/views/log/*"/>
+ <accessrule kind="accessible" pattern="org/eclipse/pde/internal/runtime/logview/*"/>
<accessrule kind="accessible" pattern="org/eclipse/mylyn/internal/tasks/ui/**"/>
</accessrules>
</classpathentry>
diff --git a/org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF
index cf7ade8e7..3543deee6 100644
--- a/org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.bugs/META-INF/MANIFEST.MF
@@ -4,10 +4,8 @@ Bundle-Name: Mylyn Bug Reporting
Bundle-SymbolicName: org.eclipse.mylyn.tasks.bugs;singleton:=true
Bundle-Version: 3.0.2.qualifier
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.core.resources,
org.eclipse.ui,
- org.eclipse.ui.views.log;resolution:=optional,
- org.eclipse.ui.ide,
+ org.eclipse.pde.runtime;resolution:=optional,
org.eclipse.mylyn.commons.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.mylyn.tasks.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.mylyn.tasks.ui;bundle-version="[3.0.0,4.0.0)",
diff --git a/org.eclipse.mylyn.tasks.bugs/icons/etool16/task-new.gif b/org.eclipse.mylyn.tasks.bugs/icons/etool16/task-new.gif
deleted file mode 100644
index e2cde50c2..000000000
--- a/org.eclipse.mylyn.tasks.bugs/icons/etool16/task-new.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.mylyn.tasks.bugs/plugin.xml b/org.eclipse.mylyn.tasks.bugs/plugin.xml
index fb954d36a..4459eb1fb 100644
--- a/org.eclipse.mylyn.tasks.bugs/plugin.xml
+++ b/org.eclipse.mylyn.tasks.bugs/plugin.xml
@@ -5,19 +5,16 @@
<extension-point id="taskContributors" name="Task Contributors" schema="schema/taskContributors.exsd"/>
<extension point="org.eclipse.ui.popupMenus">
- <objectContribution
- adaptable="false"
- id="org.eclipse.mylyn.internal.provisional.tasks.bugs.objectContribution"
- objectClass="org.eclipse.ui.internal.views.log.LogEntry">
- <action
- class="org.eclipse.mylyn.internal.tasks.bugs.actions.NewTaskFromErrorAction"
- enablesFor="1"
- icon="icons/etool16/task-repository-new.gif"
- menubarPath="org.eclipse.pde.runtime.LogView"
- id="org.eclipse.mylyn.tasklist.actions.newTaskFromErrorLog"
- label="Report as Bug">
- </action>
- </objectContribution>
+ <viewerContribution
+ id="org.eclipse.mylyn.bugzilla.ide.log.contribution"
+ targetID="org.eclipse.pde.runtime.LogView">
+ <action
+ class="org.eclipse.mylyn.internal.tasks.bugs.actions.NewTaskFromErrorAction"
+ icon="icons/etool16/task-repository-new.gif"
+ menubarPath="org.eclipse.pde.runtime.LogView"
+ id="org.eclipse.mylyn.tasklist.actions.newTaskFromErrorLog"
+ label="Report as Bug"/>
+ </viewerContribution>
</extension>
<extension point="org.eclipse.ui.actionSets">
@@ -35,62 +32,7 @@
tooltip="Report Bug or Enhancement"/>
</actionSet>
</extension>
-
- <extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.mylyn.internal.tasks.bugs.actions.NewTaskFromMarkerHandler"
- commandId="org.eclipse.mylyn.tasks.bugs.commands.newTaskFromMarker">
- <activeWhen>
- <with variable="activePart">
- <test
- args="any"
- property="org.eclipse.ui.ide.contentGenerator">
- </test>
- </with>
- </activeWhen>
- <enabledWhen>
- <and>
- <count
- value="1">
- </count>
- <iterate
- ifEmpty="false"
- operator="and">
- <instanceof
- value="org.eclipse.ui.internal.views.markers.MarkerEntry">
- </instanceof>
- </iterate>
- </and>
- </enabledWhen>
- </handler>
- </extension>
-
- <extension
- point="org.eclipse.ui.commands">
- <command
- description="Report as Bug from Marker"
- id="org.eclipse.mylyn.tasks.bugs.commands.newTaskFromMarker"
- name="New Task from Marker...">
- </command>
- </extension>
-
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="popup:org.eclipse.ui.ide.MarkersView?after=org.eclipse.ui.ide.markCompleted">
- <command
- commandId="org.eclipse.mylyn.tasks.bugs.commands.newTaskFromMarker"
- icon="icons/etool16/task-new.gif"
- mnemonic="New Task from Marker"
- style="push">
- <visibleWhen
- checkEnabled="true">
- </visibleWhen>
- </command>
- </menuContribution>
- </extension>
-
+
<extension
point="org.eclipse.mylyn.commons.core.errorReporters">
<errorReporter
@@ -98,6 +40,5 @@
id="org.eclipse.mylyn.tasks.bugs.taskReporter"
label="Report Bug">
</errorReporter>
- </extension>
-
+ </extension>
</plugin>
diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java
index fe48ec0c0..9ce90b3f7 100644
--- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java
+++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java
@@ -15,13 +15,17 @@ package org.eclipse.mylyn.internal.tasks.bugs.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylyn.internal.commons.core.ErrorReporterManager;
import org.eclipse.mylyn.internal.tasks.bugs.wizards.ErrorLogStatus;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.internal.views.log.LogEntry;
-import org.eclipse.ui.internal.views.log.LogSession;
+import org.eclipse.pde.internal.runtime.logview.LogEntry;
+import org.eclipse.pde.internal.runtime.logview.LogSession;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
/**
* Creates a new task from the selected error log entry.
@@ -29,11 +33,11 @@ import org.eclipse.ui.internal.views.log.LogSession;
* @author Jeff Pound
* @author Steffen Pingel
*/
-public class NewTaskFromErrorAction implements IObjectActionDelegate {
+public class NewTaskFromErrorAction implements IViewActionDelegate, ISelectionChangedListener {
public static final String ID = "org.eclipse.mylyn.tasklist.ui.repositories.actions.create";
- private LogEntry entry;
+ private TreeViewer treeViewer;
/**
* Fills a {@link StringBuilder} with {@link LogEntry} information, optionally including subentries too
@@ -80,42 +84,29 @@ public class NewTaskFromErrorAction implements IObjectActionDelegate {
// includeChildren = true;
// }
// StringBuilder sb = new StringBuilder();
-// buildDescriptionFromLogEntry(entry, sb, true);
+// buildDescriptionFromLogEntry(entry, sb, includeChildren);
- ErrorLogStatus status = createStatus(entry);
-
- new ErrorReporterManager().fail(status);
- }
-
- private ErrorLogStatus createStatus(LogEntry entry) {
ErrorLogStatus status = new ErrorLogStatus(entry.getSeverity(), entry.getPluginId(), entry.getCode(),
entry.getMessage());
- try {
- status.setDate(entry.getDate());
- status.setStack(entry.getStack());
- LogSession session = entry.getSession();
- if (session != null) {
- status.setLogSessionData(session.getSessionData());
- }
-
- if (entry.hasChildren()) {
- Object[] children = entry.getChildren(entry);
- if (children != null) {
- for (Object child : children) {
- if (child instanceof LogEntry) {
- ErrorLogStatus childStatus = createStatus((LogEntry) child);
- status.add(childStatus);
- }
- }
- }
- }
- } catch (Exception e) {
- // ignore any errors for setting additional attributes
+ status.setDate(entry.getDate());
+ status.setStack(entry.getStack());
+ LogSession session = entry.getSession();
+ if (session != null) {
+ status.setLogSessionData(session.getSessionData());
}
- return status;
+ new ErrorReporterManager().fail(status);
}
public void run() {
+ TreeItem[] items = treeViewer.getTree().getSelection();
+ LogEntry entry = null;
+ if (items.length > 0) {
+ entry = (LogEntry) items[0].getData();
+ }
+ if (entry == null) {
+ return;
+ }
+
createTask(entry);
}
@@ -123,14 +114,19 @@ public class NewTaskFromErrorAction implements IObjectActionDelegate {
run();
}
+ public void init(IViewPart view) {
+ ISelectionProvider sp = view.getViewSite().getSelectionProvider();
+ sp.addSelectionChangedListener(this);
+ sp.setSelection(sp.getSelection());
+ }
+
public void selectionChanged(IAction action, ISelection selection) {
- Object object = ((IStructuredSelection) selection).getFirstElement();
- if (object instanceof LogEntry) {
- entry = (LogEntry) object;
- }
+ // this selection is always empty? explicitly register a listener in
+ // init() instead
}
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ public void selectionChanged(SelectionChangedEvent event) {
+ treeViewer = (TreeViewer) event.getSource();
}
}
diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java
deleted file mode 100644
index 489b642a8..000000000
--- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 Frank Becker and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Frank Becker - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.tasks.bugs.actions;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.mylyn.tasks.core.TaskMapping;
-import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.markers.MarkerViewHandler;
-import org.eclipse.ui.views.markers.internal.MarkerType;
-import org.eclipse.ui.views.markers.internal.MarkerTypesModel;
-
-/**
- * Creates a new task from the selected marker entry.
- *
- * @author Frank Becker
- * @since 3.0
- */
-@SuppressWarnings("restriction")
-public class NewTaskFromMarkerHandler extends MarkerViewHandler {
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IMarker[] markers = getSelectedMarkers(event);
- if (markers.length == 0 || markers[0] == null) {
- MessageDialog.openInformation(null, "New Task from Marker", "No marker selected.");
- return null;
- }
- final IMarker marker = markers[0];
- TaskMapping mapping = new TaskMapping() {
-
- @Override
- public String getSummary() {
- StringBuilder sb = new StringBuilder();
- try {
- MarkerType type = MarkerTypesModel.getInstance().getType(marker.getType());
- sb.append(type.getLabel() + ": ");
- } catch (CoreException e) {
- // ignore
- }
-
- return sb.toString() + marker.getAttribute("message", "");
- }
-
- @Override
- public String getDescription() {
- return buildDescriptionFromMarkerItem(marker);
- }
-
- };
-
- TasksUiUtil.openNewTaskEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), mapping, null);
- return null;
- }
-
- private String buildDescriptionFromMarkerItem(IMarker marker) {
- StringBuilder sb = new StringBuilder();
- sb.append("Resource: " + marker.getResource().getFullPath().removeLastSegments(1).toString().substring(1) + "/"
- + marker.getResource().getName());
- int lineNumber = marker.getAttribute(IMarker.LINE_NUMBER, -1);
- if (lineNumber != -1) {
- sb.append("\nLocation: line " + lineNumber);
- }
- return sb.toString();
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java
new file mode 100644
index 000000000..96a249a4e
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java
@@ -0,0 +1,478 @@
+/*******************************************************************************
+* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Stack;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
+import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractAttributeFactory;
+import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractTaskDataHandler;
+import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskAttribute;
+import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
+import org.eclipse.mylyn.tasks.tests.connector.MockAttributeFactory;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.mylyn.tasks.tests.connector.MockTask;
+
+/**
+ * @author Rob Elves
+ */
+public class RepositoryTaskSynchronizationTest extends TestCase {
+
+ private static final String DATE_STAMP_3 = "2006-06-21 15:29:42";
+
+ private static final String DATE_STAMP_2 = "2006-06-21 15:29:41";
+
+ private static final String DATE_STAMP_1 = "2006-06-21 15:29:40";
+
+ private static final String MOCCK_ID = "1";
+
+ //private static final String URL1 = "http://www.eclipse.org/mylar";
+
+ private final TestRepositoryConnector connector = new TestRepositoryConnector();
+
+ private final TestOfflineTaskHandler handler = new TestOfflineTaskHandler();
+
+ private RepositoryTaskData newData;
+
+ public void testHasIncoming() {
+ MockTask task = new MockTask(MOCCK_ID);
+ RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(), connector.getConnectorKind(),
+ MockRepositoryConnector.REPOSITORY_URL, MOCCK_ID);
+ task.setLastReadTimeStamp("never");
+
+ assertTrue(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+ taskData.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, "2006-06-21 15:29:39");
+ assertTrue(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+ taskData.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, DATE_STAMP_1);
+ assertTrue(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+ task.setLastReadTimeStamp("2006-06-21 15:29:39");
+ assertTrue(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+ task.setLastReadTimeStamp(DATE_STAMP_1);
+ assertFalse(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+ }
+
+ public void testHasIncomingDateComparison() {
+ final Stack<Date> dates = new Stack<Date>();
+ MockTask task = new MockTask(MOCCK_ID);
+ RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Date getDateForAttributeType(String attributeKey, String dateString) {
+ return dates.pop();
+ }
+ }, connector.getConnectorKind(), MockRepositoryConnector.REPOSITORY_URL, MOCCK_ID);
+ task.setLastReadTimeStamp("never");
+
+ assertTrue(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+
+ // strings and dates mismatch
+ dates.push(new Date(1));
+ dates.push(new Date(2));
+ taskData.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, "2006-06-21 15:29:39");
+ assertTrue(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+
+ dates.push(null);
+ dates.push(new Date(2));
+ assertTrue(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+
+ dates.push(new Date());
+ dates.push(null);
+ assertTrue(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+
+ // strings mismatch but dates match
+ dates.push(new Date(1));
+ dates.push(new Date(1));
+ assertFalse(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+
+ // strings match, dates should not be checked
+ task.setLastReadTimeStamp("2006-06-21 15:29:39");
+ assertFalse(TasksUiPlugin.getTaskDataManager().checkHasIncoming(task, taskData));
+ }
+
+ public void testIncomingToIncoming() {
+ /*
+ * - Synchronize task with incoming changes - Make another change using
+ * browser - Open report in tasklist (editor opens with old 'new' data
+ * and background sync occurs) - Incoming status set again on task due
+ * to 2nd occurrence of new incoming data
+ */
+
+ // Test unforced
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.INCOMING, SynchronizationState.INCOMING);
+ RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
+ task.getTaskId());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ assertEquals(DATE_STAMP_2, newData.getLastModified());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, false);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ // TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
+ // assertEquals(DATE_STAMP_2, task.getLastSyncDateStamp());
+ // and again...
+
+ RepositoryTaskData taskData3 = new RepositoryTaskData(new MockAttributeFactory(), connector.getConnectorKind(),
+ MockRepositoryConnector.REPOSITORY_URL, "1");
+ taskData3.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, DATE_STAMP_3);
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, taskData3, false);
+ // last modified stamp not updated until user synchronizes (newdata ==
+ // olddata)
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
+ assertEquals(DATE_STAMP_3, taskData.getLastModified());
+
+ // Should keep INCOMING state state since new data has same date samp
+ // and sych is not forced.
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, taskData3, false);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
+ assertEquals(DATE_STAMP_3, taskData.getLastModified());
+ }
+
+ // Invalid state change. Test that this can't happen.
+ public void testIncomingToSynchronized() {
+ // When not forced, tasks with incoming state should remain in incoming
+ // state if
+ // if new data has same date stamp as old data.
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.INCOMING, SynchronizationState.SYNCHRONIZED);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, false);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+
+ task = primeTaskAndRepository(SynchronizationState.INCOMING, SynchronizationState.SYNCHRONIZED);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, true);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ // assertEquals(SynchronizationState.SYNCHRONIZED,
+ // task.getSyncState());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+
+ // Test forced with remote incoming
+ // Update: bug#163850 - synchronize gets new data but doesn't mark
+ // synchronized
+ task = primeTaskAndRepository(SynchronizationState.INCOMING, SynchronizationState.INCOMING);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, true);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+
+ }
+
+ // public void testIncomingToSynchronizedWithVoidSyncTime() {
+ // // IF the last sync time (modified timestamp on task) is null, this can
+ // result
+ // // in the editor refresh/repoen going into an infinite loops since the
+ // task never
+ // // gets to a synchronized state if the last mod time isn't set. It is now
+ // being set
+ // // if found to be null.
+ // AbstractTask task =
+ // primeTaskAndRepository(SynchronizationState.INCOMING,
+ // SynchronizationState.SYNCHRONIZED);
+ // assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
+ // task.setLastSyncDateStamp(null);
+ // TasksUiPlugin.getSynchronizationManager().updateOfflineState(task,
+ // newData, false);
+ // assertEquals(SynchronizationState.INCOMING, task.getSyncState());
+ // assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
+ //
+ // TasksUiPlugin.getSynchronizationManager().updateOfflineState(task,
+ // newData, false);
+ // assertEquals(SynchronizationState.SYNCHRONIZED, task.getSyncState());
+ // assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
+ // }
+
+ /*
+ * public void testIncomingToConflict() { // invalid }
+ */
+
+ /*
+ * public void testIncomingToOutgoing() { // invalid }
+ */
+
+ public void testSynchronizedToIncoming() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.SYNCHRONIZED, SynchronizationState.INCOMING);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, false);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
+ task.getTaskId());
+ assertEquals(DATE_STAMP_2, taskData.getLastModified());
+ // assertEquals(DATE_STAMP_2, task.getLastModifiedDateStamp());
+ }
+
+ public void testSynchronizedToSynchronized() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.SYNCHRONIZED, SynchronizationState.SYNCHRONIZED);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, false);
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ }
+
+ /*
+ * public void testSynchronizedToConflict() { // invalid }
+ */
+
+ public void testSynchronizedToOutgoing() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.SYNCHRONIZED, SynchronizationState.SYNCHRONIZED);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+
+ RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getEditableCopy(
+ task.getRepositoryUrl(), task.getTaskId());
+
+ taskData.setNewComment("new comment");
+
+ HashSet<RepositoryTaskAttribute> changed = new HashSet<RepositoryTaskAttribute>();
+ changed.add(taskData.getAttribute(RepositoryTaskAttribute.COMMENT_NEW));
+ TasksUiPlugin.getTaskDataManager().saveOutgoing(task, changed);
+ assertEquals(SynchronizationState.OUTGOING, task.getSynchronizationState());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ }
+
+ public void testConflictToConflict() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.CONFLICT, SynchronizationState.INCOMING);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, true);
+ assertEquals(SynchronizationState.CONFLICT, task.getSynchronizationState());
+ RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
+ task.getTaskId());
+
+ assertEquals(DATE_STAMP_2, taskData.getLastModified());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, true);
+ assertEquals(SynchronizationState.CONFLICT, task.getSynchronizationState());
+ taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
+ assertEquals(DATE_STAMP_2, taskData.getLastModified());
+ }
+
+ /*
+ * public void testConflictToSynchonized() { // invalid, requires markRead }
+ */
+
+ /*
+ * public void testConflictToConflict() { // ui involved }
+ */
+
+ /*
+ * public void testConflictToOutgoing() { // invalid? }
+ */
+
+ // TODO: Test merging new incoming with outgoing
+ // TODO: Test discard outgoing
+ public void testOutgoingToConflict() {
+ // Forced
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.OUTGOING, SynchronizationState.INCOMING);
+ RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
+ task.getTaskId());
+
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ assertEquals(SynchronizationState.OUTGOING, task.getSynchronizationState());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, true);
+ assertEquals(SynchronizationState.CONFLICT, task.getSynchronizationState());
+ taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
+
+ assertEquals(DATE_STAMP_2, taskData.getLastModified());
+ // assertEquals(DATE_STAMP_2, task.getLastModifiedDateStamp());
+ }
+
+ // Illegal state change, test it doesn't occur
+ public void testOutgoingToSynchronized() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.OUTGOING, SynchronizationState.SYNCHRONIZED);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, true);
+ assertEquals(SynchronizationState.OUTGOING, task.getSynchronizationState());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ }
+
+ public void testOutgoingToOutgoing() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.OUTGOING, SynchronizationState.SYNCHRONIZED);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ TasksUiPlugin.getTaskDataManager().saveIncoming(task, newData, false);
+ assertEquals(SynchronizationState.OUTGOING, task.getSynchronizationState());
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ }
+
+ public void testMarkRead() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.INCOMING, SynchronizationState.SYNCHRONIZED);
+ task.setLastReadTimeStamp(null);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
+ assertEquals(DATE_STAMP_1, task.getLastReadTimeStamp());
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+ }
+
+ public void testMarkUnread() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.SYNCHRONIZED, SynchronizationState.SYNCHRONIZED);
+ task.setLastReadTimeStamp(null);
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+ TasksUiPlugin.getTaskDataManager().setTaskRead(task, false);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ }
+
+ public void testClearOutgoing() {
+ AbstractTask task = primeTaskAndRepository(SynchronizationState.SYNCHRONIZED, SynchronizationState.SYNCHRONIZED);
+ RepositoryTaskData taskData1 = new RepositoryTaskData(new MockAttributeFactory(),
+ MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
+ TasksUiPlugin.getTaskDataStorageManager().setNewTaskData(taskData1);
+ taskData1 = TasksUiPlugin.getTaskDataStorageManager()
+ .getEditableCopy(task.getRepositoryUrl(), task.getTaskId());
+
+ taskData1.setNewComment("Testing");
+ Set<RepositoryTaskAttribute> edits = new HashSet<RepositoryTaskAttribute>();
+ edits.add(taskData1.getAttribute(RepositoryTaskAttribute.COMMENT_NEW));
+ TasksUiPlugin.getTaskDataStorageManager().saveEdits(task.getRepositoryUrl(), task.getTaskId(), edits);
+
+ RepositoryTaskData editedData = TasksUiPlugin.getTaskDataStorageManager().getEditableCopy(
+ task.getRepositoryUrl(), task.getTaskId());
+ assertEquals("Testing", editedData.getNewComment());
+
+ TasksUiPlugin.getTaskDataManager().discardOutgoing(task);
+
+ assertTrue(task.getSynchronizationState().equals(SynchronizationState.SYNCHRONIZED));
+ RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getEditableCopy(
+ task.getRepositoryUrl(), task.getTaskId());
+ assertEquals("", taskData.getNewComment());
+
+ }
+
+ private class TestOfflineTaskHandler extends AbstractTaskDataHandler {
+
+ @Override
+ public AbstractAttributeFactory getAttributeFactory(String repositoryUrl, String repositoryKind, String taskKind) {
+ // ignore
+ return null;
+ }
+
+ public Set<AbstractTask> getChangedSinceLastSync(TaskRepository repository, Set<AbstractTask> tasks)
+ throws CoreException {
+ return null;
+ }
+
+ @Override
+ public RepositoryTaskData getTaskData(TaskRepository repository, String taskId, IProgressMonitor monitor)
+ throws CoreException {
+ return null;
+ }
+
+ @Override
+ public String postTaskData(TaskRepository repository, RepositoryTaskData taskData, IProgressMonitor monitor)
+ throws CoreException {
+ // ignore
+ return null;
+ }
+
+ @Override
+ public boolean initializeTaskData(TaskRepository repository, RepositoryTaskData data, IProgressMonitor monitor)
+ throws CoreException {
+ // ignore
+ return false;
+ }
+
+ @Override
+ public AbstractAttributeFactory getAttributeFactory(RepositoryTaskData taskData) {
+ // ignore
+ return null;
+ }
+
+ @Override
+ public Set<String> getSubTaskIds(RepositoryTaskData taskData) {
+ return Collections.emptySet();
+ }
+
+ // private final String DATE_FORMAT_2 = "yyyy-MM-dd HH:mm:ss";
+ //
+ // private final SimpleDateFormat format = new
+ // SimpleDateFormat(DATE_FORMAT_2);
+ //
+ //
+ // public Date getDateForAttributeType(String attributeKey, String
+ // dateString) {
+ //
+ // try {
+ // return format.parse(dateString);
+ // } catch (ParseException e) {
+ // return null;
+ // }
+ // }
+
+ }
+
+ private class TestRepositoryConnector extends MockRepositoryConnector {
+
+ @Override
+ public AbstractTaskDataHandler getLegacyTaskDataHandler() {
+ return handler;
+ }
+
+ // @Override
+ // protected void removeOfflineTaskData(RepositoryTaskData bug) {
+ // // ignore
+ // }
+ //
+ // @Override
+ // public void saveOffline(RepositoryTaskData taskData) {
+ // // ignore
+ // }
+
+ // @Override
+ // protected RepositoryTaskData
+ // loadOfflineTaskData(AbstractTask repositoryTask) {
+ // return repositoryTask.getTaskData();
+ // }
+
+ }
+
+ private AbstractTask primeTaskAndRepository(SynchronizationState localState, SynchronizationState remoteState) {
+ RepositoryTaskData taskData = null;
+ AbstractTask task = new MockTask(MOCCK_ID);
+
+ taskData = new RepositoryTaskData(new MockAttributeFactory(), connector.getConnectorKind(),
+ MockRepositoryConnector.REPOSITORY_URL, MOCCK_ID);
+ taskData.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, DATE_STAMP_1);
+ task.setLastReadTimeStamp(DATE_STAMP_1);
+ task.setSynchronizationState(localState);
+ TasksUiPlugin.getTaskDataStorageManager().setNewTaskData(taskData);
+ newData = new RepositoryTaskData(new MockAttributeFactory(), connector.getConnectorKind(),
+ MockRepositoryConnector.REPOSITORY_URL, MOCCK_ID);
+
+ switch (remoteState) {
+ case CONFLICT:
+ case INCOMING:
+ newData.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, DATE_STAMP_2);
+ break;
+ case SYNCHRONIZED:
+ newData.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, DATE_STAMP_1);
+ break;
+ default:
+ fail("Remote repository can only be INCOMING or SYNCHRONIZED wrt the local task.");
+
+ }
+
+ return task;
+
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java
new file mode 100644
index 000000000..e665caa02
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
+import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
+import org.eclipse.mylyn.tasks.tests.connector.MockTask;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+
+/**
+ * @author Shawn Minto
+ */
+public class TaskActivityListenerTest extends TestCase {
+
+ private class MockTaskActivationListener extends TaskActivationAdapter {
+
+ private boolean hasActivated = false;
+
+ private boolean hasPreActivated = false;
+
+ private boolean hasDeactivated = false;
+
+ private boolean hasPreDeactivated = false;
+
+ public void reset() {
+ hasActivated = false;
+ hasPreActivated = false;
+
+ hasDeactivated = false;
+ hasPreDeactivated = false;
+
+ }
+
+ @Override
+ public void preTaskActivated(ITask task) {
+ assertFalse(hasActivated);
+ hasPreActivated = true;
+ }
+
+ @Override
+ public void preTaskDeactivated(ITask task) {
+ assertFalse(hasDeactivated);
+ hasPreDeactivated = true;
+ }
+
+ @Override
+ public void taskActivated(ITask task) {
+ assertTrue(hasPreActivated);
+ hasActivated = true;
+ }
+
+ @Override
+ public void taskDeactivated(ITask task) {
+ assertTrue(hasPreDeactivated);
+ hasDeactivated = true;
+ }
+
+ }
+
+ private ITaskActivityManager taskActivityManager;
+
+ @Override
+ protected void setUp() throws Exception {
+ taskActivityManager = TasksUi.getTaskActivityManager();
+ taskActivityManager.deactivateActiveTask();
+ }
+
+ public void testTaskActivation() {
+ MockTask task = new MockTask("test:activation");
+ MockTaskActivationListener listener = new MockTaskActivationListener();
+ try {
+ taskActivityManager.addActivationListener(listener);
+ try {
+ taskActivityManager.activateTask(task);
+ assertTrue(listener.hasPreActivated);
+ assertTrue(listener.hasActivated);
+ assertFalse(listener.hasPreDeactivated);
+ assertFalse(listener.hasDeactivated);
+
+ listener.reset();
+ } finally {
+ taskActivityManager.deactivateTask(task);
+ }
+ assertFalse(listener.hasPreActivated);
+ assertFalse(listener.hasActivated);
+ assertTrue(listener.hasPreDeactivated);
+ assertTrue(listener.hasDeactivated);
+ } finally {
+ TasksUiPlugin.getTaskActivityManager().removeActivationListener(listener);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
new file mode 100644
index 000000000..f44f0b8f3
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
@@ -0,0 +1,1006 @@
+/*******************************************************************************
+* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
+import org.eclipse.mylyn.internal.context.core.InteractionContext;
+import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
+import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
+import org.eclipse.mylyn.internal.tasks.core.AbstractTaskCategory;
+import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
+import org.eclipse.mylyn.internal.tasks.core.ITaskList;
+import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
+import org.eclipse.mylyn.internal.tasks.core.LocalTask;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
+import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
+import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
+import org.eclipse.mylyn.internal.tasks.core.TaskList;
+import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
+import org.eclipse.mylyn.internal.tasks.ui.RefactorRepositoryUrlOperation;
+import org.eclipse.mylyn.internal.tasks.ui.TaskListManager;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.monitor.core.InteractionEvent;
+import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskContainer;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.tests.connector.MockAttributeFactory;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryQuery;
+import org.eclipse.mylyn.tasks.tests.connector.MockTask;
+
+/**
+ * @author Mik Kersten
+ */
+public class TaskListManagerTest extends TestCase {
+
+ private TaskListManager manager;
+
+ private TaskRepository repository;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ TasksUiPlugin.getDefault().getPreferenceStore().setValue(
+ ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, false);
+ manager = TasksUiPlugin.getTaskListManager();
+ for (TaskRepository repository : TasksUiPlugin.getRepositoryManager().getAllRepositories()) {
+ TasksUiPlugin.getRepositoryManager().removeRepository(repository,
+ TasksUiPlugin.getDefault().getRepositoriesFilePath());
+ }
+ manager.resetTaskList();
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+// manager.readExistingOrCreateNewList();
+ TasksUiPlugin.getExternalizationManager().save(true);
+ TasksUiPlugin.getDefault().reloadDataDirectory();
+
+ repository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL);
+ TasksUiPlugin.getRepositoryManager().addRepository(repository);
+
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ TasksUiPlugin.getRepositoryManager().removeRepository(repository,
+ TasksUiPlugin.getDefault().getRepositoriesFilePath());
+ manager.resetTaskList();
+ TasksUiPlugin.getExternalizationManager().save(true);
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ }
+
+ public void testUncategorizedTasksNotLost() throws CoreException {
+ MockRepositoryQuery query = new MockRepositoryQuery("Test");
+ manager.getTaskList().addQuery(query);
+ MockTask task = new MockTask("1");
+ manager.getTaskList().addTask(task, query);
+ manager.getTaskList().addTask(task, manager.getTaskList().getDefaultCategory());
+ assertTrue(query.contains(task.getHandleIdentifier()));
+ assertTrue(manager.getTaskList().getDefaultCategory().contains(task.getHandleIdentifier()));
+
+ TasksUiPlugin.getExternalizationManager().requestSave();
+ manager.resetTaskList();
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ assertFalse(manager.getTaskList().getDefaultCategory().contains(task.getHandleIdentifier()));
+ TasksUiPlugin.getDefault().reloadDataDirectory();
+
+ assertTrue(manager.getTaskList().getDefaultCategory().contains(task.getHandleIdentifier()));
+
+ }
+
+ public void testQueryAndCategoryNameClash() {
+ TaskCategory category = new TaskCategory("TestClash");
+ manager.getTaskList().addCategory(category);
+ assertTrue(manager.getTaskList().getCategories().contains(category));
+ assertEquals(2, manager.getTaskList().getCategories().size());
+
+ MockRepositoryQuery query = new MockRepositoryQuery("TestClash");
+ manager.getTaskList().addQuery(query);
+ assertTrue(manager.getTaskList().getCategories().contains(category));
+ assertEquals(2, manager.getTaskList().getCategories().size());
+
+ manager.getTaskList().deleteCategory(category);
+ }
+
+ public void testUniqueTaskID() {
+ LocalTask task1 = TasksUiInternal.createNewLocalTask("label");
+ manager.getTaskList().addTask(task1);
+ LocalTask task2 = TasksUiInternal.createNewLocalTask("label");
+ manager.getTaskList().addTask(task2);
+ assertEquals(2, manager.getTaskList().getLastLocalTaskId());
+ manager.getTaskList().deleteTask(task2);
+ LocalTask task3 = TasksUiInternal.createNewLocalTask("label");
+ manager.getTaskList().addTask(task3);
+ assertTrue(task3.getHandleIdentifier() + " should end with 3", task3.getHandleIdentifier().endsWith("3"));
+ assertEquals(3, manager.getTaskList().getLastLocalTaskId());
+
+ assertEquals(2, manager.getTaskList().getAllTasks().size());
+ manager.saveTaskList();
+ manager.resetTaskList();
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ assertEquals(0, manager.getTaskList().getLastLocalTaskId());
+ manager.readExistingOrCreateNewList();
+ assertEquals(2, manager.getTaskList().getAllTasks().size());
+ assertEquals(3, manager.getTaskList().getLastLocalTaskId());
+ ITask task4 = TasksUiInternal.createNewLocalTask("label");
+ assertTrue(task4.getHandleIdentifier() + " should end with 4", task4.getHandleIdentifier().endsWith("4"));
+ }
+
+ public void testSingleTaskDeletion() {
+ MockTask task = new MockTask("1");
+ task.setLastReadTimeStamp("now");
+ manager.getTaskList().addTask(task,
+ manager.getTaskList().getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+ manager.getTaskList().deleteTask(task);
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ manager.getTaskList().addTask(task,
+ manager.getTaskList().getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+
+ manager.saveTaskList();
+
+ manager.resetTaskList();
+ manager.readExistingOrCreateNewList();
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+
+ manager.getTaskList().deleteTask(task);
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ manager.saveTaskList();
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+
+ manager.resetTaskList();
+ manager.readExistingOrCreateNewList();
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ }
+
+ private void runRepositoryUrlOperation(String oldUrl, String newUrl) {
+ try {
+ new RefactorRepositoryUrlOperation(oldUrl, newUrl).run(new NullProgressMonitor());
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testMigrateTaskContextFiles() throws IOException {
+ File fileA = ContextCorePlugin.getContextStore().getFileForContext("http://a-1");
+ fileA.createNewFile();
+ fileA.deleteOnExit();
+ assertTrue(fileA.exists());
+ runRepositoryUrlOperation("http://a", "http://b");
+ File fileB = ContextCorePlugin.getContextStore().getFileForContext("http://b-1");
+ assertTrue(fileB.exists());
+ assertFalse(fileA.exists());
+ }
+
+ public void testMigrateQueryUrlHandles() {
+ RepositoryQuery query = new MockRepositoryQuery("mquery");
+ query.setRepositoryUrl("http://foo.bar");
+ query.setUrl("http://foo.bar/b");
+ manager.getTaskList().addQuery(query);
+ assertTrue(manager.getTaskList().getRepositoryQueries("http://foo.bar").size() > 0);
+ runRepositoryUrlOperation("http://foo.bar", "http://bar.baz");
+ assertTrue(manager.getTaskList().getRepositoryQueries("http://foo.bar").size() == 0);
+ assertTrue(manager.getTaskList().getRepositoryQueries("http://bar.baz").size() > 0);
+ IRepositoryQuery changedQuery = manager.getTaskList().getRepositoryQueries("http://bar.baz").iterator().next();
+ assertEquals("http://bar.baz/b", changedQuery.getUrl());
+ }
+
+ public void testMigrateQueryHandles() {
+ RepositoryQuery query = new MockRepositoryQuery("mquery");
+ query.setRepositoryUrl("http://a");
+ manager.getTaskList().addQuery(query);
+ runRepositoryUrlOperation("http://a", "http://b");
+ assertFalse(manager.getTaskList().getRepositoryQueries("http://b").isEmpty());
+ assertTrue(manager.getTaskList().getRepositoryQueries("http://a").isEmpty());
+ }
+
+// public void testMigrateQueryHits() {
+// AbstractRepositoryQuery query = new MockRepositoryQuery("mquery",
+// manager.getTaskList());
+// query.setRepositoryUrl("http://a");
+// manager.getTaskList().addQuery(query);
+// AbstractQueryHit hit = new MockQueryHit(manager.getTaskList(), "http://a",
+// "", "123");
+// query.addHit(hit);
+// runRepositoryUrlOperation("http://a", "http://b");
+// assertNotNull(manager.getTaskList().getQueryHit("http://b-123"));
+// assertEquals("http://b-123", hit.getHandleIdentifier());
+// }
+
+ public void testMigrateTaskHandles() {
+ AbstractTask task = new MockTask("http://a", "123");
+ AbstractTask task2 = new MockTask("http://other", "other");
+ manager.getTaskList().addTask(task);
+ manager.getTaskList().addTask(task2);
+
+ RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(), task.getConnectorKind(),
+ task.getRepositoryUrl(), task.getTaskId(), task.getTaskKind());
+ TasksUiPlugin.getTaskDataStorageManager().setNewTaskData(taskData);
+ assertNotNull(TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
+ task.getTaskId()));
+
+ RepositoryTaskData taskData2 = new RepositoryTaskData(new MockAttributeFactory(), task2.getConnectorKind(),
+ task2.getRepositoryUrl(), task2.getTaskId(), task2.getTaskKind());
+ taskData2.setNewComment("TEST");
+ TasksUiPlugin.getTaskDataStorageManager().setNewTaskData(taskData2);
+ assertNotNull(TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task2.getRepositoryUrl(),
+ task2.getTaskId()));
+ assertEquals("TEST", TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task2.getRepositoryUrl(),
+ task2.getTaskId()).getNewComment());
+
+ runRepositoryUrlOperation("http://a", "http://b");
+ assertNull(manager.getTaskList().getTask("http://a-123"));
+ assertNotNull(manager.getTaskList().getTask("http://b-123"));
+ assertNotNull(TasksUiPlugin.getTaskDataStorageManager().getNewTaskData("http://b", "123"));
+ RepositoryTaskData otherData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(
+ task2.getRepositoryUrl(), task2.getTaskId());
+ assertNotNull(otherData);
+ assertEquals("TEST", otherData.getNewComment());
+ }
+
+ public void testMigrateTaskHandlesWithExplicitSet() {
+ AbstractTask task = new MockTask("http://a", "123");
+ task.setUrl("http://a/task/123");
+ manager.getTaskList().addTask(task);
+ runRepositoryUrlOperation("http://a", "http://b");
+ assertNull(manager.getTaskList().getTask("http://a-123"));
+ assertNotNull(manager.getTaskList().getTask("http://b-123"));
+ assertEquals("http://b/task/123", task.getUrl());
+ }
+
+ public void testRefactorMetaContextHandles() {
+ String firstUrl = "http://repository1.com/bugs";
+ String secondUrl = "http://repository2.com/bugs";
+ AbstractTask task1 = new MockTask(firstUrl, "1");
+ AbstractTask task2 = new MockTask(firstUrl, "2");
+ manager.getTaskList().addTask(task1);
+ manager.getTaskList().addTask(task2);
+ Calendar startDate = Calendar.getInstance();
+ Calendar endDate = Calendar.getInstance();
+ endDate.add(Calendar.MINUTE, 5);
+
+ Calendar startDate2 = Calendar.getInstance();
+ startDate2.add(Calendar.MINUTE, 15);
+ Calendar endDate2 = Calendar.getInstance();
+ endDate2.add(Calendar.MINUTE, 25);
+
+ ContextCorePlugin.getContextManager().resetActivityMetaContext();
+ InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
+ assertEquals(0, metaContext.getInteractionHistory().size());
+
+ ContextCorePlugin.getContextManager().processActivityMetaContextEvent(
+ new InteractionEvent(InteractionEvent.Kind.ATTENTION,
+ InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(), "origin",
+ null, InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startDate.getTime(),
+ endDate.getTime()));
+
+ ContextCorePlugin.getContextManager().processActivityMetaContextEvent(
+ new InteractionEvent(InteractionEvent.Kind.ATTENTION,
+ InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task2.getHandleIdentifier(), "origin",
+ null, InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startDate2.getTime(),
+ endDate2.getTime()));
+
+ assertEquals(2, metaContext.getInteractionHistory().size());
+ assertEquals(60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
+ assertEquals(2 * 60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task2));
+ runRepositoryUrlOperation(firstUrl, secondUrl);
+ metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
+ assertEquals(2, metaContext.getInteractionHistory().size());
+ assertEquals(60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(new MockTask(secondUrl, "1")));
+ assertEquals(2 * 60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(
+ new MockTask(secondUrl, "2")));
+ assertEquals(secondUrl + "-1", metaContext.getInteractionHistory().get(0).getStructureHandle());
+ }
+
+ public void testIsActiveToday() {
+ AbstractTask task = new LocalTask("1", "task-1");
+ assertFalse(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
+
+ task.setScheduledForDate(TaskActivityUtil.getCurrentWeek().getToday());
+ assertTrue(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
+
+ task.setReminded(true);
+ assertTrue(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
+ task.setReminded(true);
+
+// Calendar inAnHour = Calendar.getInstance();
+// inAnHour.set(Calendar.HOUR_OF_DAY, inAnHour.get(Calendar.HOUR_OF_DAY) + 1);
+// inAnHour.getTime();
+// task.setScheduledForDate(inAnHour.getTime());
+// Calendar tomorrow = Calendar.getInstance();
+// TaskActivityUtil.snapToNextDay(tomorrow);
+// assertEquals(-1, inAnHour.compareTo(tomorrow));
+// assertTrue(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
+ }
+
+ public void testScheduledForToday() {
+ AbstractTask task = new LocalTask("1", "task-1");
+ task.setScheduledForDate(TaskActivityUtil.getCurrentWeek().getToday());
+ assertTrue(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
+ task.setScheduledForDate(TaskActivityUtil.getCurrentWeek().getToday().next());
+ assertFalse(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
+ }
+
+ public void testSchedulePastEndOfMonth() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Calendar.MONTH, Calendar.SEPTEMBER);
+ calendar.set(Calendar.DAY_OF_MONTH, 30);
+ TaskActivityUtil.snapForwardNumDays(calendar, 1);
+ assertEquals("Should be October", Calendar.OCTOBER, calendar.get(Calendar.MONTH));
+ }
+
+ public void testIsCompletedToday() {
+ ITask task = new LocalTask("1", "task 1");
+ task.setCompletionDate(new Date());
+ assertTrue(TasksUiPlugin.getTaskActivityManager().isCompletedToday(task));
+
+ MockTask mockTask = new MockTask("1");
+ mockTask.setOwner("unknown");
+ manager.getTaskList().addTask(mockTask);
+ mockTask.setCompletionDate(new Date());
+ assertFalse("completed: " + mockTask.getCompletionDate(), TasksUiPlugin.getTaskActivityManager()
+ .isCompletedToday(mockTask));
+
+ mockTask = new MockTask("2");
+ manager.getTaskList().addTask(mockTask);
+ mockTask.setCompletionDate(new Date());
+ repository.setAuthenticationCredentials("testUser", "testPassword");
+ mockTask.setOwner("testUser");
+ assertTrue(TasksUiPlugin.getTaskActivityManager().isCompletedToday(mockTask));
+
+ }
+
+ public void testMoveCategories() {
+// assertEquals(0, manager.getTaskList()
+// .getOrphanContainer(LocalRepositoryConnector.REPOSITORY_URL)
+// .getChildren()
+// .size());
+
+ assertTrue(manager.getTaskList().getDefaultCategory().isEmpty());
+
+ AbstractTask task1 = new LocalTask("t1", "t1");
+
+ TaskCategory cat1 = new TaskCategory("cat1");
+ manager.getTaskList().addCategory(cat1);
+ TaskCategory cat2 = new TaskCategory("cat2");
+ manager.getTaskList().addCategory(cat2);
+
+ manager.getTaskList().addTask(task1, cat1);
+ assertEquals(1, manager.getTaskList().getContainerForHandle("cat1").getChildren().size());
+ assertEquals(0, manager.getTaskList().getContainerForHandle("cat2").getChildren().size());
+
+ manager.getTaskList().addTask(task1, cat2);
+ assertEquals(0, manager.getTaskList().getContainerForHandle("cat1").getChildren().size());
+ assertEquals(1, manager.getTaskList().getContainerForHandle("cat2").getChildren().size());
+ }
+
+ public void testMoveToRoot() {
+// assertEquals(0, manager.getTaskList()
+// .getOrphanContainer(LocalRepositoryConnector.REPOSITORY_URL)
+// .getChildren()
+// .size());
+ assertTrue(manager.getTaskList().getDefaultCategory().isEmpty());
+
+ AbstractTask task1 = new LocalTask("t1", "t1");
+ manager.getTaskList().addTask(task1,
+ manager.getTaskList().getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
+ assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
+ assertEquals(manager.getTaskList().getDefaultCategory(), TaskCategory.getParentTaskCategory(task1));
+
+ TaskCategory cat1 = new TaskCategory("c1");
+ manager.getTaskList().addCategory(cat1);
+
+ manager.getTaskList().addTask(task1, cat1);
+ assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
+ assertEquals(cat1, TaskCategory.getParentTaskCategory(task1));
+
+ manager.getTaskList().addTask(task1,
+ manager.getTaskList().getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
+ assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
+ assertEquals(0, cat1.getChildren().size());
+ assertEquals(manager.getTaskList().getDefaultCategory(), TaskCategory.getParentTaskCategory(task1));
+ }
+
+ public void testCategoryPersistance() {
+ MockTask task = new MockTask("1");
+ TaskCategory category = new TaskCategory("cat");
+ manager.getTaskList().addCategory(category);
+ manager.getTaskList().addTask(task, category);
+ assertNotNull(manager.getTaskList());
+ assertEquals(2, manager.getTaskList().getCategories().size());
+
+ manager.saveTaskList();
+ manager.resetTaskList();
+ manager.readExistingOrCreateNewList();
+ assertEquals("" + manager.getTaskList().getCategories(), 2, manager.getTaskList().getCategories().size());
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+ }
+
+ public void testDeleteCategory() {
+ assertNotNull(manager.getTaskList());
+ assertEquals(1, manager.getTaskList().getCategories().size());
+ TaskCategory category = new TaskCategory("cat");
+ manager.getTaskList().addCategory(category);
+ assertEquals(2, manager.getTaskList().getCategories().size());
+ manager.getTaskList().deleteCategory(category);
+ assertEquals(1, manager.getTaskList().getCategories().size());
+ }
+
+ public void testDeleteCategoryMovesTasksToRoot() {
+ AbstractTask task = new MockTask("delete");
+ TaskCategory category = new TaskCategory("cat");
+ manager.getTaskList().addCategory(category);
+ manager.getTaskList().addTask(task, category);
+ assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
+ manager.getTaskList().deleteCategory(category);
+ manager.getTaskList().getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL);
+ }
+
+ public void testRenameCategory() {
+
+ assertNotNull(manager.getTaskList());
+
+ TaskCategory category = new TaskCategory("cat");
+ manager.getTaskList().addCategory(category);
+ assertEquals(2, manager.getTaskList().getCategories().size());
+ String newDesc = "newDescription";
+ manager.getTaskList().renameContainer(category, newDesc);
+ AbstractTaskCategory container = manager.getTaskList().getContainerForHandle(newDesc);
+ assertNotNull(container);
+ assertEquals(newDesc, container.getSummary());
+ manager.getTaskList().deleteCategory(container);
+ assertEquals(1, manager.getTaskList().getCategories().size());
+ }
+
+ public void testDeleteCategoryAfterRename() {
+ String newDesc = "newDescription";
+ assertNotNull(manager.getTaskList());
+ assertEquals(1, manager.getTaskList().getCategories().size());
+ TaskCategory category = new TaskCategory("cat");
+ manager.getTaskList().addCategory(category);
+ assertEquals(2, manager.getTaskList().getCategories().size());
+ manager.getTaskList().renameContainer(category, newDesc);
+ manager.getTaskList().deleteCategory(category);
+ assertEquals(1, manager.getTaskList().getCategories().size());
+ }
+
+ public void testCreateSameCategoryName() {
+ assertNotNull(manager.getTaskList());
+ assertEquals(1, manager.getTaskList().getCategories().size());
+ TaskCategory category = new TaskCategory("cat");
+ manager.getTaskList().addCategory(category);
+ assertEquals(2, manager.getTaskList().getCategories().size());
+ TaskCategory category2 = new TaskCategory("cat");
+ manager.getTaskList().addCategory(category2);
+ assertEquals(2, manager.getTaskList().getCategories().size());
+ ITaskContainer container = manager.getTaskList().getContainerForHandle("cat");
+ assertEquals(container, category);
+ }
+
+ public void testDeleteRootTask() {
+ AbstractTask task = new LocalTask("1", "label");
+ manager.getTaskList().addTask(task);
+ manager.getTaskList().deleteTask(task);
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
+ }
+
+ public void testDeleteFromCategory() {
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
+ //assertEquals(0, manager.getTaskList().getArchiveContainer().getChildren().size());
+ assertEquals(1, manager.getTaskList().getCategories().size());
+
+ AbstractTask task = new LocalTask("1", "label");
+ TaskCategory category = new TaskCategory("handleAndDescription");
+ manager.getTaskList().addTask(task);
+ assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
+
+ manager.getTaskList().addCategory(category);
+ manager.getTaskList().addTask(task, category);
+ assertEquals(2, manager.getTaskList().getCategories().size());
+ assertEquals(1, category.getChildren().size());
+ assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+
+ manager.getTaskList().deleteTask(task);
+ assertEquals(0, manager.getTaskList().getAllTasks().size());
+ assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
+ assertEquals(0, category.getChildren().size());
+ }
+
+ public void testDeleteRepositoryTask() {
+ String repositoryUrl = "http://somewhere.com";
+ repository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND, repositoryUrl);
+ TasksUiPlugin.getRepositoryManager().addRepository(repository);
+ MockTask task = new MockTask(repositoryUrl, "1");
+ TaskList taskList = TasksUiPlugin.getTaskList();
+ taskList.addTask(task, manager.getTaskList().getDefaultCategory());
+ MockRepositoryQuery query = new MockRepositoryQuery("query");
+ taskList.addQuery(query);
+ taskList.addTask(task, query);
+ assertEquals(1, taskList.getAllTasks().size());
+ assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
+ taskList.deleteTask(task);
+ assertEquals(0, taskList.getAllTasks().size());
+ assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
+ }
+
+ public void testCreate() {
+ MockTask repositoryTask = new MockTask("1");
+ repositoryTask.setLastReadTimeStamp("now");
+ manager.getTaskList().addTask(repositoryTask, manager.getTaskList().getDefaultCategory());
+ assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
+ manager.saveTaskList();
+
+ manager.resetTaskList();
+ manager.readExistingOrCreateNewList();
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+ }
+
+ public void testCreateAndMove() throws CoreException {
+ MockTask repositoryTask = new MockTask("1");
+ repositoryTask.setLastReadTimeStamp("now");
+ manager.getTaskList().addTask(repositoryTask);
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+ TasksUiPlugin.getExternalizationManager().requestSave();
+ TasksUiPlugin.getDefault().reloadDataDirectory();
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+ assertEquals(1, manager.getTaskList()
+ .getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL)
+ .getChildren()
+ .size());
+
+ }
+
+ public void testArchiveRepositoryTaskExternalization() {
+ MockTask repositoryTask = new MockTask("1");
+ repositoryTask.setLastReadTimeStamp("now");
+ manager.getTaskList().addTask(repositoryTask);
+ assertEquals(1, manager.getTaskList()
+ .getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL)
+ .getChildren()
+ .size());
+ manager.saveTaskList();
+
+ manager.resetTaskList();
+ manager.readExistingOrCreateNewList();
+ assertEquals(1, manager.getTaskList()
+ .getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL)
+ .getChildren()
+ .size());
+ }
+
+ public void testRepositoryTasksAndCategoriesMultiRead() {
+ TaskCategory cat1 = new TaskCategory("Category 1");
+ manager.getTaskList().addCategory(cat1);
+
+ MockTask reportInCat1 = new MockTask("123");
+ manager.getTaskList().addTask(reportInCat1, cat1);
+ assertEquals(cat1, TaskCategory.getParentTaskCategory(reportInCat1));
+
+ manager.saveTaskList();
+ assertNotNull(manager.getTaskList());
+ manager.resetTaskList();
+ manager.readExistingOrCreateNewList();
+
+ // read once
+ Set<AbstractTaskCategory> readCats = manager.getTaskList().getTaskCategories();
+ assertTrue(manager.getTaskList().getCategories().contains(cat1));
+ Iterator<AbstractTaskCategory> iterator = readCats.iterator();
+
+ boolean found = false;
+ while (iterator.hasNext()) {
+ ITaskContainer readCat1 = iterator.next();
+ if (cat1.equals(readCat1)) {
+ found = true;
+ assertEquals(1, readCat1.getChildren().size());
+ }
+ }
+ if (!found) {
+ fail(" Category not found afer tasklist read");
+ }
+
+ manager.saveTaskList();
+ assertNotNull(manager.getTaskList());
+ manager.resetTaskList();
+ manager.readExistingOrCreateNewList();
+
+ // read again
+ readCats = manager.getTaskList().getTaskCategories();
+ assertTrue(manager.getTaskList().getCategories().contains(cat1));
+
+ iterator = readCats.iterator();
+ found = false;
+ while (iterator.hasNext()) {
+ ITaskContainer readCat1 = iterator.next();
+ if (cat1.equals(readCat1)) {
+ found = true;
+ assertEquals(1, readCat1.getChildren().size());
+ }
+ }
+ if (!found) {
+ fail(" Category not found afer tasklist read");
+ }
+ }
+
+ public void testSubTaskExternalization() {
+ Set<AbstractTask> rootTasks = new HashSet<AbstractTask>();
+ AbstractTask task1 = new LocalTask("1", "task1");
+ manager.getTaskList().addTask(task1);
+ rootTasks.add(task1);
+
+ AbstractTask sub2 = new LocalTask("2", "sub 2");
+ manager.getTaskList().addTask(sub2, task1);
+ assertEquals(1, task1.getChildren().size());
+ assertTrue(rootTasks.containsAll(manager.getTaskList().getDefaultCategory().getChildren()));
+
+ manager.saveTaskList();
+ assertNotNull(manager.getTaskList());
+ manager.resetTaskList();
+ manager.readExistingOrCreateNewList();
+
+ assertNotNull(manager.getTaskList());
+
+ // XXX: This should pass once sub tasks are handled properly
+// assertTrue(rootTasks.containsAll(manager.getTaskList().getOrphanContainer(
+// LocalRepositoryConnector.REPOSITORY_URL).getChildren()));
+
+ Collection<ITask> readList = manager.getTaskList().getDefaultCategory().getChildren();
+ for (ITask task : readList) {
+ if (task.equals(task1)) {
+ assertEquals(task1.getSummary(), task.getSummary());
+ assertEquals(1, ((ITaskContainer) task).getChildren().size());
+ }
+ }
+ }
+
+ public void testCreationAndExternalization() throws CoreException {
+ Set<AbstractTask> rootTasks = new HashSet<AbstractTask>();
+ AbstractTask task1 = TasksUiInternal.createNewLocalTask("task 1");
+ rootTasks.add(task1);
+ assertEquals(1, manager.getTaskList().getAllTasks().size());
+
+ AbstractTask sub1 = TasksUiInternal.createNewLocalTask("sub 1");
+ manager.getTaskList().addTask(sub1, task1);
+ assertEquals(4, manager.getTaskList().getRootElements().size());
+
+ //manager.getTaskList().moveToContainer(sub1, manager.getTaskList().getArchiveContainer());
+
+ AbstractTask task2 = TasksUiInternal.createNewLocalTask("task 2");
+ rootTasks.add(task2);
+ assertEquals(3, manager.getTaskList().getAllTasks().size());
+
+ Set<TaskCategory> categories = new HashSet<TaskCategory>();
+ Set<AbstractTask> cat1Contents = new HashSet<AbstractTask>();
+ TaskCategory cat1 = new TaskCategory("Category 1");
+ manager.getTaskList().addCategory(cat1);
+ categories.add(cat1);
+ assertEquals(5, manager.getTaskList().getRootElements().size());
+
+ AbstractTask task3 = TasksUiInternal.createNewLocalTask("task 3");
+ manager.getTaskList().addTask(task3, cat1);
+ cat1Contents.add(task3);
+ assertEquals(4, manager.getTaskList().getAllTasks().size());
+ assertEquals(cat1, TaskCategory.getParentTaskCategory(task3));
+ AbstractTask sub2 = TasksUiInternal.createNewLocalTask("sub 2");
+ assertEquals(5, manager.getTaskList().getAllTasks().size());
+ manager.getTaskList().addTask(sub2, task3);
+ //manager.getTaskList().moveToContainer(sub2, manager.getTaskList().getArchiveContainer());
+
+ AbstractTask task4 = TasksUiInternal.createNewLocalTask("task 4");
+ manager.getTaskList().addTask(task4, cat1);
+ cat1Contents.add(task4);
+ assertEquals(6, manager.getTaskList().getAllTasks().size());
+
+ MockTask reportInCat1 = new MockTask("123");
+ manager.getTaskList().addTask(reportInCat1, cat1);
+ assertEquals(cat1, TaskCategory.getParentTaskCategory(reportInCat1));
+ cat1Contents.add(reportInCat1);
+ assertEquals(7, manager.getTaskList().getAllTasks().size());
+
+ assertEquals(5, manager.getTaskList().getRootElements().size());
+
+ TasksUiPlugin.getExternalizationManager().requestSave();
+ TasksUiPlugin.getDefault().reloadDataDirectory();
+
+ Collection<ITask> readList = manager.getTaskList().getDefaultCategory().getChildren();
+ for (ITask task : readList) {
+ if (task.equals(task1)) {
+ assertEquals(task1.getSummary(), task.getSummary());
+ assertEquals(1, ((AbstractTaskContainer) task).getChildren().size());
+ }
+ }
+
+ Set<AbstractTaskCategory> readCats = manager.getTaskList().getTaskCategories();
+ assertTrue(manager.getTaskList().getCategories().contains(cat1));
+ Iterator<AbstractTaskCategory> iterator = readCats.iterator();
+ boolean found = false;
+ while (iterator.hasNext()) {
+ ITaskContainer readCat1 = iterator.next();
+ if (cat1.equals(readCat1)) {
+ found = true;
+ for (ITask task : readCat1.getChildren()) {
+ assertTrue(cat1Contents.contains(task));
+ }
+ }
+ }
+ if (!found) {
+ fail(" Category not found afer tasklist read");
+ }
+ }
+
+ public void testExternalizationOfHandlesWithDash() throws CoreException {
+ AbstractTask task1 = TasksUiInternal.createNewLocalTask("task 1");
+ manager.getTaskList().addTask(task1, manager.getTaskList().getDefaultCategory());
+
+ TasksUiPlugin.getExternalizationManager().requestSave();
+ TasksUiPlugin.getDefault().reloadDataDirectory();
+ assertTrue(manager.getTaskList().getDefaultCategory().getChildren().contains(task1));
+ }
+
+ public void testgetQueriesAndHitsForHandle() {
+ TaskList taskList = manager.getTaskList();
+
+ MockTask hit1 = new MockTask("1");
+ MockTask hit2 = new MockTask("2");
+ MockTask hit3 = new MockTask("3");
+
+ MockTask hit1twin = new MockTask("1");
+ MockTask hit2twin = new MockTask("2");
+ MockTask hit3twin = new MockTask("3");
+
+ MockRepositoryQuery query1 = new MockRepositoryQuery("query1");
+ MockRepositoryQuery query2 = new MockRepositoryQuery("query2");
+
+ taskList.addQuery(query1);
+ taskList.addQuery(query2);
+ taskList.addTask(hit1, query1);
+ taskList.addTask(hit2, query1);
+ taskList.addTask(hit3, query1);
+
+ assertEquals(3, query1.getChildren().size());
+
+ taskList.addTask(hit1twin, query2);
+ taskList.addTask(hit2twin, query2);
+ taskList.addTask(hit3twin, query2);
+
+ assertEquals(3, query2.getChildren().size());
+
+ Set<AbstractTaskContainer> queriesReturned = hit1.getParentContainers();
+ assertNotNull(queriesReturned);
+ assertEquals(2, queriesReturned.size());
+ assertTrue(queriesReturned.contains(query1));
+ assertTrue(queriesReturned.contains(query2));
+ }
+
+// public void testQueryHitHasParent() {
+// TaskList taskList = manager.getTaskList();
+//
+// MockQueryHit hit1 = new MockQueryHit(taskList,
+// MockRepositoryConnector.REPOSITORY_URL, "description1", "1");
+// assertNull(hit1.getParent());
+// MockRepositoryQuery query1 = new MockRepositoryQuery("query1",
+// manager.getTaskList());
+// query1.addHit(hit1);
+// assertEquals(query1, hit1.getParent());
+//
+// }
+
+ public void testUpdateQueryHits() {
+ ITaskList taskList = manager.getTaskList();
+
+ MockTask hit1 = new MockTask("1");
+ MockTask hit2 = new MockTask("2");
+ MockTask hit3 = new MockTask("3");
+
+ MockTask hit1twin = new MockTask("1");
+ MockTask hit2twin = new MockTask("2");
+ MockTask hit3twin = new MockTask("3");
+
+ MockRepositoryQuery query1 = new MockRepositoryQuery("query1");
+ taskList.addQuery(query1);
+
+ taskList.addTask(hit1, query1);
+ taskList.addTask(hit2, query1);
+ taskList.addTask(hit3, query1);
+
+ taskList.addTask(hit1twin, query1);
+ taskList.addTask(hit2twin, query1);
+ taskList.addTask(hit3twin, query1);
+
+ assertEquals(3, query1.getChildren().size());
+ for (ITask child : query1.getChildren()) {
+ taskList.removeFromContainer(query1, child);
+ }
+ assertEquals(0, query1.getChildren().size());
+ taskList.addTask(hit1, query1);
+ taskList.addTask(hit2, query1);
+ assertEquals(2, query1.getChildren().size());
+ hit1.setNotified(true);
+
+ taskList.addTask(hit1twin, query1);
+ taskList.addTask(hit2twin, query1);
+ taskList.addTask(hit3twin, query1);
+ assertEquals(3, query1.getChildren().size());
+ assertTrue(query1.getChildren().contains(hit1twin));
+ assertTrue(query1.getChildren().contains(hit2twin));
+ assertTrue(query1.getChildren().contains(hit3twin));
+ for (ITask hit : query1.getChildren()) {
+ if (hit.equals(hit1twin)) {
+ assertTrue(((AbstractTask) hit).isNotified());
+ } else {
+ assertFalse(((AbstractTask) hit).isNotified());
+ }
+ }
+ }
+
+ public void testgetRepositoryTasks() {
+
+ String repositoryUrl = "https://bugs.eclipse.org/bugs";
+
+ String bugNumber = "106939";
+
+ MockTask task1 = new MockTask(repositoryUrl, bugNumber);
+ manager.getTaskList().addTask(task1);
+
+ MockTask task2 = new MockTask("https://unresolved", bugNumber);
+ manager.getTaskList().addTask(task2);
+
+ TaskList taskList = manager.getTaskList();
+ assertEquals(2, taskList.getAllTasks().size());
+ Set<ITask> tasksReturned = taskList.getTasks(repositoryUrl);
+ assertNotNull(tasksReturned);
+ assertEquals(1, tasksReturned.size());
+ assertTrue(tasksReturned.contains(task1));
+ }
+
+ public void testAllTasksDeactivation() {
+ AbstractTask task1 = new LocalTask("task1", "description1");
+ AbstractTask task2 = new LocalTask("task2", "description2");
+ TaskList taskList = manager.getTaskList();
+ taskList.addTask(task1);
+ taskList.addTask(task2);
+ assertNull(manager.getActiveTask());
+
+ manager.activateTask(task2);
+ assertEquals(task2, manager.getActiveTask());
+
+ manager.deactivateAllTasks();
+ assertNull(manager.getActiveTask());
+ }
+
+ public void testMarkTaskRead() {
+ // TODO reimplement
+// String repositoryUrl = "http://mylyn.eclipse.org/bugs222";
+// MockTask task1 = new MockTask(repositoryUrl, "1");
+// MockTask task2 = new MockTask(repositoryUrl, "2");
+// task1.setSynchronizationState(SynchronizationState.INCOMING);
+// task2.setSynchronizationState(SynchronizationState.INCOMING);
+// List<ITaskElement> elements = new ArrayList<ITaskElement>();
+// elements.add(task1);
+// elements.add(task2);
+// MarkTaskReadAction readAction = new MarkTaskReadAction(elements);
+// readAction.run();
+// assertEquals(SynchronizationState.SYNCHRONIZED, task1.getSynchronizationState());
+// assertEquals(SynchronizationState.SYNCHRONIZED, task2.getSynchronizationState());
+//
+// manager.getTaskList().reset();
+// MockTask hit1 = new MockTask("1");
+// MockTask hit2 = new MockTask("2");
+// MockRepositoryQuery query = new MockRepositoryQuery("summary");
+// manager.getTaskList().addQuery(query);
+// manager.getTaskList().addTask(hit1, query);
+// manager.getTaskList().addTask(hit2, query);
+//
+// elements.clear();
+// elements.add(query);
+// readAction = new MarkTaskReadAction(elements);
+// readAction.run();
+// assertEquals(2, query.getChildren().size());
+// for (ITaskElement element : query.getChildren()) {
+// if (element instanceof MockTask) {
+// MockTask mockTask = (MockTask) element;
+// assertEquals(SynchronizationState.SYNCHRONIZED, mockTask.getSynchronizationState());
+// }
+// }
+
+ }
+
+ public void testMarkUnRead() {
+ // TODO reimplement
+// String repositoryUrl = "http://mylyn.eclipse.org/bugs222";
+// MockTask task1 = new MockTask(repositoryUrl, "1");
+// MockTask task2 = new MockTask(repositoryUrl, "2");
+// assertEquals(SynchronizationState.SYNCHRONIZED, task1.getSynchronizationState());
+// assertEquals(SynchronizationState.SYNCHRONIZED, task2.getSynchronizationState());
+// List<ITaskElement> elements = new ArrayList<ITaskElement>();
+// elements.add(task1);
+// elements.add(task2);
+// MarkTaskUnreadAction unreadAction = new MarkTaskUnreadAction(elements);
+// unreadAction.run();
+// assertEquals(SynchronizationState.INCOMING, task1.getSynchronizationState());
+// assertEquals(SynchronizationState.INCOMING, task2.getSynchronizationState());
+//
+// manager.getTaskList().reset();
+// MockTask hit1 = new MockTask("1");
+// MockTask hit2 = new MockTask("2");
+// MockRepositoryQuery query = new MockRepositoryQuery("summary");
+// manager.getTaskList().addQuery(query);
+// manager.getTaskList().addTask(hit1, query);
+// manager.getTaskList().addTask(hit2, query);
+//
+// elements.clear();
+// elements.add(query);
+// MarkTaskReadAction readAction = new MarkTaskReadAction(elements);
+// readAction.run();
+// assertEquals(2, query.getChildren().size());
+// for (ITaskElement element : query.getChildren()) {
+// if (element instanceof MockTask) {
+// MockTask mockTask = (MockTask) element;
+// assertEquals(SynchronizationState.SYNCHRONIZED, mockTask.getSynchronizationState());
+// } else {
+// fail();
+// }
+// }
+//
+// unreadAction = new MarkTaskUnreadAction(elements);
+// unreadAction.run();
+// assertEquals(2, query.getChildren().size());
+// for (ITaskElement element : query.getChildren()) {
+// if (element instanceof MockTask) {
+// MockTask mockTask = (MockTask) element;
+// assertEquals(SynchronizationState.INCOMING, mockTask.getSynchronizationState());
+// } else {
+// fail();
+// }
+// }
+ }
+
+ public void testQueryHitsNotDropped() {
+ MockTask task1 = new MockTask("1");
+ MockTask task2 = new MockTask("2");
+ task1.setLastReadTimeStamp("today");
+ task2.setLastReadTimeStamp("today");
+ MockRepositoryQuery query = new MockRepositoryQuery("summary");
+ manager.getTaskList().addQuery(query);
+ manager.getTaskList().addTask(task1, query);
+ manager.getTaskList().addTask(task2, query);
+ //assertEquals(0, manager.getTaskList().getArchiveContainer().getChildren().size());
+ assertEquals(2, query.getChildren().size());
+ TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
+ MockRepositoryConnector.REPOSITORY_URL);
+ Set<RepositoryQuery> queries = new HashSet<RepositoryQuery>();
+ queries.add(query);
+ TasksUiInternal.synchronizeQueries(new MockRepositoryConnector(), repository, queries, null, true);
+ //assertEquals(2, manager.getTaskList().getArchiveContainer().getChildren().size());
+ assertEquals(0, query.getChildren().size());
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java
new file mode 100644
index 000000000..776ab6a81
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.connector;
+
+import java.util.Date;
+
+import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractAttributeFactory;
+
+/**
+ * @author Rob Elves
+ */
+public class MockAttributeFactory extends AbstractAttributeFactory {
+
+ private static final long serialVersionUID = 7713746838934802731L;
+
+ @Override
+ public boolean isHidden(String key) {
+ // ignore
+ return false;
+ }
+
+ @Override
+ public String getName(String key) {
+ // ignore
+ return key;
+ }
+
+ @Override
+ public boolean isReadOnly(String key) {
+ // ignore
+ return false;
+ }
+
+ @Override
+ public String mapCommonAttributeKey(String key) {
+ return key;
+ }
+
+ @Override
+ public Date getDateForAttributeType(String attributeKey, String dateString) {
+ // ignore
+ return null;
+ }
+
+}

Back to the top