From 1f5ac8df6f0b33716b3a1d18a0dddd3e382348eb Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Tue, 3 Jul 2012 14:37:47 +0000 Subject: [PATCH] Fixed problem with double query encoding by URLBuilder. --- src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java | 10 ++-------- src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java | 4 ++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java b/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java index 3596c03..59e2494 100644 --- a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java +++ b/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java @@ -266,14 +266,8 @@ public class YoutrackAPI { public List searchIssuesByProject(String project, Object filter) throws JAXBException, IOException { - final URI uri; - try { - uri = new URIBuilder(serviceLocation + "/rest/issue/byproject/" + project).addParameter("filter", filter == null ? null : filter.toString()) - .build(); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - final Object result = YoutrackUnmarshaller.unmarshall(execute(new HttpGet(uri))); + final String url = serviceLocation + "/rest/issue/byproject/" + project + "?filter=" + (filter == null ? "" : filter); + final Object result = YoutrackUnmarshaller.unmarshall(execute(new HttpGet(url))); if (!(result instanceof Issues)) { throw new YoutrackAPIException("Unmarshalling problem. Expected Issues, received: " + result.getClass() + " " + result); } diff --git a/src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java b/src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java index 1544978..cf0ba77 100644 --- a/src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java +++ b/src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java @@ -5,6 +5,7 @@ import org.apache.http.HttpStatus; import org.apache.http.auth.AuthenticationException; import org.junit.Test; import pl.com.it_crowd.youtrack.api.Command; +import pl.com.it_crowd.youtrack.api.Filter; import pl.com.it_crowd.youtrack.api.IssueWrapper; import pl.com.it_crowd.youtrack.api.YoutrackAPI; import pl.com.it_crowd.youtrack.api.defaults.Fields; @@ -162,6 +163,9 @@ public class YoutrackAPITest { Assert.assertNotNull(summary); Assert.assertTrue(!"".equals(summary.trim())); } + api.createIssue("TST", "searchIssuesByProject " + System.currentTimeMillis(), "searchIssuesByProject"); + issues = api.searchIssuesByProject("TST", Filter.stateFilter(StateValues.Unresolved)); + Assert.assertTrue(!issues.isEmpty()); } private String getPassword() -- libgit2 0.24.0