IDEA-87409 Issue tracker settings - {number} placeholder doesn't work properly

This commit is contained in:
Dmitry Avdeev
2012-08-27 13:30:59 +04:00
parent 967db7fece
commit 6e2cbdd81d
2 changed files with 35 additions and 4 deletions
@@ -107,13 +107,13 @@ public abstract class Task {
@Nullable
public String getNumber() {
String[] split = getId().split("\\-");
return split.length > 1 ? split[1] : null;
int i = getId().lastIndexOf('-');
return i > 0 ? getId().substring(i + 1) : getId();
}
@Nullable
public String getProject() {
String[] split = getId().split("\\-");
return split.length > 1 ? split[0] : null;
int i = getId().lastIndexOf('-');
return i > 0 ? getId().substring(0, i) : null;
}
}
@@ -89,6 +89,37 @@ public class TaskVcsTest extends TaskManagerTestCase {
assertNotNull(associatedTask); // association should survive
}
public void testProjectWithDash() throws Exception {
LocalTaskImpl task = new LocalTaskImpl("foo-bar-001", "summary") {
@Override
public TaskRepository getRepository() {
return myRepository;
}
};
assertEquals("foo-bar", task.getProject());
assertEquals("001", task.getNumber());
String name = myManager.getChangelistName(task);
assertEquals("foo-bar-001 summary", name);
}
public void testIds() throws Exception {
LocalTaskImpl task = new LocalTaskImpl("", "");
assertEquals("", task.getNumber());
assertEquals(null, task.getProject());
task = new LocalTaskImpl("-", "");
assertEquals("-", task.getNumber());
assertEquals(null, task.getProject());
task = new LocalTaskImpl("foo", "");
assertEquals("foo", task.getNumber());
assertEquals(null, task.getProject());
task = new LocalTaskImpl("112", "");
assertEquals("112", task.getNumber());
assertEquals(null, task.getProject());
}
private void createChangelist(LocalTask localTask) throws InterruptedException {
clearChangeLists();
if (localTask.isActive()) {