IDEA-105413 Update Mantis integration tests

This commit is contained in:
Mikhail Golubev
2014-03-20 20:42:39 +04:00
parent 01c054dfe3
commit f6a41efe0c
3 changed files with 49 additions and 32 deletions
@@ -14,6 +14,7 @@ import com.intellij.util.NullableFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.VersionComparatorUtil;
import com.intellij.util.xmlb.annotations.Tag;
import org.apache.axis.AxisFault;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -87,14 +88,13 @@ public class MantisRepository extends BaseRepositoryImpl {
ensureProjectsRefreshed();
MantisConnectPortType soap = createSoap();
int total = limit - offset + 1;
List<Task> tasks = new ArrayList<Task>(total);
List<Task> tasks = new ArrayList<Task>(limit);
int pageNumber = offset / PAGE_SIZE + 1;
// what the heck does it suppose to mean?
while (tasks.size() < total) {
while (tasks.size() < limit) {
cancelled.checkCanceled();
int pageSize = Math.min(PAGE_SIZE, total - tasks.size());
int pageSize = Math.min(PAGE_SIZE, limit - tasks.size());
List<Task> issuesFromPage = getIssuesFromPage(soap, pageNumber, pageSize);
tasks.addAll(issuesFromPage);
if (issuesFromPage.size() < pageSize) {
@@ -148,8 +148,12 @@ public class MantisRepository extends BaseRepositoryImpl {
return new CancellableConnection() {
@Override
protected void doTest() throws Exception {
//refreshProjects();
createSoap();
try {
createSoap().mc_enum_access_levels(getUsername(), getPassword());
}
catch (AxisFault e) {
throw new Exception(TaskBundle.message("failure.server.message", e.getMessage()));
}
}
@Override
@@ -171,7 +175,7 @@ public class MantisRepository extends BaseRepositoryImpl {
if (data.getId() == null || data.getSummary() == null) {
return null;
}
return new MantisTask(data, this);
return new MantisTask(data, myCurrentProject, this);
}
@NotNull
@@ -31,8 +31,9 @@ public class MantisTask extends Task {
myRepository = repository;
myId = String.valueOf(data.getId());
mySummary = data.getSummary();
myClosed = data.getStatus().getId().intValue() >= 90;
myDescription = data.getDescription();
myProjectName = data.getProject() == null ? null : data.getProject().getName();
myClosed = data.getStatus().getId().intValue() >= 90;
myCreated = data.getDate_submitted().getTime();
myUpdated = data.getLast_updated().getTime();
@@ -66,10 +67,13 @@ public class MantisTask extends Task {
}
}
public MantisTask(@NotNull IssueHeaderData header, @NotNull MantisRepository repository) {
public MantisTask(@NotNull IssueHeaderData header, @Nullable MantisProject project, @NotNull MantisRepository repository) {
myRepository = repository;
myId = String.valueOf(header.getId());
mySummary = header.getSummary();
// actually it's not necessary because on activation tasks updated by TaskRepository#findTask
// and in this case constructor from IssueData will be used
myProjectName = project == null || project.isUnspecified() ? null : project.getName();
myClosed = header.getStatus().intValue() >= 90;
myDescription = null; // unavailable from header
myCreated = null; // unavailable from header
@@ -92,13 +96,13 @@ public class MantisTask extends Task {
@Nullable
@Override
public String getDescription() {
return null;
return myDescription;
}
@NotNull
@Override
public Comment[] getComments() {
return Comment.EMPTY_ARRAY;
return myComments;
}
@NotNull
@@ -122,7 +126,7 @@ public class MantisTask extends Task {
@Nullable
@Override
public Date getCreated() {
return null;
return myCreated;
}
@Override
@@ -1,5 +1,6 @@
package com.intellij.tasks.integration;
import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.tasks.Task;
import com.intellij.tasks.TaskManagerTestCase;
import com.intellij.tasks.mantis.MantisFilter;
@@ -14,16 +15,15 @@ import org.apache.commons.httpclient.methods.GetMethod;
* Date: 10/12/12
*/
public class MantisIntegrationTest extends TaskManagerTestCase {
public void testMantis12() throws Exception {
MantisRepository mantisRepository = new MantisRepository(new MantisRepositoryType());
mantisRepository.setUrl("http://trackers-tests.labs.intellij.net:8142/");
mantisRepository.setUsername("deva");
mantisRepository.setPassword("deva");
public static final String MANTIS_1_2_11_TEST_SERVER_URL = "http://trackers-tests.labs.intellij.net:8142/";
assertTrue(mantisRepository.getProjects().size() >= 2);
final MantisProject mantisProject = mantisRepository.getProjects().get(1);
private MantisRepository myRepository;
public void testMantis12() throws Exception {
assertTrue(myRepository.getProjects().size() >= 2);
final MantisProject mantisProject = myRepository.getProjects().get(1);
assertEquals(mantisProject.getName(), "Mantis 1.2 project 1");
mantisRepository.setCurrentProject(mantisProject);
myRepository.setCurrentProject(mantisProject);
assertTrue(mantisProject.getFilters().size() >= 2);
MantisFilter mantisFilter = null;
@@ -33,27 +33,36 @@ public class MantisIntegrationTest extends TaskManagerTestCase {
}
}
assertNotNull(mantisFilter);
mantisRepository.setCurrentFilter(mantisFilter);
myRepository.setCurrentFilter(mantisFilter);
final Task[] issues = mantisRepository.getIssues("", 1, 0);
final Task[] issues = myRepository.getIssues("", 0, 1, true, new EmptyProgressIndicator());
assertTrue(issues.length >= 1);
final Task task = issues[0];
assertEquals(task.getId(), "1");
assertEquals(task.getProject(), "Mantis 1.2 project 1");
assertEquals(task.getNumber(), "1");
assertEquals(task.getSummary(), "M12P1I1");
assertEquals("1", task.getId());
assertEquals("Mantis 1.2 project 1", task.getProject());
assertEquals("1", task.getNumber());
assertEquals("M12P1I1", task.getSummary());
final Task task1 = mantisRepository.findTask("1");
final Task task1 = myRepository.findTask("1");
assertNotNull(task1);
assertEquals(task1.getId(), "1");
assertEquals(task1.getProject(), "Mantis 1.2 project 1");
assertEquals(task1.getNumber(), "1");
assertEquals(task1.getSummary(), "M12P1I1");
assertEquals(task1.getDescription(), ".");
assertEquals("1", task1.getId());
assertEquals("Mantis 1.2 project 1", task1.getProject());
assertEquals("1", task1.getNumber());
assertEquals("M12P1I1", task1.getSummary());
assertEquals(".", task1.getDescription());
HttpClient client = new HttpClient();
final GetMethod method = new GetMethod(task1.getIssueUrl());
client.executeMethod(method);
assertEquals(method.getStatusCode(), 200);
}
@Override
public void setUp() throws Exception {
super.setUp();
myRepository = new MantisRepository(new MantisRepositoryType());
myRepository.setUrl(MANTIS_1_2_11_TEST_SERVER_URL);
myRepository.setUsername("deva");
myRepository.setPassword("deva");
}
}