Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2010-03-03 16:32:08 -0500
committerfbecker2010-03-03 16:32:08 -0500
commit86a87382ef88d402f08ce2ed9454a2c7280ab5bd (patch)
treeb857af13f998834d9dcaeff4682c8b8a29dd87b4 /org.eclipse.mylyn.bugzilla.tests
parent751da41a8942179496277d286f351c48e031a477 (diff)
downloadorg.eclipse.mylyn.tasks-86a87382ef88d402f08ce2ed9454a2c7280ab5bd.tar.gz
org.eclipse.mylyn.tasks-86a87382ef88d402f08ce2ed9454a2c7280ab5bd.tar.xz
org.eclipse.mylyn.tasks-86a87382ef88d402f08ce2ed9454a2c7280ab5bd.zip
ASSIGNED - bug 164221: Recognize comment#number link on bug editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=164221 Cleanup and add some more junit tests.
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java107
1 files changed, 91 insertions, 16 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java
index 918237e3d..49a2c83dd 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java
@@ -94,6 +94,22 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
private final String BUG_FORMAT_4_COMMENT_2 = "bug #1 comment #44556677";
+ private final String TASK_FORMAT_1_COMMENT_3 = "task#123 comment#44556677";
+
+ private final String TASK_FORMAT_2_COMMENT_3 = "task# 1 comment#44556677";
+
+ private final String TASK_FORMAT_3_COMMENT_3 = "task1 comment#44556677";
+
+ private final String TASK_FORMAT_4_COMMENT_3 = "task #1 comment#44556677";
+
+ private final String BUG_FORMAT_1_COMMENT_3 = "bug# 1 comment#44556677";
+
+ private final String BUG_FORMAT_2_COMMENT_3 = "bug # 1 comment#44556677";
+
+ private final String BUG_FORMAT_3_COMMENT_3 = "bug1 comment#44556677";
+
+ private final String BUG_FORMAT_4_COMMENT_3 = "bug #1 comment#44556677";
+
//private BugzillaTaskHyperlinkDetector detector = new BugzillaTaskHyperlinkDetector();
private TaskHyperlinkDetector detector;
@@ -142,7 +158,9 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
TASK_FORMAT_4_COMMENT_1, BUG_FORMAT_1_COMMENT_1, BUG_FORMAT_2_COMMENT_1, BUG_FORMAT_3_COMMENT_1,
BUG_FORMAT_4_COMMENT_1, TASK_FORMAT_1_COMMENT_2, TASK_FORMAT_2_COMMENT_2, TASK_FORMAT_3_COMMENT_2,
TASK_FORMAT_4_COMMENT_2, BUG_FORMAT_1_COMMENT_2, BUG_FORMAT_2_COMMENT_2, BUG_FORMAT_3_COMMENT_2,
- BUG_FORMAT_4_COMMENT_2 };
+ BUG_FORMAT_4_COMMENT_2, TASK_FORMAT_1_COMMENT_3, TASK_FORMAT_2_COMMENT_3, TASK_FORMAT_3_COMMENT_3,
+ TASK_FORMAT_4_COMMENT_3, BUG_FORMAT_1_COMMENT_3, BUG_FORMAT_2_COMMENT_3, BUG_FORMAT_3_COMMENT_3,
+ BUG_FORMAT_4_COMMENT_3 };
}
private void setRepository(final TaskRepository repository) {
@@ -171,6 +189,18 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
Object comment = ((TaskHyperlink) links[0]).getSelection();
assertNull(comment);
}
+ for (String format : commentFormats) {
+ String testString = "First line\n:" + format + " is at the beginning";
+ viewer.setDocument(new Document(testString));
+ Region region = new Region(0, testString.length());
+ IHyperlink[] links = detector.detectHyperlinks(viewer, region, false);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset());
+ Object comment = ((TaskHyperlink) links[0]).getSelection();
+ assertNotNull(comment);
+ assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment);
+ }
}
public void testBeginningOfSecondLine() {
@@ -185,6 +215,18 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
Object comment = ((TaskHyperlink) links[0]).getSelection();
assertNull(comment);
}
+ for (String format : commentFormats) {
+ String testString = "First line\n" + format + " is at the beginning";
+ viewer.setDocument(new Document(testString));
+ Region region = new Region(0, testString.length());
+ IHyperlink[] links = detector.detectHyperlinks(viewer, region, false);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset());
+ Object comment = ((TaskHyperlink) links[0]).getSelection();
+ assertNotNull(comment);
+ assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment);
+ }
}
public void testBeginningOfSecondLineWithisWhitespace() {
@@ -199,6 +241,18 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
Object comment = ((TaskHyperlink) links[0]).getSelection();
assertNull(comment);
}
+ for (String format : commentFormats) {
+ String testString = "First line\n \t " + format + " is at the beginning";
+ viewer.setDocument(new Document(testString));
+ Region region = new Region(0, testString.length());
+ IHyperlink[] links = detector.detectHyperlinks(viewer, region, false);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset());
+ Object comment = ((TaskHyperlink) links[0]).getSelection();
+ assertNotNull(comment);
+ assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment);
+ }
}
public void testBeginning() {
@@ -213,6 +267,18 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
Object comment = ((TaskHyperlink) links[0]).getSelection();
assertNull(comment);
}
+ for (String format : commentFormats) {
+ String testString = format + " is at the beginning";
+ viewer.setDocument(new Document(testString));
+ Region region = new Region(0, testString.length());
+ IHyperlink[] links = detector.detectHyperlinks(viewer, region, false);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset());
+ Object comment = ((TaskHyperlink) links[0]).getSelection();
+ assertNotNull(comment);
+ assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment);
+ }
}
public void testEnd() {
@@ -228,6 +294,18 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
Object comment = ((TaskHyperlink) links[0]).getSelection();
assertNull(comment);
}
+ for (String format : commentFormats) {
+ String testString = "is ends with " + format;
+ viewer.setDocument(new Document(testString));
+ Region region = new Region(0, testString.length());
+ IHyperlink[] links = detector.detectHyperlinks(viewer, region, false);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset());
+ Object comment = ((TaskHyperlink) links[0]).getSelection();
+ assertNotNull(comment);
+ assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment);
+ }
}
public void testMiddle() {
@@ -243,6 +321,18 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
Object comment = ((TaskHyperlink) links[0]).getSelection();
assertNull(comment);
}
+ for (String format : commentFormats) {
+ String testString = "is a " + format + " in the middle";
+ viewer.setDocument(new Document(testString));
+ Region region = new Region(0, testString.length());
+ IHyperlink[] links = detector.detectHyperlinks(viewer, region, false);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset());
+ Object comment = ((TaskHyperlink) links[0]).getSelection();
+ assertNotNull(comment);
+ assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment);
+ }
}
public void testTwoOnSingleLine() {
@@ -401,19 +491,4 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
assertEquals(1, links.length);
assertEquals(testString.indexOf(ATTACHMENT_NUMBER), links[0].getHyperlinkRegion().getOffset());
}
-
- public void testBugWithComment() {
- for (String format : commentFormats) {
- String testString = "First line\n:" + format + " is at the beginning";
- viewer.setDocument(new Document(testString));
- Region region = new Region(0, testString.length());
- IHyperlink[] links = detector.detectHyperlinks(viewer, region, false);
- assertNotNull(links);
- assertEquals(1, links.length);
- assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset());
- Object comment = ((TaskHyperlink) links[0]).getSelection();
- assertNotNull(comment);
- assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment);
- }
- }
}

Back to the top