use of org.jdom.Element in project intellij-community by JetBrains.
the class TaskManagerTest method testSharedServers.
public void testSharedServers() throws Exception {
TaskRepository repository = new YouTrackRepository(new YouTrackRepositoryType());
repository.setShared(true);
myTaskManager.setRepositories(Collections.singletonList(repository));
TaskProjectConfiguration configuration = ServiceManager.getService(getProject(), TaskProjectConfiguration.class);
TaskProjectConfiguration state = configuration.getState();
assertNotNull(state);
assertEquals(1, state.servers.size());
Element element = XmlSerializer.serialize(state);
configuration.servers.clear();
myTaskManager.setRepositories(Collections.emptyList());
configuration.loadState(XmlSerializer.deserialize(element, TaskProjectConfiguration.class));
assertEquals(1, state.servers.size());
myTaskManager.projectOpened();
TaskRepository[] repositories = myTaskManager.getAllRepositories();
assertEquals(1, repositories.length);
assertTrue(repositories[0].isShared());
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class PivotalTrackerRepository method setTaskState.
@Override
public void setTaskState(@NotNull Task task, @NotNull TaskState state) throws Exception {
final String realId = getRealId(task.getId());
if (realId == null)
return;
final String stateName;
switch(state) {
case IN_PROGRESS:
stateName = "started";
break;
case RESOLVED:
stateName = "finished";
break;
// may add some others in future
default:
return;
}
String url = API_URL + "/projects/" + myProjectId + "/stories/" + realId;
url += "?" + encodeUrl("story[current_state]") + "=" + encodeUrl(stateName);
LOG.info("Updating issue state by id: " + url);
final HttpMethod method = doREST(url, HTTPMethod.PUT);
final InputStream stream = method.getResponseBodyAsStream();
final Element element = new SAXBuilder(false).build(stream).getRootElement();
if (!element.getName().equals("story")) {
if (element.getName().equals("errors")) {
throw new Exception(extractErrorMessage(element));
} else {
// unknown error, probably our fault
LOG.warn("Error setting state for: " + url + ", HTTP status code: " + method.getStatusCode());
throw new Exception(String.format("Cannot set state '%s' for issue.", stateName));
}
}
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class YouTrackIntegrationTest method checkSpentTime.
private void checkSpentTime(@NotNull HttpClient client, @NotNull String issueId, @NotNull String expectedTime) throws IOException, JDOMException {
// Endpoint /rest/issue/BTYT4TT-8/timetracking/workitem/ doesn't work on this instance of YouTrack for some reason
final GetMethod method = new GetMethod(myRepository.getUrl() + "/rest/issue/" + issueId);
final int statusCode = client.executeMethod(method);
assertEquals(HttpStatus.SC_OK, statusCode);
final Element root = JDOMUtil.load(method.getResponseBodyAsStream());
for (Element field : root.getChildren("field")) {
if ("Spent time".equals(field.getAttributeValue("name"))) {
final Element value = field.getChild("value");
assertNotNull(value);
assertEquals(expectedTime, value.getText().trim());
return;
}
}
fail("Field 'Spent time' not found in issue " + issueId);
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class EditorsContextTest method testDockableContainer.
public void testDockableContainer() throws Exception {
VirtualFile file = getFile("/foo.txt");
myManager.openFile(file, false);
DockManager dockManager = DockManager.getInstance(getProject());
assertEquals(1, dockManager.getContainers().size());
myManager.initDockableContentFactory();
myManager.openFileInNewWindow(file);
assertEquals(2, dockManager.getContainers().size());
Element context = new Element("context");
WorkingContextManager contextManager = WorkingContextManager.getInstance(getProject());
contextManager.saveContext(context);
assertEquals(2, context.getChild("editors").getChildren().size());
assertEquals(2, EditorFactory.getInstance().getAllEditors().length);
contextManager.clearContext();
assertEquals(1, dockManager.getContainers().size());
assertEquals(0, EditorFactory.getInstance().getAllEditors().length);
//contextManager.loadContext(context);
//assertEquals(2, dockManager.getContainers().size());
//Editor[] editors = EditorFactory.getInstance().getAllEditors();
//assertEquals(2, editors.length);
//
//contextManager.clearContext();
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class XPathProjectComponent method getState.
public Element getState() {
Element element = new Element("xpathview");
writeHistory(element, HISTORY, history);
writeHistory(element, FIND_HISTORY, findHistory);
return element;
}
Aggregations