From 2b455d82adc3e32c401f4494a18ad8df2f573bdf Mon Sep 17 00:00:00 2001
From: Bernard Labno <bernard.labno@itcrowd.pl>
Date: Sat, 17 Dec 2011 14:55:36 +0000
Subject: [PATCH] Code reformat.

---
 src/main/java/pl/com/it_crowd/youtrack/api/Issue.java                |  15 +++++++++++----
 src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java          |  86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java          | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------
 src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java   |  44 +++++++++++++++++++++++++-------------------
 src/main/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPI.java     |  82 ----------------------------------------------------------------------------------
 src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java |  16 +++++++++++-----
 6 files changed, 234 insertions(+), 179 deletions(-)
 create mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java
 delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPI.java

diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/Issue.java b/src/main/java/pl/com/it_crowd/youtrack/api/Issue.java
index f60862f..f90bb35 100644
--- a/src/main/java/pl/com/it_crowd/youtrack/api/Issue.java
+++ b/src/main/java/pl/com/it_crowd/youtrack/api/Issue.java
@@ -14,14 +14,17 @@ public class Issue implements Serializable {
 // ------------------------------ FIELDS ------------------------------
 
     private static final Log log = LogFactory.getLog(Issue.class);
+
     private List<Issues.Issue.Comment> comments;
+
     private Map<String, Issues.Issue.Field> fieldMap;
 
     private Issues.Issue issue;
 
 // --------------------------- CONSTRUCTORS ---------------------------
 
-    public Issue(Issues.Issue issue) {
+    public Issue(Issues.Issue issue)
+    {
         this.issue = issue;
         fieldMap = new HashMap<String, Issues.Issue.Field>();
         comments = new ArrayList<Issues.Issue.Comment>();
@@ -39,11 +42,13 @@ public class Issue implements Serializable {
 
 // -------------------------- OTHER METHODS --------------------------
 
-    public Issues.Issue.Field getField(String field) {
+    public Issues.Issue.Field getField(String field)
+    {
         return fieldMap.get(field);
     }
 
-    public String getFieldValue(String fieldName) {
+    public String getFieldValue(String fieldName)
+    {
         Issues.Issue.Field field = fieldMap.get(fieldName);
         if (field == null) {
             return null;
@@ -52,9 +57,11 @@ public class Issue implements Serializable {
         return values.isEmpty() ? null : values.get(0).getContent();
     }
 
-    public String getFieldValue(Fields fieldName) {
+    public String getFieldValue(Fields fieldName)
+    {
         return getFieldValue(fieldName.name());
     }
+
 // -------------------------- ENUMERATIONS --------------------------
 
     public enum Fields {
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
new file mode 100644
index 0000000..9ef02d5
--- /dev/null
+++ b/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java
@@ -0,0 +1,86 @@
+package pl.com.it_crowd.youtrack.api;
+
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.HttpMethod;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.WebRequest;
+import com.gargoylesoftware.htmlunit.WebResponse;
+import com.gargoylesoftware.htmlunit.html.DomNode;
+import com.gargoylesoftware.htmlunit.util.NameValuePair;
+import com.gargoylesoftware.htmlunit.xml.XmlPage;
+import org.apache.http.auth.AuthenticationException;
+import pl.com.it_crowd.youtrack.api.rest.Issues;
+
+import javax.xml.bind.JAXBException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+public class YoutrackAPI {
+// ------------------------------ FIELDS ------------------------------
+
+    private String serviceLocation;
+
+    private WebClient webClient;
+
+// --------------------------- CONSTRUCTORS ---------------------------
+
+    public YoutrackAPI(String serviceLocation)
+    {
+        this.serviceLocation = serviceLocation;
+        this.webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
+        this.webClient.setJavaScriptEnabled(false);
+        this.webClient.setCssEnabled(false);
+    }
+
+    public YoutrackAPI(String serviceLocation, String username, String password) throws IOException, AuthenticationException
+    {
+        this(serviceLocation);
+        login(username, password);
+    }
+
+// --------------------- GETTER / SETTER METHODS ---------------------
+
+    public String getServiceLocation()
+    {
+        return serviceLocation;
+    }
+
+// -------------------------- OTHER METHODS --------------------------
+
+    public void login(String username, String password) throws IOException, AuthenticationException
+    {
+        ArrayList<NameValuePair> requestParameters = new ArrayList<NameValuePair>();
+        requestParameters.add(new NameValuePair("login", username));
+        requestParameters.add(new NameValuePair("password", password));
+        WebRequest request = new WebRequest(new URL(serviceLocation + "/rest/user/login"), HttpMethod.POST);
+        request.setRequestParameters(requestParameters);
+        try {
+            webClient.getPage(request);
+        } catch (FailingHttpStatusCodeException e) {
+            if (e.getStatusCode() == 403) {
+                DomNode error = ((XmlPage) webClient.getCurrentWindow().getEnclosedPage()).getFirstChild();
+                if (error != null) {
+                    throw new AuthenticationException(error.getTextContent());
+                }
+            }
+            throw e;
+        }
+    }
+
+    public List<Issue> searchIssuesByProject(String project, String filter) throws JAXBException, IOException
+    {
+        String url = serviceLocation + "/rest/issue/byproject/" + project + "?filter=" + filter;
+        WebResponse webResponse = webClient.<Page>getPage(url).getWebResponse();
+//        System.out.println(webResponse.getContentAsString());
+        List<Issues.Issue> issues = IssuesUnmarshaller.unmarshal(webResponse.getContentAsStream()).getIssue();
+        List<Issue> result = new ArrayList<Issue>();
+        for (Issues.Issue issue : issues) {
+            result.add(new Issue(issue));
+        }
+        return result;
+    }
+}
diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java
index 549ee8e..9e02507 100644
--- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java
+++ b/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java
@@ -2,7 +2,7 @@
 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 
 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2011.12.16 at 09:34:48 AM CET 
+// Generated on: 2011.12.16 at 10:06:20 AM CET 
 //
 
 package pl.com.it_crowd.youtrack.api.rest;
@@ -96,9 +96,7 @@ import java.util.List;
  * </pre>
  */
 @XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {
-    "issue"
-})
+@XmlType(name = "", propOrder = {"issue"})
 @XmlRootElement(name = "issues")
 public class Issues {
 
@@ -124,7 +122,8 @@ public class Issues {
      * Objects of the following type(s) are allowed in the list
      * {@link Issues.Issue }
      */
-    public List<Issues.Issue> getIssue() {
+    public List<Issues.Issue> getIssue()
+    {
         if (issue == null) {
             issue = new ArrayList<Issues.Issue>();
         }
@@ -199,16 +198,12 @@ public class Issues {
      * </pre>
      */
     @XmlAccessorType(XmlAccessType.FIELD)
-    @XmlType(name = "", propOrder = {
-        "fieldOrComment"
-    })
+    @XmlType(name = "", propOrder = {"fieldOrComment"})
     public static class Issue {
 
-        @XmlElements({
-            @XmlElement(name = "field", type = Issues.Issue.Field.class),
-            @XmlElement(name = "comment", type = Issues.Issue.Comment.class)
-        })
+        @XmlElements({@XmlElement(name = "field", type = Issues.Issue.Field.class), @XmlElement(name = "comment", type = Issues.Issue.Comment.class)})
         protected List<Object> fieldOrComment;
+
         @XmlAttribute
         protected String id;
 
@@ -233,7 +228,8 @@ public class Issues {
          * {@link Issues.Issue.Field }
          * {@link Issues.Issue.Comment }
          */
-        public List<Object> getFieldOrComment() {
+        public List<Object> getFieldOrComment()
+        {
             if (fieldOrComment == null) {
                 fieldOrComment = new ArrayList<Object>();
             }
@@ -246,7 +242,8 @@ public class Issues {
          * @return possible object is
          *         {@link String }
          */
-        public String getId() {
+        public String getId()
+        {
             return id;
         }
 
@@ -256,7 +253,8 @@ public class Issues {
          * @param value allowed object is
          *              {@link String }
          */
-        public void setId(String value) {
+        public void setId(String value)
+        {
             this.id = value;
         }
 
@@ -296,28 +294,34 @@ public class Issues {
          * </pre>
          */
         @XmlAccessorType(XmlAccessType.FIELD)
-        @XmlType(name = "", propOrder = {
-            "replies",
-            "value"
-        })
+        @XmlType(name = "", propOrder = {"replies", "value"})
         public static class Comment {
 
             protected String replies;
+
             protected Issues.Issue.Comment.Value value;
+
             @XmlAttribute
             protected String id;
+
             @XmlAttribute
             protected String author;
+
             @XmlAttribute
             protected String issueId;
+
             @XmlAttribute
             protected String deleted;
+
             @XmlAttribute
             protected String text;
+
             @XmlAttribute
             protected String shownForIssueAuthor;
+
             @XmlAttribute
             protected String created;
+
             @XmlAttribute
             protected String name;
 
@@ -327,7 +331,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getReplies() {
+            public String getReplies()
+            {
                 return replies;
             }
 
@@ -337,7 +342,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setReplies(String value) {
+            public void setReplies(String value)
+            {
                 this.replies = value;
             }
 
@@ -347,7 +353,8 @@ public class Issues {
              * @return possible object is
              *         {@link Issues.Issue.Comment.Value }
              */
-            public Issues.Issue.Comment.Value getValue() {
+            public Issues.Issue.Comment.Value getValue()
+            {
                 return value;
             }
 
@@ -357,7 +364,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link Issues.Issue.Comment.Value }
              */
-            public void setValue(Issues.Issue.Comment.Value value) {
+            public void setValue(Issues.Issue.Comment.Value value)
+            {
                 this.value = value;
             }
 
@@ -367,7 +375,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getId() {
+            public String getId()
+            {
                 return id;
             }
 
@@ -377,7 +386,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setId(String value) {
+            public void setId(String value)
+            {
                 this.id = value;
             }
 
@@ -387,7 +397,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getAuthor() {
+            public String getAuthor()
+            {
                 return author;
             }
 
@@ -397,7 +408,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setAuthor(String value) {
+            public void setAuthor(String value)
+            {
                 this.author = value;
             }
 
@@ -407,7 +419,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getIssueId() {
+            public String getIssueId()
+            {
                 return issueId;
             }
 
@@ -417,7 +430,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setIssueId(String value) {
+            public void setIssueId(String value)
+            {
                 this.issueId = value;
             }
 
@@ -427,7 +441,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getDeleted() {
+            public String getDeleted()
+            {
                 return deleted;
             }
 
@@ -437,7 +452,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setDeleted(String value) {
+            public void setDeleted(String value)
+            {
                 this.deleted = value;
             }
 
@@ -447,7 +463,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getText() {
+            public String getText()
+            {
                 return text;
             }
 
@@ -457,7 +474,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setText(String value) {
+            public void setText(String value)
+            {
                 this.text = value;
             }
 
@@ -467,7 +485,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getShownForIssueAuthor() {
+            public String getShownForIssueAuthor()
+            {
                 return shownForIssueAuthor;
             }
 
@@ -477,7 +496,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setShownForIssueAuthor(String value) {
+            public void setShownForIssueAuthor(String value)
+            {
                 this.shownForIssueAuthor = value;
             }
 
@@ -487,7 +507,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getCreated() {
+            public String getCreated()
+            {
                 return created;
             }
 
@@ -497,7 +518,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setCreated(String value) {
+            public void setCreated(String value)
+            {
                 this.created = value;
             }
 
@@ -507,7 +529,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getName() {
+            public String getName()
+            {
                 return name;
             }
 
@@ -517,7 +540,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setName(String value) {
+            public void setName(String value)
+            {
                 this.name = value;
             }
 
@@ -538,15 +562,15 @@ public class Issues {
              * </pre>
              */
             @XmlAccessorType(XmlAccessType.FIELD)
-            @XmlType(name = "", propOrder = {
-                "value"
-            })
+            @XmlType(name = "", propOrder = {"value"})
             public static class Value {
 
                 @XmlValue
                 protected String value;
+
                 @XmlAttribute
                 protected String type;
+
                 @XmlAttribute
                 protected String role;
 
@@ -556,7 +580,8 @@ public class Issues {
                  * @return possible object is
                  *         {@link String }
                  */
-                public String getValue() {
+                public String getValue()
+                {
                     return value;
                 }
 
@@ -566,7 +591,8 @@ public class Issues {
                  * @param value allowed object is
                  *              {@link String }
                  */
-                public void setValue(String value) {
+                public void setValue(String value)
+                {
                     this.value = value;
                 }
 
@@ -576,7 +602,8 @@ public class Issues {
                  * @return possible object is
                  *         {@link String }
                  */
-                public String getType() {
+                public String getType()
+                {
                     return type;
                 }
 
@@ -586,7 +613,8 @@ public class Issues {
                  * @param value allowed object is
                  *              {@link String }
                  */
-                public void setType(String value) {
+                public void setType(String value)
+                {
                     this.type = value;
                 }
 
@@ -596,7 +624,8 @@ public class Issues {
                  * @return possible object is
                  *         {@link String }
                  */
-                public String getRole() {
+                public String getRole()
+                {
                     return role;
                 }
 
@@ -606,12 +635,11 @@ public class Issues {
                  * @param value allowed object is
                  *              {@link String }
                  */
-                public void setRole(String value) {
+                public void setRole(String value)
+                {
                     this.role = value;
                 }
-
             }
-
         }
 
         /**
@@ -642,13 +670,12 @@ public class Issues {
          * </pre>
          */
         @XmlAccessorType(XmlAccessType.FIELD)
-        @XmlType(name = "", propOrder = {
-            "values"
-        })
+        @XmlType(name = "", propOrder = {"values"})
         public static class Field {
 
             @XmlElement(name = "value")
             protected List<Issues.Issue.Field.Value> values;
+
             @XmlAttribute
             protected String name;
 
@@ -672,7 +699,8 @@ public class Issues {
              * Objects of the following type(s) are allowed in the list
              * {@link Issues.Issue.Field.Value }
              */
-            public List<Issues.Issue.Field.Value> getValues() {
+            public List<Issues.Issue.Field.Value> getValues()
+            {
                 if (values == null) {
                     values = new ArrayList<Issues.Issue.Field.Value>();
                 }
@@ -685,7 +713,8 @@ public class Issues {
              * @return possible object is
              *         {@link String }
              */
-            public String getName() {
+            public String getName()
+            {
                 return name;
             }
 
@@ -695,7 +724,8 @@ public class Issues {
              * @param value allowed object is
              *              {@link String }
              */
-            public void setName(String value) {
+            public void setName(String value)
+            {
                 this.name = value;
             }
 
@@ -716,15 +746,15 @@ public class Issues {
              * </pre>
              */
             @XmlAccessorType(XmlAccessType.FIELD)
-            @XmlType(name = "", propOrder = {
-                "content"
-            })
+            @XmlType(name = "", propOrder = {"content"})
             public static class Value {
 
                 @XmlValue
                 protected String content;
+
                 @XmlAttribute
                 protected String type;
+
                 @XmlAttribute
                 protected String role;
 
@@ -734,7 +764,8 @@ public class Issues {
                  * @return possible object is
                  *         {@link String }
                  */
-                public String getContent() {
+                public String getContent()
+                {
                     return content;
                 }
 
@@ -744,7 +775,8 @@ public class Issues {
                  * @param value allowed object is
                  *              {@link String }
                  */
-                public void setContent(String value) {
+                public void setContent(String value)
+                {
                     this.content = value;
                 }
 
@@ -754,7 +786,8 @@ public class Issues {
                  * @return possible object is
                  *         {@link String }
                  */
-                public String getType() {
+                public String getType()
+                {
                     return type;
                 }
 
@@ -764,7 +797,8 @@ public class Issues {
                  * @param value allowed object is
                  *              {@link String }
                  */
-                public void setType(String value) {
+                public void setType(String value)
+                {
                     this.type = value;
                 }
 
@@ -774,7 +808,8 @@ public class Issues {
                  * @return possible object is
                  *         {@link String }
                  */
-                public String getRole() {
+                public String getRole()
+                {
                     return role;
                 }
 
@@ -784,14 +819,11 @@ public class Issues {
                  * @param value allowed object is
                  *              {@link String }
                  */
-                public void setRole(String value) {
+                public void setRole(String value)
+                {
                     this.role = value;
                 }
-
             }
-
         }
-
     }
-
 }
diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java
index b10762e..2bb77c5 100644
--- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java
+++ b/src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java
@@ -2,7 +2,7 @@
 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 
 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
 // Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2011.12.16 at 09:34:48 AM CET 
+// Generated on: 2011.12.16 at 10:06:20 AM CET 
 //
 
 package pl.com.it_crowd.youtrack.api.rest;
@@ -28,49 +28,55 @@ public class ObjectFactory {
     /**
      * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pl.com.it_crowd.youtrack.api.rest
      */
-    public ObjectFactory() {
+    public ObjectFactory()
+    {
     }
 
     /**
-     * Create an instance of {@link Issues.Issue.Comment.Value }
+     * Create an instance of {@link Issues.Issue }
      */
-    public Issues.Issue.Comment.Value createIssuesIssueCommentValue() {
-        return new Issues.Issue.Comment.Value();
+    public Issues.Issue createIssuesIssue()
+    {
+        return new Issues.Issue();
     }
 
     /**
-     * Create an instance of {@link Issues.Issue.Field }
+     * Create an instance of {@link Issues.Issue.Comment }
      */
-    public Issues.Issue.Field createIssuesIssueField() {
-        return new Issues.Issue.Field();
+    public Issues.Issue.Comment createIssuesIssueComment()
+    {
+        return new Issues.Issue.Comment();
     }
 
     /**
      * Create an instance of {@link Issues }
      */
-    public Issues createIssues() {
+    public Issues createIssues()
+    {
         return new Issues();
     }
 
     /**
-     * Create an instance of {@link Issues.Issue.Field.Value }
+     * Create an instance of {@link Issues.Issue.Comment.Value }
      */
-    public Issues.Issue.Field.Value createIssuesIssueFieldValue() {
-        return new Issues.Issue.Field.Value();
+    public Issues.Issue.Comment.Value createIssuesIssueCommentValue()
+    {
+        return new Issues.Issue.Comment.Value();
     }
 
     /**
-     * Create an instance of {@link Issues.Issue.Comment }
+     * Create an instance of {@link Issues.Issue.Field.Value }
      */
-    public Issues.Issue.Comment createIssuesIssueComment() {
-        return new Issues.Issue.Comment();
+    public Issues.Issue.Field.Value createIssuesIssueFieldValue()
+    {
+        return new Issues.Issue.Field.Value();
     }
 
     /**
-     * Create an instance of {@link Issues.Issue }
+     * Create an instance of {@link Issues.Issue.Field }
      */
-    public Issues.Issue createIssuesIssue() {
-        return new Issues.Issue();
+    public Issues.Issue.Field createIssuesIssueField()
+    {
+        return new Issues.Issue.Field();
     }
-
 }
diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPI.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPI.java
deleted file mode 100644
index 75b49c7..0000000
--- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPI.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package pl.com.it_crowd.youtrack.api.rest;
-
-import com.gargoylesoftware.htmlunit.BrowserVersion;
-import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
-import com.gargoylesoftware.htmlunit.HttpMethod;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.WebRequest;
-import com.gargoylesoftware.htmlunit.WebResponse;
-import com.gargoylesoftware.htmlunit.html.DomNode;
-import com.gargoylesoftware.htmlunit.util.NameValuePair;
-import com.gargoylesoftware.htmlunit.xml.XmlPage;
-import org.apache.http.auth.AuthenticationException;
-import pl.com.it_crowd.youtrack.api.Issue;
-import pl.com.it_crowd.youtrack.api.IssuesUnmarshaller;
-
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-public class YoutrackAPI {
-// ------------------------------ FIELDS ------------------------------
-
-    private String serviceLocation;
-
-    private WebClient webClient;
-
-// --------------------------- CONSTRUCTORS ---------------------------
-
-    public YoutrackAPI(String serviceLocation) {
-        this.serviceLocation = serviceLocation;
-        this.webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
-        this.webClient.setJavaScriptEnabled(false);
-        this.webClient.setCssEnabled(false);
-    }
-
-    public YoutrackAPI(String serviceLocation, String username, String password) throws IOException, AuthenticationException {
-        this(serviceLocation);
-        login(username, password);
-    }
-
-// --------------------- GETTER / SETTER METHODS ---------------------
-
-    public String getServiceLocation() {
-        return serviceLocation;
-    }
-
-// -------------------------- OTHER METHODS --------------------------
-
-    public void login(String username, String password) throws IOException, AuthenticationException {
-        ArrayList<NameValuePair> requestParameters = new ArrayList<NameValuePair>();
-        requestParameters.add(new NameValuePair("login", username));
-        requestParameters.add(new NameValuePair("password", password));
-        WebRequest request = new WebRequest(new URL(serviceLocation + "/rest/user/login"), HttpMethod.POST);
-        request.setRequestParameters(requestParameters);
-        try {
-            webClient.getPage(request);
-        } catch (FailingHttpStatusCodeException e) {
-            if (e.getStatusCode() == 403) {
-                DomNode error = ((XmlPage) webClient.getCurrentWindow().getEnclosedPage()).getFirstChild();
-                if (error != null) {
-                    throw new AuthenticationException(error.getTextContent());
-                }
-            }
-            throw e;
-        }
-    }
-
-    public List<Issue> searchIssuesByProject(String project, String filter) throws JAXBException, IOException {
-        String url = serviceLocation + "/rest/issue/byproject/" + project + "?filter=" + filter;
-        WebResponse webResponse = webClient.<Page>getPage(url).getWebResponse();
-//        System.out.println(webResponse.getContentAsString());
-        List<Issues.Issue> issues = IssuesUnmarshaller.unmarshal(webResponse.getContentAsStream()).getIssue();
-        List<Issue> result = new ArrayList<Issue>();
-        for (Issues.Issue issue : issues) {
-            result.add(new Issue(issue));
-        }
-        return 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 fa86ee8..81fd2fa 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
@@ -4,6 +4,7 @@ import junit.framework.Assert;
 import org.apache.http.auth.AuthenticationException;
 import org.junit.Test;
 import pl.com.it_crowd.youtrack.api.Issue;
+import pl.com.it_crowd.youtrack.api.YoutrackAPI;
 
 import javax.xml.bind.JAXBException;
 import java.io.IOException;
@@ -16,14 +17,16 @@ public class YoutrackAPITest {
 // -------------------------- OTHER METHODS --------------------------
 
     @Test(expected = AuthenticationException.class)
-    public void loginFailureTest() throws IOException, AuthenticationException {
+    public void loginFailureTest() throws IOException, AuthenticationException
+    {
         final String username = "someFakeLogin";
         final String password = "someFakePassword";
         new YoutrackAPI("http://youtrack.it-crowd.com.pl", username, password);
     }
 
     @Test
-    public void loginTest() throws IOException, AuthenticationException {
+    public void loginTest() throws IOException, AuthenticationException
+    {
         final String username = getUsername();
         final String password = getPassword();
         new YoutrackAPI("http://youtrack.it-crowd.com.pl", username, password);
@@ -32,7 +35,8 @@ public class YoutrackAPITest {
     }
 
     @Test
-    public void searchIssuesByProjectTest() throws IOException, AuthenticationException, JAXBException {
+    public void searchIssuesByProjectTest() throws IOException, AuthenticationException, JAXBException
+    {
         YoutrackAPI api = new YoutrackAPI("http://youtrack.it-crowd.com.pl", getUsername(), getPassword());
         List<Issue> issues = api.searchIssuesByProject("SM", null);
         Assert.assertTrue(!issues.isEmpty());
@@ -43,11 +47,13 @@ public class YoutrackAPITest {
         }
     }
 
-    private String getPassword() {
+    private String getPassword()
+    {
         return System.getProperty("youtrackPassword");
     }
 
-    private String getUsername() {
+    private String getUsername()
+    {
         return System.getProperty("youtrackUsername");
     }
 }
--
libgit2 0.24.0