Commit 1f5ac8df6f0b33716b3a1d18a0dddd3e382348eb

Authored by bernard
1 parent 1f0624db

Fixed problem with double query encoding by URLBuilder.

@@ -266,14 +266,8 @@ public class YoutrackAPI { @@ -266,14 +266,8 @@ public class YoutrackAPI {
266 266
267 public List<IssueWrapper> searchIssuesByProject(String project, Object filter) throws JAXBException, IOException 267 public List<IssueWrapper> searchIssuesByProject(String project, Object filter) throws JAXBException, IOException
268 { 268 {
269 - final URI uri;  
270 - try {  
271 - uri = new URIBuilder(serviceLocation + "/rest/issue/byproject/" + project).addParameter("filter", filter == null ? null : filter.toString())  
272 - .build();  
273 - } catch (URISyntaxException e) {  
274 - throw new RuntimeException(e);  
275 - }  
276 - final Object result = YoutrackUnmarshaller.unmarshall(execute(new HttpGet(uri))); 269 + final String url = serviceLocation + "/rest/issue/byproject/" + project + "?filter=" + (filter == null ? "" : filter);
  270 + final Object result = YoutrackUnmarshaller.unmarshall(execute(new HttpGet(url)));
277 if (!(result instanceof Issues)) { 271 if (!(result instanceof Issues)) {
278 throw new YoutrackAPIException("Unmarshalling problem. Expected Issues, received: " + result.getClass() + " " + result); 272 throw new YoutrackAPIException("Unmarshalling problem. Expected Issues, received: " + result.getClass() + " " + result);
279 } 273 }
@@ -5,6 +5,7 @@ import org.apache.http.HttpStatus; @@ -5,6 +5,7 @@ import org.apache.http.HttpStatus;
5 import org.apache.http.auth.AuthenticationException; 5 import org.apache.http.auth.AuthenticationException;
6 import org.junit.Test; 6 import org.junit.Test;
7 import pl.com.it_crowd.youtrack.api.Command; 7 import pl.com.it_crowd.youtrack.api.Command;
  8 +import pl.com.it_crowd.youtrack.api.Filter;
8 import pl.com.it_crowd.youtrack.api.IssueWrapper; 9 import pl.com.it_crowd.youtrack.api.IssueWrapper;
9 import pl.com.it_crowd.youtrack.api.YoutrackAPI; 10 import pl.com.it_crowd.youtrack.api.YoutrackAPI;
10 import pl.com.it_crowd.youtrack.api.defaults.Fields; 11 import pl.com.it_crowd.youtrack.api.defaults.Fields;
@@ -162,6 +163,9 @@ public class YoutrackAPITest { @@ -162,6 +163,9 @@ public class YoutrackAPITest {
162 Assert.assertNotNull(summary); 163 Assert.assertNotNull(summary);
163 Assert.assertTrue(!"".equals(summary.trim())); 164 Assert.assertTrue(!"".equals(summary.trim()));
164 } 165 }
  166 + api.createIssue("TST", "searchIssuesByProject " + System.currentTimeMillis(), "searchIssuesByProject");
  167 + issues = api.searchIssuesByProject("TST", Filter.stateFilter(StateValues.Unresolved));
  168 + Assert.assertTrue(!issues.isEmpty());
165 } 169 }
166 170
167 private String getPassword() 171 private String getPassword()
Please register or login to post a comment