From f64776123a06f63101f1ed21977a46e511e37768 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 4 Apr 2013 13:07:34 +0000 Subject: [PATCH] Repackage pl.com.it_crowd to pl.itcrowd --- pom.xml | 18 +++++++++--------- src/main/java/pl/com/it_crowd/youtrack/api/Command.java | 67 ------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/Commander.java | 7 ------- src/main/java/pl/com/it_crowd/youtrack/api/ErrorUnmarshaller.java | 42 ------------------------------------------ src/main/java/pl/com/it_crowd/youtrack/api/Filter.java | 255 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/IssueWrapper.java | 78 ------------------------------------------------------------------------------ src/main/java/pl/com/it_crowd/youtrack/api/URIUtils.java | 23 ----------------------- src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java | 389 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/YoutrackUnmarshaller.java | 28 ---------------------------- src/main/java/pl/com/it_crowd/youtrack/api/defaults/DateValues.java | 29 ----------------------------- src/main/java/pl/com/it_crowd/youtrack/api/defaults/Fields.java | 44 -------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/defaults/StateValues.java | 89 ----------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/exceptions/NoResultFoundException.java | 10 ---------- src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java | 14 -------------- src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java | 22 ---------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/AssignedByType.java | 61 ------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeList.java | 186 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeType.java | 114 ------------------------------------------------------------------------------------------------------------------ src/main/java/pl/com/it_crowd/youtrack/api/rest/Comment.java | 423 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/Enumeration.java | 96 ------------------------------------------------------------------------------------------------ src/main/java/pl/com/it_crowd/youtrack/api/rest/EnumerationValue.java | 85 ------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/Field.java | 207 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/Issue.java | 99 --------------------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java | 71 ----------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java | 226 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/User.java | 87 --------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/UserGroupRefType.java | 111 --------------------------------------------------------------------------------------------------------------- src/main/java/pl/com/it_crowd/youtrack/api/rest/UserRefs.java | 71 ----------------------------------------------------------------------- src/main/java/pl/it_crowd/youtrack/api/Command.java | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/Commander.java | 7 +++++++ src/main/java/pl/it_crowd/youtrack/api/ErrorUnmarshaller.java | 42 ++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/Filter.java | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/IssueWrapper.java | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/URIUtils.java | 23 +++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/YoutrackAPI.java | 389 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/YoutrackUnmarshaller.java | 28 ++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/defaults/DateValues.java | 29 +++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/defaults/Fields.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/defaults/StateValues.java | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/exceptions/NoResultFoundException.java | 10 ++++++++++ src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java | 14 ++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java | 22 ++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/AssignedByType.java | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeList.java | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeType.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/Comment.java | 423 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/Enumeration.java | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/EnumerationValue.java | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/Field.java | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/Issue.java | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/Issues.java | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/ObjectFactory.java | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/User.java | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/UserGroupRefType.java | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/pl/it_crowd/youtrack/api/rest/UserRefs.java | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/xjb/bindings.xjb | 3 ++- src/test/java/pl/com/it_crowd/youtrack/api/rest/CommandTest.java | 50 -------------------------------------------------- src/test/java/pl/com/it_crowd/youtrack/api/rest/FilterTest.java | 140 -------------------------------------------------------------------------------------------------------------------------------------------- src/test/java/pl/com/it_crowd/youtrack/api/rest/URIUtilsTest.java | 35 ----------------------------------- src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java | 244 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/test/java/pl/it_crowd/youtrack/api/rest/CommandTest.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/java/pl/it_crowd/youtrack/api/rest/FilterTest.java | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/java/pl/it_crowd/youtrack/api/rest/URIUtilsTest.java | 35 +++++++++++++++++++++++++++++++++++ src/test/java/pl/it_crowd/youtrack/api/rest/YoutrackAPITest.java | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 64 files changed, 3414 insertions(+), 3413 deletions(-) delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/Command.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/Commander.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/ErrorUnmarshaller.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/Filter.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/IssueWrapper.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/URIUtils.java delete 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/YoutrackUnmarshaller.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/defaults/DateValues.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/defaults/Fields.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/defaults/StateValues.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/exceptions/NoResultFoundException.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/AssignedByType.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeList.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeType.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/Comment.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/Enumeration.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/EnumerationValue.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/Field.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/Issue.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/User.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/UserGroupRefType.java delete mode 100644 src/main/java/pl/com/it_crowd/youtrack/api/rest/UserRefs.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/Command.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/Commander.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/ErrorUnmarshaller.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/Filter.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/IssueWrapper.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/URIUtils.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/YoutrackAPI.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/YoutrackUnmarshaller.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/defaults/DateValues.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/defaults/Fields.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/defaults/StateValues.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/exceptions/NoResultFoundException.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/AssignedByType.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeList.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeType.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/Comment.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/Enumeration.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/EnumerationValue.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/Field.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/Issue.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/Issues.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/ObjectFactory.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/User.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/UserGroupRefType.java create mode 100644 src/main/java/pl/it_crowd/youtrack/api/rest/UserRefs.java delete mode 100644 src/test/java/pl/com/it_crowd/youtrack/api/rest/CommandTest.java delete mode 100644 src/test/java/pl/com/it_crowd/youtrack/api/rest/FilterTest.java delete mode 100644 src/test/java/pl/com/it_crowd/youtrack/api/rest/URIUtilsTest.java delete mode 100644 src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java create mode 100644 src/test/java/pl/it_crowd/youtrack/api/rest/CommandTest.java create mode 100644 src/test/java/pl/it_crowd/youtrack/api/rest/FilterTest.java create mode 100644 src/test/java/pl/it_crowd/youtrack/api/rest/URIUtilsTest.java create mode 100644 src/test/java/pl/it_crowd/youtrack/api/rest/YoutrackAPITest.java diff --git a/pom.xml b/pom.xml index df2edd4..65f5dd6 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - pl.com.it-crowd + pl.itcrowd youtrack-rest-api 1.1.0-SNAPSHOT @@ -68,7 +68,7 @@ - pl.com.it_crowd.youtrack.api.rest + pl.itcrowd.youtrack.api.rest ${project.build.sourceDirectory} false false @@ -87,19 +87,19 @@ - it-crowd.com.pl - MyCo Internal Repository - http://artifactory.it-crowd.com.pl/libs-release-local + itcrowd.pl + IT Crowd company internal repository + http://artifactory.itcrowd.pl/libs-release-local - it-crowd.com.pl - MyCo Internal Repository - http://artifactory.it-crowd.com.pl/libs-snapshot-local + itcrowd.pl + IT Crowd company internal repository + http://artifactory.itcrowd.pl/libs-snapshot-local - scm:svn:https://it-crowd.com.pl/svn/youtrack-rest-api/trunk + scm:svn:https://itcrowd.pl/svn/youtrack-rest-api/trunk diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/Command.java b/src/main/java/pl/com/it_crowd/youtrack/api/Command.java deleted file mode 100644 index d2d2c06..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/Command.java +++ /dev/null @@ -1,67 +0,0 @@ -package pl.com.it_crowd.youtrack.api; - -import pl.com.it_crowd.youtrack.api.defaults.Fields; -import pl.com.it_crowd.youtrack.api.defaults.StateValues; - -public class Command { -// ------------------------------ FIELDS ------------------------------ - - protected StringBuilder command = new StringBuilder(); - -// -------------------------- STATIC METHODS -------------------------- - - public static Command assigneeCommand(String assignee) - { - return new Command().assignee(assignee); - } - - public static Command stateCommand(String state) - { - return new Command().state(state); - } - - public static Command stateCommand(StateValues state) - { - return new Command().state(state); - } - -// --------------------------- CONSTRUCTORS --------------------------- - - protected Command() - { - } - -// ------------------------ CANONICAL METHODS ------------------------ - - @Override - public String toString() - { - return command.toString().trim(); - } - -// -------------------------- OTHER METHODS -------------------------- - - public Command assignee(String assignee) - { - return command(Fields.assignee, assignee); - } - - public Command state(String state) - { - return command(Fields.state, state); - } - - public Command state(StateValues state) - { - if (state.getCommandValue() == null) { - throw new IllegalArgumentException("Cannot set readonly state: " + state); - } - return state(state.getCommandValue()); - } - - protected Command command(Commander commander, String argument) - { - this.command.append(" ").append(commander.getCommand()).append(" ").append(argument); - return this; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/Commander.java b/src/main/java/pl/com/it_crowd/youtrack/api/Commander.java deleted file mode 100644 index cc88b98..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/Commander.java +++ /dev/null @@ -1,7 +0,0 @@ -package pl.com.it_crowd.youtrack.api; - -public interface Commander { -// -------------------------- OTHER METHODS -------------------------- - - String getCommand(); -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/ErrorUnmarshaller.java b/src/main/java/pl/com/it_crowd/youtrack/api/ErrorUnmarshaller.java deleted file mode 100644 index ac7f53e..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/ErrorUnmarshaller.java +++ /dev/null @@ -1,42 +0,0 @@ -package pl.com.it_crowd.youtrack.api; - -import org.apache.commons.io.IOUtils; -import pl.com.it_crowd.youtrack.api.rest.ObjectFactory; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; - -//TODO methods from this class should be probably merged with YoutrackUnmarshaller -public final class ErrorUnmarshaller { -// -------------------------- STATIC METHODS -------------------------- - - public static String unmarshal(String string) throws JAXBException, IOException - { - return unmarshal(new StringReader(string)); - } - - public static String unmarshal(Reader reader) throws JAXBException, IOException - { - String content = IOUtils.toString(reader); - try { - JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); - @SuppressWarnings("unchecked") - final JAXBElement element = (JAXBElement) jaxbContext.createUnmarshaller().unmarshal(new StringReader(content)); - return element.getValue(); - } catch (JAXBException e) { -// TODO we need logging here - System.err.println("Cannot unmarshal input stream.\n" + content + e); - throw e; - } - } - -// --------------------------- CONSTRUCTORS --------------------------- - - private ErrorUnmarshaller() - { - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/Filter.java b/src/main/java/pl/com/it_crowd/youtrack/api/Filter.java deleted file mode 100644 index 81863c7..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/Filter.java +++ /dev/null @@ -1,255 +0,0 @@ -package pl.com.it_crowd.youtrack.api; - -import pl.com.it_crowd.youtrack.api.defaults.DateValues; -import pl.com.it_crowd.youtrack.api.defaults.Fields; -import pl.com.it_crowd.youtrack.api.defaults.StateValues; - -import java.util.ArrayList; -import java.util.List; - -public final class Filter { -// ------------------------------ FIELDS ------------------------------ - - private long after; - - private List conditions = new ArrayList(); - - private long maxResults; - -// -------------------------- STATIC METHODS -------------------------- - - public static Filter createdFilter(String date) - { - return new Filter().created(date); - } - - public static Filter createdFilter(DateValues date) - { - return new Filter().created(date); - } - - public static Filter descriptionFilter(String description) - { - return new Filter().description(description); - } - - public static Filter issueIdFilter(String issueId) - { - return new Filter().issueId(issueId); - } - - public static Filter projectFilter(String project) - { - return new Filter().project(project); - } - - public static Filter reporterFilter(String reporter) - { - return new Filter().reporter(reporter); - } - - public static Filter resolvedFilter(String date) - { - return new Filter().resolved(date); - } - - public static Filter resolvedFilter(DateValues date) - { - return new Filter().resolved(date); - } - - public static Filter stateFilter(StateValues... state) - { - return new Filter().state(state); - } - - public static Filter stateFilter(String state) - { - return new Filter().state(state); - } - - public static Filter summaryFilter(String summary) - { - return new Filter().summary(summary); - } - - public static Filter unresolvedFilter() - { - return new Filter().unresolved(); - } - - public static Filter updatedFilter(String date) - { - return new Filter().updated(date); - } - - public static Filter updatedFilter(DateValues date) - { - return new Filter().updated(date); - } - - public static Filter updaterFilter(String updater) - { - return new Filter().updater(updater); - } - -// --------------------------- CONSTRUCTORS --------------------------- - - private Filter() - { - - } - -// ------------------------ CANONICAL METHODS ------------------------ - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - String space = " "; - for (Condition condition : conditions) { - builder.append(space); - if (condition.field != null) { - builder.append(condition.field.getCommand()); - builder.append(":"); - } - builder.append(condition.value); - } - if (maxResults > 0) { - builder.append("&max=").append(maxResults); - } - if (after > 0) { - builder.append("&after=").append(after); - } - return builder.length() > space.length() ? builder.substring(space.length()) : builder.toString(); - } - -// -------------------------- OTHER METHODS -------------------------- - - public Filter after(long after) - { - this.after = after; - return this; - } - - public Filter created(DateValues date) - { - return created(date.getFilterValue()); - } - - public Filter created(String date) - { - conditions.add(new Condition(Fields.created, date)); - return this; - } - - public Filter description(String description) - { - conditions.add(new Condition(Fields.description, description)); - return this; - } - - public Filter freeText(String text) - { - conditions.add(new Condition(null, text)); - return this; - } - - public Filter issueId(String issueId) - { - conditions.add(new Condition(Fields.issueId, issueId)); - return this; - } - - public Filter maxResults(long maxResults) - { - this.maxResults = maxResults; - return this; - } - - public Filter project(String project) - { - conditions.add(new Condition(Fields.projectShortName, project)); - return this; - } - - public Filter reporter(String reporter) - { - conditions.add(new Condition(Fields.reporterName, reporter)); - return this; - } - - public Filter resolved(DateValues date) - - { - return resolved(date.getFilterValue()); - } - - public Filter resolved(String date) - { - conditions.add(new Condition(Fields.resolved, date)); - return this; - } - - public Filter state(StateValues... state) - { - final StringBuilder stringBuilder = new StringBuilder(); - for (StateValues value : state) { - stringBuilder.append(",").append(value.getFilterValue()); - } - return state(stringBuilder.length() > 0 ? stringBuilder.substring(1) : stringBuilder.toString()); - } - - public Filter summary(String summary) - { - conditions.add(new Condition(Fields.summary, summary)); - return this; - } - - public Filter unresolved() - { - conditions.add(new Condition(Fields.state, StateValues.Unresolved.getFilterValue())); - return this; - } - - public Filter updated(DateValues date) - { - return updated(date.getFilterValue()); - } - - public Filter updated(String date) - { - conditions.add(new Condition(Fields.updated, date)); - return this; - } - - public Filter updater(String updater) - { - conditions.add(new Condition(Fields.updaterName, updater)); - return this; - } - - private Filter state(String state) - { - conditions.add(new Condition(Fields.state, state)); - return this; - } - -// -------------------------- INNER CLASSES -------------------------- - - private class Condition { -// ------------------------------ FIELDS ------------------------------ - - private Fields field; - - private String value; - -// --------------------------- CONSTRUCTORS --------------------------- - - private Condition(Fields field, String value) - { - this.field = field; - this.value = value; - } - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/IssueWrapper.java b/src/main/java/pl/com/it_crowd/youtrack/api/IssueWrapper.java deleted file mode 100644 index 4a9e4b3..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/IssueWrapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package pl.com.it_crowd.youtrack.api; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import pl.com.it_crowd.youtrack.api.defaults.Fields; -import pl.com.it_crowd.youtrack.api.rest.Comment; -import pl.com.it_crowd.youtrack.api.rest.Field; -import pl.com.it_crowd.youtrack.api.rest.Issue; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class IssueWrapper implements Serializable { -// ------------------------------ FIELDS ------------------------------ - - private static final Log log = LogFactory.getLog(IssueWrapper.class); - - private List comments; - - private Map fieldMap; - - private Issue issue; - -// --------------------------- CONSTRUCTORS --------------------------- - - public IssueWrapper(Issue issue) - { - this.issue = issue; - fieldMap = new HashMap(); - comments = new ArrayList(); - for (Object o : issue.getFieldOrComment()) { - if (o instanceof Field) { - Field field = (Field) o; - fieldMap.put(field.getName().toLowerCase(), field); - } else if (o instanceof Comment) { - comments.add((Comment) o); - } else { - log.warn("Object " + o + " is not Field nor Coment"); - } - } - } - -// -------------------------- OTHER METHODS -------------------------- - - public List getComments() - { - return Collections.unmodifiableList(comments); - } - - public Field getField(String field) - { - return fieldMap.get(field); - } - - public String getFieldValue(String fieldName) - { - Field field = getField(fieldName.toLowerCase()); - if (field == null) { - return null; - } - List values = field.getValues(); - return values.isEmpty() ? null : values.get(0).getContent(); - } - - public String getFieldValue(Fields field) - { - return getFieldValue(field.name()); - } - - public String getId() - { - return issue.getId(); - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/URIUtils.java b/src/main/java/pl/com/it_crowd/youtrack/api/URIUtils.java deleted file mode 100644 index ffadeef..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/URIUtils.java +++ /dev/null @@ -1,23 +0,0 @@ -package pl.com.it_crowd.youtrack.api; - -import java.net.URI; -import java.net.URISyntaxException; - -public class URIUtils { -// -------------------------- STATIC METHODS -------------------------- - - public static URI buildURI(URI base, String path) - { - return buildURI(base, path, null); - } - - public static URI buildURI(URI base, String path, String query) - { - try { - return new URI(base.getScheme(), base.getUserInfo(), base.getHost(), base.getPort(), base.getPath().replaceAll("/+$", "") + path, query, - base.getFragment()); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } -} 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 deleted file mode 100644 index 06f692b..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java +++ /dev/null @@ -1,389 +0,0 @@ -package pl.com.it_crowd.youtrack.api; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.Header; -import org.apache.http.HttpEntity; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.NameValuePair; -import org.apache.http.StatusLine; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.HttpClient; -import org.apache.http.client.HttpResponseException; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.conn.PoolingClientConnectionManager; -import org.apache.http.impl.conn.SchemeRegistryFactory; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.util.EntityUtils; -import pl.com.it_crowd.youtrack.api.defaults.Fields; -import pl.com.it_crowd.youtrack.api.exceptions.NoResultFoundException; -import pl.com.it_crowd.youtrack.api.exceptions.YoutrackAPIException; -import pl.com.it_crowd.youtrack.api.exceptions.YoutrackErrorException; -import pl.com.it_crowd.youtrack.api.rest.AssigneeList; -import pl.com.it_crowd.youtrack.api.rest.Enumeration; -import pl.com.it_crowd.youtrack.api.rest.Issue; -import pl.com.it_crowd.youtrack.api.rest.Issues; -import pl.com.it_crowd.youtrack.api.rest.User; -import pl.com.it_crowd.youtrack.api.rest.UserRefs; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.namespace.QName; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static pl.com.it_crowd.youtrack.api.URIUtils.buildURI; - -public class YoutrackAPI { -// ------------------------------ FIELDS ------------------------------ - - private final static QName Enumeration_QNAME = new QName("", "enumeration"); - - private final static QName Issue_QNAME = new QName("", "issue"); - - private static Log LOG = LogFactory.getLog(YoutrackAPI.class); - - private HttpClient httpClient; - - private String serviceLocation; - - private URI serviceLocationURI; - -// -------------------------- STATIC METHODS -------------------------- - - private static HttpClient getDefaultHttpClient() - { - SSLContext sslContext; - try { - sslContext = SSLContext.getInstance("SSL"); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } - // set up a TrustManager that trusts everything - try { - sslContext.init(null, new TrustManager[]{new X509TrustManager() { - public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException - { - } - - public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException - { - } - - public X509Certificate[] getAcceptedIssuers() - { - return new X509Certificate[0]; - } - }}, new SecureRandom()); - } catch (KeyManagementException e) { - throw new RuntimeException(e); - } - - SSLSocketFactory sf = new SSLSocketFactory(sslContext); - Scheme httpsScheme = new Scheme("https", 443, sf); - SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault(); - schemeRegistry.register(schemeRegistry.unregister("https")); - schemeRegistry.register(httpsScheme); - - ClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); - return new DefaultHttpClient(cm); - } - - private static boolean isBlank(String str) - { - int strLen; - if (str == null || (strLen = str.length()) == 0) { - return true; - } - for (int i = 0; i < strLen; i++) { - if ((!Character.isWhitespace(str.charAt(i)))) { - return false; - } - } - return true; - } - -// --------------------------- CONSTRUCTORS --------------------------- - - public YoutrackAPI(String serviceLocation) - { - this(serviceLocation, null); - } - - public YoutrackAPI(String serviceLocation, HttpClient httpClient) - { - if (serviceLocation == null) { - throw new IllegalArgumentException("serviceLocation cannot be null"); - } - this.serviceLocation = serviceLocation; - try { - serviceLocationURI = new URI(this.serviceLocation); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - this.httpClient = httpClient == null ? getDefaultHttpClient() : httpClient; - } - - public YoutrackAPI(String serviceLocation, String username, String password) throws IOException, JAXBException - { - this(serviceLocation, null, username, password); - } - - public YoutrackAPI(String serviceLocation, HttpClient httpClient, String username, String password) throws IOException, JAXBException - { - this(serviceLocation, httpClient); - login(username, password); - } - -// --------------------- GETTER / SETTER METHODS --------------------- - - public String getServiceLocation() - { - return serviceLocation; - } - -// -------------------------- OTHER METHODS -------------------------- - - public void command(String issueId, String command) throws IOException - { - command(issueId, command, null, null, null, null); - } - - public void command(String issueId, Command command) throws IOException - { - command(issueId, command.toString()); - } - - public void command(String issueId, String command, String comment, String group, Boolean disableNotifications, String runAs) throws IOException - { - final HttpPost request = new HttpPost(buildURI(serviceLocationURI, "/rest/issue/" + issueId + "/execute")); - final List parameters = new ArrayList(); - parameters.add(new BasicNameValuePair("command", command)); - if (!isBlank(comment)) { - parameters.add(new BasicNameValuePair("comment", comment)); - } - if (!isBlank(group)) { - parameters.add(new BasicNameValuePair("group", group)); - } - if (disableNotifications != null) { - parameters.add(new BasicNameValuePair("disableNotifications", disableNotifications.toString())); - } - if (!isBlank(runAs)) { - parameters.add(new BasicNameValuePair("runAs", runAs)); - } - request.setEntity(new UrlEncodedFormEntity(parameters)); - execute(request); - } - - /** - * Creates new issue on Youtrack. - * - * @param project project to create issue in - * @param summary summary of the issue - * @param description longer description of the issue - * - * @return issue id of created issue - * - * @throws IOException in case of communication problems - */ - public String createIssue(String project, String summary, String description) throws IOException - { - final HttpPut request = createPutRequest(buildURI(serviceLocationURI, "/rest/issue"), new BasicNameValuePair("project", project), - new BasicNameValuePair("summary", summary), new BasicNameValuePair("description", description)); - final HttpResponse response = httpClient.execute(request); - final StatusLine statusLine = response.getStatusLine(); - final HttpEntity entity = response.getEntity(); - final String responseText = entity == null ? null : EntityUtils.toString(entity); - throwExceptionsIfNeeded(statusLine, responseText); - - final Header header = response.getFirstHeader(HttpHeaders.LOCATION); - if (header == null) { - throw new YoutrackAPIException("Missing location header despite positive status code: " + statusLine.getStatusCode()); - } - final String issueURL = header.getValue(); - final Matcher matcher = Pattern.compile(".*(" + project + "-\\d+)").matcher(issueURL); - if (!matcher.find() || matcher.groupCount() < 1) { - throw new YoutrackAPIException("Cannot extract issue id from issue URL: " + issueURL); - } - return matcher.group(1); - } - - public void deleteIssue(String issueId) throws IOException - { - execute(new HttpDelete(buildURI(serviceLocationURI, "/rest/issue/" + issueId))); - } - - public AssigneeList getAssignees(String project) throws IOException, JAXBException - { - final String responseString = execute(new HttpGet(buildURI(serviceLocationURI, "/rest/admin/project/" + project + "/assignee"))); - final Object result = YoutrackUnmarshaller.unmarshall(responseString); - if (result instanceof AssigneeList) { - return (AssigneeList) result; - } else { - throw new YoutrackAPIException("Unexpected type: " + result); - } - } - - public Enumeration getBundle(String customField) throws IOException, JAXBException - { - final Object result = YoutrackUnmarshaller.unmarshall(execute(new HttpGet(buildURI(serviceLocationURI, "/rest/admin/customfield/bundle/" + customField)))); - if (result instanceof Enumeration) { - return (Enumeration) result; - } else if (result instanceof JAXBElement) { - final JAXBElement jaxbElement = (JAXBElement) result; - if (Enumeration_QNAME.equals(jaxbElement.getName())) { - return (Enumeration) ((JAXBElement) result).getValue(); - } else { - throw new YoutrackAPIException("Unexpected type: " + jaxbElement.getValue()); - } - } else { - throw new YoutrackAPIException("Unexpected type: " + result); - } - } - - public List getIndividualAssignees(String project) throws IOException, JAXBException - { - final String responseString = execute(new HttpGet(buildURI(serviceLocationURI, "/rest/admin/project/" + project + "/assignee/individual"))); - final Object result = YoutrackUnmarshaller.unmarshall(responseString); - if (result instanceof UserRefs) { - return ((UserRefs) result).getUsers(); - } else { - throw new YoutrackAPIException("Unexpected type: " + result); - } - } - - public IssueWrapper getIssue(String issueId) throws IOException, JAXBException - { - final String responseString; - try { - responseString = execute(new HttpGet(buildURI(serviceLocationURI, "/rest/issue/" + issueId))); - } catch (YoutrackErrorException e) { - if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { - throw new NoResultFoundException(e.getMessage(), e); - } else { - throw e; - } - } - final Object result = YoutrackUnmarshaller.unmarshall(responseString); - if (result instanceof pl.com.it_crowd.youtrack.api.rest.Issue) { - return new IssueWrapper((Issue) result); - } else if (result instanceof JAXBElement) { - final JAXBElement jaxbElement = (JAXBElement) result; - if (Issue_QNAME.equals(jaxbElement.getName())) { - return new IssueWrapper((Issue) jaxbElement.getValue()); - } else { - throw new YoutrackAPIException("Unexpected type: " + jaxbElement.getValue()); - } - } else { - throw new YoutrackAPIException("Unexpected type " + result); - } - } - - public void login(String username, String password) throws IOException, JAXBException - { - final HttpPost request = new HttpPost(buildURI(serviceLocationURI, "/rest/user/login")); - request.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair("login", username), new BasicNameValuePair("password", password)))); - execute(request); - } - - public List searchIssuesByProject(String project, Object filter) throws JAXBException, IOException - { - final Object result = YoutrackUnmarshaller.unmarshall( - execute(new HttpGet(buildURI(serviceLocationURI, "/rest/issue/byproject/" + project, "filter=" + (filter == null ? "" : filter))))); - if (!(result instanceof Issues)) { - throw new YoutrackAPIException("Unmarshalling problem. Expected Issues, received: " + result.getClass() + " " + result); - } - List issues = ((Issues) result).getIssues(); - List wrappedIssues = new ArrayList(); - for (Issue issue : issues) { - wrappedIssues.add(new IssueWrapper(issue)); - } - return wrappedIssues; - } - - public void updateIssue(String issueId, String summary, String description) throws IOException - { - final HttpPost request = createPostRequest(buildURI(serviceLocationURI, "/rest/issue/" + issueId), new BasicNameValuePair(Fields.summary.name(), summary), - new BasicNameValuePair(Fields.description.name(), description)); - final HttpResponse response = httpClient.execute(request); - final StatusLine statusLine = response.getStatusLine(); - final HttpEntity entity = response.getEntity(); - final String responseText = entity == null ? null : EntityUtils.toString(entity); - throwExceptionsIfNeeded(statusLine, responseText); - } - - private HttpPost createPostRequest(URI uri, NameValuePair... nameValuePair) throws UnsupportedEncodingException - { - return setEntity(new HttpPost(uri), nameValuePair); - } - - private HttpPut createPutRequest(URI uri, NameValuePair... nameValuePair) throws UnsupportedEncodingException - { - return setEntity(new HttpPut(uri), nameValuePair); - } - - private String execute(HttpUriRequest request) throws IOException - { - final HttpResponse response = httpClient.execute(request); - final StatusLine statusLine = response.getStatusLine(); - final HttpEntity entity = response.getEntity(); - String responseText = entity == null ? null : EntityUtils.toString(entity); - if (statusLine.getStatusCode() >= 300) { - try { - final String error = ErrorUnmarshaller.unmarshal(responseText); - throw new YoutrackErrorException(error, statusLine.getStatusCode()); - } catch (JAXBException e) { - LOG.error("Cannot unmarshal following response text:\n" + responseText, e); - throw new HttpResponseException(statusLine.getStatusCode(), responseText); - } - } - if (entity == null) { - throw new ClientProtocolException("Response contains no content"); - } - return responseText; - } - - private T setEntity(T request, NameValuePair[] nameValuePair) throws UnsupportedEncodingException - { - final ArrayList list = new ArrayList(); - Collections.addAll(list, nameValuePair); - request.setEntity(new UrlEncodedFormEntity(list)); - return request; - } - - private void throwExceptionsIfNeeded(StatusLine statusLine, String responseText) throws IOException - { - if (statusLine.getStatusCode() >= 300) { - throw new HttpResponseException(statusLine.getStatusCode(), responseText); - } - } -} \ No newline at end of file diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackUnmarshaller.java b/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackUnmarshaller.java deleted file mode 100644 index a7ada03..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackUnmarshaller.java +++ /dev/null @@ -1,28 +0,0 @@ -package pl.com.it_crowd.youtrack.api; - -import pl.com.it_crowd.youtrack.api.rest.ObjectFactory; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import java.io.Reader; -import java.io.StringReader; - -public final class YoutrackUnmarshaller { -// -------------------------- STATIC METHODS -------------------------- - - public static Object unmarshall(String string) throws JAXBException - { - return unmarshall(new StringReader(string)); - } - - public static Object unmarshall(Reader reader) throws JAXBException - { - return JAXBContext.newInstance(ObjectFactory.class).createUnmarshaller().unmarshal(reader); - } - -// --------------------------- CONSTRUCTORS --------------------------- - - private YoutrackUnmarshaller() - { - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/defaults/DateValues.java b/src/main/java/pl/com/it_crowd/youtrack/api/defaults/DateValues.java deleted file mode 100644 index 4cf4f7c..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/defaults/DateValues.java +++ /dev/null @@ -1,29 +0,0 @@ -package pl.com.it_crowd.youtrack.api.defaults; - -public enum DateValues { - Today, Yesterday, Saturday, Friday, Thursday, Wednesday, Tuesday, Monday, Sunday, ThisWeek("{This week}"), LastWeek("{Last week}"), TwoWeeksAgo( - "{Two weeks ago}"), ThreeWeeksAgo("{Three weeks ago}"), ThisMonth("{This month}"), LastMonth("{Last month}"); - -// ------------------------------ FIELDS ------------------------------ - - private String filterValue; - -// --------------------------- CONSTRUCTORS --------------------------- - - private DateValues() - { - filterValue = name(); - } - - private DateValues(String filterValue) - { - this.filterValue = filterValue; - } - -// --------------------- GETTER / SETTER METHODS --------------------- - - public String getFilterValue() - { - return filterValue; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/defaults/Fields.java b/src/main/java/pl/com/it_crowd/youtrack/api/defaults/Fields.java deleted file mode 100644 index ad02a7b..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/defaults/Fields.java +++ /dev/null @@ -1,44 +0,0 @@ -package pl.com.it_crowd.youtrack.api.defaults; - -import pl.com.it_crowd.youtrack.api.Commander; - -public enum Fields implements Commander { - assignee, - issueId("issue id"), - state, - created("created"), - description, - numberInProject(null), - projectShortName("project"), - reporterName("reporter"), - resolved("resolved date"), - summary, - updated, - updaterName("updated by"); - -// ------------------------------ FIELDS ------------------------------ - - private String command; - -// --------------------------- CONSTRUCTORS --------------------------- - - private Fields() - { - command = name(); - } - - private Fields(String command) - { - this.command = command; - } - -// --------------------- GETTER / SETTER METHODS --------------------- - - public String getCommand() - { - if (command == null) { - throw new UnsupportedOperationException("There is no command for field: " + name()); - } - return command; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/defaults/StateValues.java b/src/main/java/pl/com/it_crowd/youtrack/api/defaults/StateValues.java deleted file mode 100644 index fa626d4..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/defaults/StateValues.java +++ /dev/null @@ -1,89 +0,0 @@ -package pl.com.it_crowd.youtrack.api.defaults; - -public enum StateValues { - Submitted, - Open, - InProgress("{In Progress}", "In Progress"), - ToBeDiscussed("{To be discussed}", "To be discussed"), - Reopened, - CantReproduce("{Can't Reproduce}", "Can't Reproduce"), - Duplicate, - Fixed, - WontFix("{Won't fix}", "Won't fix"), - Incomplete, - Obsolete, - Verified, - New, - NotSubmitted(true, Submitted), - NotOpen(true, Open), - NotInProgress(true, InProgress), - NotToBeDiscussed(true, ToBeDiscussed), - NotReopened(true, Reopened), - NotCantReproduce(true, CantReproduce), - NotDuplicate(true, Duplicate), - NotFixed(true, Fixed), - NotWontFix(true, WontFix), - NotIncomplete(true, Incomplete), - NotObsolete(true, Open), - NotVerified(true, Verified), - NotNew(true, New), - Resolved("Resolved", null), - Unresolved("Unresolved", null); - -// ------------------------------ FIELDS ------------------------------ - - private String commandValue; - - private String filterValue; - - private boolean not; - -// --------------------------- CONSTRUCTORS --------------------------- - - private StateValues() - { - this(false); - } - - private StateValues(boolean not) - { - this(not, null, null); - } - - private StateValues(String filterValue, String commandValue) - { - this(false, filterValue, commandValue); - } - - private StateValues(boolean not, StateValues value) - { - this(not, value.getFilterValue(), value.getCommandValue()); - } - - private StateValues(boolean not, String filterValue, String commandValue) - { - this.not = not; - this.filterValue = filterValue == null ? name() : filterValue; - this.commandValue = commandValue == null ? name() : commandValue; - } - -// ------------------------ CANONICAL METHODS ------------------------ - - @Override - public String toString() - { - return getCommandValue(); - } - -// -------------------------- OTHER METHODS -------------------------- - - public String getCommandValue() - { - return (not ? "-" : "") + commandValue; - } - - public String getFilterValue() - { - return (not ? "-" : "") + filterValue; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/NoResultFoundException.java b/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/NoResultFoundException.java deleted file mode 100644 index ebd7ace..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/NoResultFoundException.java +++ /dev/null @@ -1,10 +0,0 @@ -package pl.com.it_crowd.youtrack.api.exceptions; - -public class NoResultFoundException extends RuntimeException { -// --------------------------- CONSTRUCTORS --------------------------- - - public NoResultFoundException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java b/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java deleted file mode 100644 index be96924..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java +++ /dev/null @@ -1,14 +0,0 @@ -package pl.com.it_crowd.youtrack.api.exceptions; - -public class YoutrackAPIException extends RuntimeException { -// --------------------------- CONSTRUCTORS --------------------------- - - public YoutrackAPIException() - { - } - - public YoutrackAPIException(String message) - { - super(message); - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java b/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java deleted file mode 100644 index ee93cdc..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java +++ /dev/null @@ -1,22 +0,0 @@ -package pl.com.it_crowd.youtrack.api.exceptions; - -public class YoutrackErrorException extends RuntimeException { -// ------------------------------ FIELDS ------------------------------ - - private int statusCode; - -// --------------------------- CONSTRUCTORS --------------------------- - - public YoutrackErrorException(String message, int statusCode) - { - super(message); - this.statusCode = statusCode; - } - -// --------------------- GETTER / SETTER METHODS --------------------- - - public int getStatusCode() - { - return statusCode; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssignedByType.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssignedByType.java deleted file mode 100644 index d6d35c4..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssignedByType.java +++ /dev/null @@ -1,61 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

Java class for assignedByType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="assignedByType">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="userGroupRef" type="{}userGroupRefType"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "assignedByType", propOrder = {"userGroupRef"}) -public class AssignedByType { -// ------------------------------ FIELDS ------------------------------ - - @XmlElement(required = true) - protected UserGroupRefType userGroupRef; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the userGroupRef property. - * - * @return possible object is - * {@link UserGroupRefType } - */ - public UserGroupRefType getUserGroupRef() - { - return userGroupRef; - } - - /** - * Sets the value of the userGroupRef property. - * - * @param value allowed object is - * {@link UserGroupRefType } - */ - public void setUserGroupRef(UserGroupRefType value) - { - this.userGroupRef = value; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeList.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeList.java deleted file mode 100644 index 41efc75..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeList.java +++ /dev/null @@ -1,186 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import java.util.ArrayList; -import java.util.List; - -/** - *

Java class for anonymous complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="assignees">
- *           <complexType>
- *             <complexContent>
- *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                 <sequence>
- *                   <element name="assignee" type="{}assigneeType" maxOccurs="unbounded" minOccurs="0"/>
- *                 </sequence>
- *               </restriction>
- *             </complexContent>
- *           </complexType>
- *         </element>
- *       </sequence>
- *       <attribute name="groupsUrl" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="individualsUrl" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = {"assignees"}) -@XmlRootElement(name = "assigneeList") -public class AssigneeList { -// ------------------------------ FIELDS ------------------------------ - - @XmlElement(required = true) - protected AssigneeList.Assignees assignees; - - @XmlAttribute - protected String groupsUrl; - - @XmlAttribute - protected String individualsUrl; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the assignees property. - * - * @return possible object is - * {@link AssigneeList.Assignees } - */ - public AssigneeList.Assignees getAssignees() - { - return assignees; - } - - /** - * Sets the value of the assignees property. - * - * @param value allowed object is - * {@link AssigneeList.Assignees } - */ - public void setAssignees(AssigneeList.Assignees value) - { - this.assignees = value; - } - - /** - * Gets the value of the groupsUrl property. - * - * @return possible object is - * {@link String } - */ - public String getGroupsUrl() - { - return groupsUrl; - } - - /** - * Sets the value of the groupsUrl property. - * - * @param value allowed object is - * {@link String } - */ - public void setGroupsUrl(String value) - { - this.groupsUrl = value; - } - - /** - * Gets the value of the individualsUrl property. - * - * @return possible object is - * {@link String } - */ - public String getIndividualsUrl() - { - return individualsUrl; - } - - /** - * Sets the value of the individualsUrl property. - * - * @param value allowed object is - * {@link String } - */ - public void setIndividualsUrl(String value) - { - this.individualsUrl = value; - } - -// -------------------------- INNER CLASSES -------------------------- - - /** - *

Java class for anonymous complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

-     * <complexType>
-     *   <complexContent>
-     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *       <sequence>
-     *         <element name="assignee" type="{}assigneeType" maxOccurs="unbounded" minOccurs="0"/>
-     *       </sequence>
-     *     </restriction>
-     *   </complexContent>
-     * </complexType>
-     * 
- */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"assignees"}) - public static class Assignees { -// ------------------------------ FIELDS ------------------------------ - - @XmlElement(name = "assignee") - protected List assignees; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the assignees property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the assignees property. - *

- *

- * For example, to add a new item, do as follows: - *

-         *    getAssignees().add(newItem);
-         * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link AssigneeType } - */ - public List getAssignees() - { - if (assignees == null) { - assignees = new ArrayList(); - } - return this.assignees; - } - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeType.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeType.java deleted file mode 100644 index 5dc818e..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/AssigneeType.java +++ /dev/null @@ -1,114 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

Java class for assigneeType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="assigneeType">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="assignedBy" type="{}assignedByType"/>
- *       </sequence>
- *       <attribute name="login" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="isIndividualAssignee" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "assigneeType", propOrder = {"assignedBy"}) -public class AssigneeType { -// ------------------------------ FIELDS ------------------------------ - - @XmlElement(required = true) - protected AssignedByType assignedBy; - - @XmlAttribute - protected String isIndividualAssignee; - - @XmlAttribute - protected String login; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the assignedBy property. - * - * @return possible object is - * {@link AssignedByType } - */ - public AssignedByType getAssignedBy() - { - return assignedBy; - } - - /** - * Sets the value of the assignedBy property. - * - * @param value allowed object is - * {@link AssignedByType } - */ - public void setAssignedBy(AssignedByType value) - { - this.assignedBy = value; - } - - /** - * Gets the value of the isIndividualAssignee property. - * - * @return possible object is - * {@link String } - */ - public String getIsIndividualAssignee() - { - return isIndividualAssignee; - } - - /** - * Sets the value of the isIndividualAssignee property. - * - * @param value allowed object is - * {@link String } - */ - public void setIsIndividualAssignee(String value) - { - this.isIndividualAssignee = value; - } - - /** - * Gets the value of the login property. - * - * @return possible object is - * {@link String } - */ - public String getLogin() - { - return login; - } - - /** - * Sets the value of the login property. - * - * @param value allowed object is - * {@link String } - */ - public void setLogin(String value) - { - this.login = value; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Comment.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/Comment.java deleted file mode 100644 index 0b2b4c2..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Comment.java +++ /dev/null @@ -1,423 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlElementRefs; -import javax.xml.bind.annotation.XmlMixed; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - *

Java class for commentType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="commentType">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="replies" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="value" maxOccurs="unbounded" minOccurs="0">
- *           <complexType>
- *             <simpleContent>
- *               <extension base="<http://www.w3.org/2001/XMLSchema>string">
- *                 <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
- *                 <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" />
- *               </extension>
- *             </simpleContent>
- *           </complexType>
- *         </element>
- *       </sequence>
- *       <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="author" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="issueId" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="deleted" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="text" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="shownForIssueAuthor" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="created" type="{http://www.w3.org/2001/XMLSchema}long" />
- *       <attribute name="updated" type="{http://www.w3.org/2001/XMLSchema}long" />
- *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "commentType", propOrder = {"content"}) -public class Comment { -// ------------------------------ FIELDS ------------------------------ - - @XmlAttribute - protected String author; - - @XmlElementRefs({@XmlElementRef(name = "value", type = JAXBElement.class), @XmlElementRef(name = "replies", type = JAXBElement.class)}) - @XmlMixed - protected List content; - - @XmlAttribute - protected Long created; - - @XmlAttribute - protected String deleted; - - @XmlAttribute - protected String id; - - @XmlAttribute - protected String issueId; - - @XmlAttribute - protected String name; - - @XmlAttribute - protected String shownForIssueAuthor; - - @XmlAttribute - protected String text; - - @XmlAttribute - protected Long updated; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the author property. - * - * @return possible object is - * {@link String } - */ - public String getAuthor() - { - return author; - } - - /** - * Sets the value of the author property. - * - * @param value allowed object is - * {@link String } - */ - public void setAuthor(String value) - { - this.author = value; - } - - /** - * Gets the value of the content property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the content property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getContent().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link String } - * {@link JAXBElement }{@code <}{@link Comment.Value }{@code >} - * {@link JAXBElement }{@code <}{@link String }{@code >} - */ - public List getContent() - { - if (content == null) { - content = new ArrayList(); - } - return this.content; - } - - /** - * Gets the value of the created property. - * - * @return possible object is - * {@link Long } - */ - public Long getCreated() - { - return created; - } - - /** - * Sets the value of the created property. - * - * @param value allowed object is - * {@link Long } - */ - public void setCreated(Long value) - { - this.created = value; - } - - /** - * Gets the value of the deleted property. - * - * @return possible object is - * {@link String } - */ - public String getDeleted() - { - return deleted; - } - - /** - * Sets the value of the deleted property. - * - * @param value allowed object is - * {@link String } - */ - public void setDeleted(String value) - { - this.deleted = value; - } - - /** - * Gets the value of the id property. - * - * @return possible object is - * {@link String } - */ - public String getId() - { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value allowed object is - * {@link String } - */ - public void setId(String value) - { - this.id = value; - } - - /** - * Gets the value of the issueId property. - * - * @return possible object is - * {@link String } - */ - public String getIssueId() - { - return issueId; - } - - /** - * Sets the value of the issueId property. - * - * @param value allowed object is - * {@link String } - */ - public void setIssueId(String value) - { - this.issueId = value; - } - - /** - * Gets the value of the name property. - * - * @return possible object is - * {@link String } - */ - public String getName() - { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value allowed object is - * {@link String } - */ - public void setName(String value) - { - this.name = value; - } - - /** - * Gets the value of the shownForIssueAuthor property. - * - * @return possible object is - * {@link String } - */ - public String getShownForIssueAuthor() - { - return shownForIssueAuthor; - } - - /** - * Sets the value of the shownForIssueAuthor property. - * - * @param value allowed object is - * {@link String } - */ - public void setShownForIssueAuthor(String value) - { - this.shownForIssueAuthor = value; - } - - /** - * Gets the value of the text property. - * - * @return possible object is - * {@link String } - */ - public String getText() - { - return text; - } - - /** - * Sets the value of the text property. - * - * @param value allowed object is - * {@link String } - */ - public void setText(String value) - { - this.text = value; - } - - /** - * Gets the value of the updated property. - * - * @return possible object is - * {@link Long } - */ - public Long getUpdated() - { - return updated; - } - - /** - * Sets the value of the updated property. - * - * @param value allowed object is - * {@link Long } - */ - public void setUpdated(Long value) - { - this.updated = value; - } - -// -------------------------- INNER CLASSES -------------------------- - - /** - *

Java class for anonymous complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

-     * <complexType>
-     *   <simpleContent>
-     *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
-     *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
-     *       <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" />
-     *     </extension>
-     *   </simpleContent>
-     * </complexType>
-     * 
- */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"value"}) - public static class Value { -// ------------------------------ FIELDS ------------------------------ - - @XmlAttribute - protected String role; - - @XmlAttribute - protected String type; - - @XmlValue - protected String value; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the role property. - * - * @return possible object is - * {@link String } - */ - public String getRole() - { - return role; - } - - /** - * Sets the value of the role property. - * - * @param value allowed object is - * {@link String } - */ - public void setRole(String value) - { - this.role = value; - } - - /** - * Gets the value of the type property. - * - * @return possible object is - * {@link String } - */ - public String getType() - { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value allowed object is - * {@link String } - */ - public void setType(String value) - { - this.type = value; - } - - /** - * Gets the value of the value property. - * - * @return possible object is - * {@link String } - */ - public String getValue() - { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value allowed object is - * {@link String } - */ - public void setValue(String value) - { - this.value = value; - } - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Enumeration.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/Enumeration.java deleted file mode 100644 index 9913204..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Enumeration.java +++ /dev/null @@ -1,96 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; -import java.util.ArrayList; -import java.util.List; - -/** - *

Java class for enumerationType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="enumerationType">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="value" type="{}enumerationValueType" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "enumerationType", propOrder = {"values"}) -public class Enumeration { -// ------------------------------ FIELDS ------------------------------ - - @XmlAttribute - protected String name; - - @XmlElement(name = "value") - protected List values; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the name property. - * - * @return possible object is - * {@link String } - */ - public String getName() - { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value allowed object is - * {@link String } - */ - public void setName(String value) - { - this.name = value; - } - - /** - * Gets the value of the values property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the values property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getValues().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link EnumerationValue } - */ - public List getValues() - { - if (values == null) { - values = new ArrayList(); - } - return this.values; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/EnumerationValue.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/EnumerationValue.java deleted file mode 100644 index cea1aba..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/EnumerationValue.java +++ /dev/null @@ -1,85 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; - -/** - *

Java class for enumerationValueType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="enumerationValueType">
- *   <simpleContent>
- *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
- *       <attribute name="colorIndex" type="{http://www.w3.org/2001/XMLSchema}long" />
- *     </extension>
- *   </simpleContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "enumerationValueType", propOrder = {"value"}) -public class EnumerationValue { -// ------------------------------ FIELDS ------------------------------ - - @XmlAttribute - protected Long colorIndex; - - @XmlValue - protected String value; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the colorIndex property. - * - * @return possible object is - * {@link Long } - */ - public Long getColorIndex() - { - return colorIndex; - } - - /** - * Sets the value of the colorIndex property. - * - * @param value allowed object is - * {@link Long } - */ - public void setColorIndex(Long value) - { - this.colorIndex = value; - } - - /** - * Gets the value of the value property. - * - * @return possible object is - * {@link String } - */ - public String getValue() - { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value allowed object is - * {@link String } - */ - public void setValue(String value) - { - this.value = value; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Field.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/Field.java deleted file mode 100644 index bbeeb43..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Field.java +++ /dev/null @@ -1,207 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import java.util.ArrayList; -import java.util.List; - -/** - *

Java class for fieldType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="fieldType">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence maxOccurs="unbounded" minOccurs="0">
- *         <element name="value">
- *           <complexType>
- *             <complexContent>
- *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                 <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
- *                 <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" />
- *               </restriction>
- *             </complexContent>
- *           </complexType>
- *         </element>
- *       </sequence>
- *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "fieldType", propOrder = {"values"}) -public class Field { -// ------------------------------ FIELDS ------------------------------ - - @XmlAttribute - protected String name; - - @XmlElement(name = "value") - protected List values; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the name property. - * - * @return possible object is - * {@link String } - */ - public String getName() - { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value allowed object is - * {@link String } - */ - public void setName(String value) - { - this.name = value; - } - - /** - * Gets the value of the values property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the values property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getValues().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Field.Value } - */ - public List getValues() - { - if (values == null) { - values = new ArrayList(); - } - return this.values; - } - -// -------------------------- INNER CLASSES -------------------------- - - /** - *

Java class for anonymous complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

-     * <complexType>
-     *   <complexContent>
-     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
-     *       <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" />
-     *     </restriction>
-     *   </complexContent>
-     * </complexType>
-     * 
- */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"content"}) - public static class Value { -// ------------------------------ FIELDS ------------------------------ - - @XmlValue - protected String content; - - @XmlAttribute - protected String role; - - @XmlAttribute - protected String type; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the content property. - * - * @return possible object is - * {@link String } - */ - public String getContent() - { - return content; - } - - /** - * Sets the value of the content property. - * - * @param value allowed object is - * {@link String } - */ - public void setContent(String value) - { - this.content = value; - } - - /** - * Gets the value of the role property. - * - * @return possible object is - * {@link String } - */ - public String getRole() - { - return role; - } - - /** - * Sets the value of the role property. - * - * @param value allowed object is - * {@link String } - */ - public void setRole(String value) - { - this.role = value; - } - - /** - * Gets the value of the type property. - * - * @return possible object is - * {@link String } - */ - public String getType() - { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value allowed object is - * {@link String } - */ - public void setType(String value) - { - this.type = value; - } - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issue.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issue.java deleted file mode 100644 index 3359438..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issue.java +++ /dev/null @@ -1,99 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; -import javax.xml.bind.annotation.XmlType; -import java.util.ArrayList; -import java.util.List; - -/** - *

Java class for issueType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="issueType">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <choice maxOccurs="unbounded" minOccurs="0">
- *         <element name="field" type="{}fieldType"/>
- *         <element name="comment" type="{}commentType"/>
- *       </choice>
- *       <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "issueType", propOrder = {"fieldOrComment"}) -public class Issue { -// ------------------------------ FIELDS ------------------------------ - - @XmlElements({@XmlElement(name = "comment", type = Comment.class), @XmlElement(name = "field", type = Field.class)}) - protected List fieldOrComment; - - @XmlAttribute - protected String id; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the fieldOrComment property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the fieldOrComment property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getFieldOrComment().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Comment } - * {@link Field } - */ - public List getFieldOrComment() - { - if (fieldOrComment == null) { - fieldOrComment = new ArrayList(); - } - return this.fieldOrComment; - } - - /** - * Gets the value of the id property. - * - * @return possible object is - * {@link String } - */ - public String getId() - { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value allowed object is - * {@link String } - */ - public void setId(String value) - { - this.id = value; - } -} 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 deleted file mode 100644 index f2b4c53..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java +++ /dev/null @@ -1,71 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import java.util.ArrayList; -import java.util.List; - -/** - *

Java class for anonymous complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence maxOccurs="unbounded" minOccurs="0">
- *         <element name="issue" type="{}issueType"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = {"issues"}) -@XmlRootElement(name = "issues") -public class Issues { -// ------------------------------ FIELDS ------------------------------ - - @XmlElement(name = "issue") - protected List issues; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the issues property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the issues property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getIssues().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Issue } - */ - public List getIssues() - { - if (issues == null) { - issues = new ArrayList(); - } - return this.issues; - } -} 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 deleted file mode 100644 index f0a10a1..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java +++ /dev/null @@ -1,226 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the pl.com.it_crowd.youtrack.api.rest package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - */ -@XmlRegistry -public class ObjectFactory { -// ------------------------------ FIELDS ------------------------------ - - private final static QName _CommentReplies_QNAME = new QName("", "replies"); - - private final static QName _CommentValue_QNAME = new QName("", "value"); - - private final static QName _Enumeration_QNAME = new QName("", "enumeration"); - - private final static QName _Error_QNAME = new QName("", "error"); - - private final static QName _Int_QNAME = new QName("", "int"); - - private final static QName _Issue_QNAME = new QName("", "issue"); - -// --------------------------- CONSTRUCTORS --------------------------- - - /** - * 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() - { - } - -// -------------------------- OTHER METHODS -------------------------- - - /** - * Create an instance of {@link AssignedByType } - */ - public AssignedByType createAssignedByType() - { - return new AssignedByType(); - } - - /** - * Create an instance of {@link AssigneeList } - */ - public AssigneeList createAssigneeList() - { - return new AssigneeList(); - } - - /** - * Create an instance of {@link AssigneeList.Assignees } - */ - public AssigneeList.Assignees createAssigneeListAssignees() - { - return new AssigneeList.Assignees(); - } - - /** - * Create an instance of {@link AssigneeType } - */ - public AssigneeType createAssigneeType() - { - return new AssigneeType(); - } - - /** - * Create an instance of {@link Comment } - */ - public Comment createComment() - { - return new Comment(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} - */ - @XmlElementDecl(namespace = "", name = "replies", scope = Comment.class) - public JAXBElement createCommentReplies(String value) - { - return new JAXBElement(_CommentReplies_QNAME, String.class, Comment.class, value); - } - - /** - * Create an instance of {@link Comment.Value } - */ - public Comment.Value createCommentValue() - { - return new Comment.Value(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Comment.Value }{@code >}} - */ - @XmlElementDecl(namespace = "", name = "value", scope = Comment.class) - public JAXBElement createCommentValue(Comment.Value value) - { - return new JAXBElement(_CommentValue_QNAME, Comment.Value.class, Comment.class, value); - } - - /** - * Create an instance of {@link Enumeration } - */ - public Enumeration createEnumeration() - { - return new Enumeration(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Enumeration }{@code >}} - */ - @XmlElementDecl(namespace = "", name = "enumeration") - public JAXBElement createEnumeration(Enumeration value) - { - return new JAXBElement(_Enumeration_QNAME, Enumeration.class, null, value); - } - - /** - * Create an instance of {@link EnumerationValue } - */ - public EnumerationValue createEnumerationValue() - { - return new EnumerationValue(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} - */ - @XmlElementDecl(namespace = "", name = "error") - public JAXBElement createError(String value) - { - return new JAXBElement(_Error_QNAME, String.class, null, value); - } - - /** - * Create an instance of {@link Field } - */ - public Field createField() - { - return new Field(); - } - - /** - * Create an instance of {@link Field.Value } - */ - public Field.Value createFieldValue() - { - return new Field.Value(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Short }{@code >}} - */ - @XmlElementDecl(namespace = "", name = "int") - public JAXBElement createInt(Short value) - { - return new JAXBElement(_Int_QNAME, Short.class, null, value); - } - - /** - * Create an instance of {@link Issue } - */ - public Issue createIssue() - { - return new Issue(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Issue }{@code >}} - */ - @XmlElementDecl(namespace = "", name = "issue") - public JAXBElement createIssue(Issue value) - { - return new JAXBElement(_Issue_QNAME, Issue.class, null, value); - } - - /** - * Create an instance of {@link Issues } - */ - public Issues createIssues() - { - return new Issues(); - } - - /** - * Create an instance of {@link User } - */ - public User createUser() - { - return new User(); - } - - /** - * Create an instance of {@link UserGroupRefType } - */ - public UserGroupRefType createUserGroupRefType() - { - return new UserGroupRefType(); - } - - /** - * Create an instance of {@link UserRefs } - */ - public UserRefs createUserRefs() - { - return new UserRefs(); - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/User.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/User.java deleted file mode 100644 index b90f64b..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/User.java +++ /dev/null @@ -1,87 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; - -/** - *

Java class for userType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="userType">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <attribute name="login" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="url" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "userType") -public class User { -// ------------------------------ FIELDS ------------------------------ - - @XmlAttribute(required = true) - protected String login; - - @XmlAttribute - @XmlSchemaType(name = "anyURI") - protected String url; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the login property. - * - * @return possible object is - * {@link String } - */ - public String getLogin() - { - return login; - } - - /** - * Sets the value of the login property. - * - * @param value allowed object is - * {@link String } - */ - public void setLogin(String value) - { - this.login = value; - } - - /** - * Gets the value of the url property. - * - * @return possible object is - * {@link String } - */ - public String getUrl() - { - return url; - } - - /** - * Sets the value of the url property. - * - * @param value allowed object is - * {@link String } - */ - public void setUrl(String value) - { - this.url = value; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/UserGroupRefType.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/UserGroupRefType.java deleted file mode 100644 index abe00d7..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/UserGroupRefType.java +++ /dev/null @@ -1,111 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; - -/** - *

Java class for userGroupRefType complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="userGroupRefType">
- *   <simpleContent>
- *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
- *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="url" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </extension>
- *   </simpleContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "userGroupRefType", propOrder = {"value"}) -public class UserGroupRefType { -// ------------------------------ FIELDS ------------------------------ - - @XmlAttribute - protected String name; - - @XmlAttribute - protected String url; - - @XmlValue - protected String value; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the name property. - * - * @return possible object is - * {@link String } - */ - public String getName() - { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value allowed object is - * {@link String } - */ - public void setName(String value) - { - this.name = value; - } - - /** - * Gets the value of the url property. - * - * @return possible object is - * {@link String } - */ - public String getUrl() - { - return url; - } - - /** - * Sets the value of the url property. - * - * @param value allowed object is - * {@link String } - */ - public void setUrl(String value) - { - this.url = value; - } - - /** - * Gets the value of the value property. - * - * @return possible object is - * {@link String } - */ - public String getValue() - { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value allowed object is - * {@link String } - */ - public void setValue(String value) - { - this.value = value; - } -} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/UserRefs.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/UserRefs.java deleted file mode 100644 index c515d04..0000000 --- a/src/main/java/pl/com/it_crowd/youtrack/api/rest/UserRefs.java +++ /dev/null @@ -1,71 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// -package pl.com.it_crowd.youtrack.api.rest; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import java.util.ArrayList; -import java.util.List; - -/** - *

Java class for anonymous complex type. - *

- *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="user" type="{}userType" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = {"users"}) -@XmlRootElement(name = "userRefs") -public class UserRefs { -// ------------------------------ FIELDS ------------------------------ - - @XmlElement(name = "user") - protected List users; - -// --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Gets the value of the users property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the users property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getUsers().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link User } - */ - public List getUsers() - { - if (users == null) { - users = new ArrayList(); - } - return this.users; - } -} diff --git a/src/main/java/pl/it_crowd/youtrack/api/Command.java b/src/main/java/pl/it_crowd/youtrack/api/Command.java new file mode 100644 index 0000000..a7c1194 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/Command.java @@ -0,0 +1,67 @@ +package pl.it_crowd.youtrack.api; + +import pl.it_crowd.youtrack.api.defaults.Fields; +import pl.it_crowd.youtrack.api.defaults.StateValues; + +public class Command { +// ------------------------------ FIELDS ------------------------------ + + protected StringBuilder command = new StringBuilder(); + +// -------------------------- STATIC METHODS -------------------------- + + public static Command assigneeCommand(String assignee) + { + return new Command().assignee(assignee); + } + + public static Command stateCommand(String state) + { + return new Command().state(state); + } + + public static Command stateCommand(StateValues state) + { + return new Command().state(state); + } + +// --------------------------- CONSTRUCTORS --------------------------- + + protected Command() + { + } + +// ------------------------ CANONICAL METHODS ------------------------ + + @Override + public String toString() + { + return command.toString().trim(); + } + +// -------------------------- OTHER METHODS -------------------------- + + public Command assignee(String assignee) + { + return command(Fields.assignee, assignee); + } + + public Command state(String state) + { + return command(Fields.state, state); + } + + public Command state(StateValues state) + { + if (state.getCommandValue() == null) { + throw new IllegalArgumentException("Cannot set readonly state: " + state); + } + return state(state.getCommandValue()); + } + + protected Command command(Commander commander, String argument) + { + this.command.append(" ").append(commander.getCommand()).append(" ").append(argument); + return this; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/Commander.java b/src/main/java/pl/it_crowd/youtrack/api/Commander.java new file mode 100644 index 0000000..f9d7495 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/Commander.java @@ -0,0 +1,7 @@ +package pl.it_crowd.youtrack.api; + +public interface Commander { +// -------------------------- OTHER METHODS -------------------------- + + String getCommand(); +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/ErrorUnmarshaller.java b/src/main/java/pl/it_crowd/youtrack/api/ErrorUnmarshaller.java new file mode 100644 index 0000000..488a538 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/ErrorUnmarshaller.java @@ -0,0 +1,42 @@ +package pl.it_crowd.youtrack.api; + +import org.apache.commons.io.IOUtils; +import pl.it_crowd.youtrack.api.rest.ObjectFactory; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; + +//TODO methods from this class should be probably merged with YoutrackUnmarshaller +public final class ErrorUnmarshaller { +// -------------------------- STATIC METHODS -------------------------- + + public static String unmarshal(String string) throws JAXBException, IOException + { + return unmarshal(new StringReader(string)); + } + + public static String unmarshal(Reader reader) throws JAXBException, IOException + { + String content = IOUtils.toString(reader); + try { + JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); + @SuppressWarnings("unchecked") + final JAXBElement element = (JAXBElement) jaxbContext.createUnmarshaller().unmarshal(new StringReader(content)); + return element.getValue(); + } catch (JAXBException e) { +// TODO we need logging here + System.err.println("Cannot unmarshal input stream.\n" + content + e); + throw e; + } + } + +// --------------------------- CONSTRUCTORS --------------------------- + + private ErrorUnmarshaller() + { + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/Filter.java b/src/main/java/pl/it_crowd/youtrack/api/Filter.java new file mode 100644 index 0000000..80c2b6c --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/Filter.java @@ -0,0 +1,255 @@ +package pl.it_crowd.youtrack.api; + +import pl.it_crowd.youtrack.api.defaults.DateValues; +import pl.it_crowd.youtrack.api.defaults.Fields; +import pl.it_crowd.youtrack.api.defaults.StateValues; + +import java.util.ArrayList; +import java.util.List; + +public final class Filter { +// ------------------------------ FIELDS ------------------------------ + + private long after; + + private List conditions = new ArrayList(); + + private long maxResults; + +// -------------------------- STATIC METHODS -------------------------- + + public static Filter createdFilter(String date) + { + return new Filter().created(date); + } + + public static Filter createdFilter(DateValues date) + { + return new Filter().created(date); + } + + public static Filter descriptionFilter(String description) + { + return new Filter().description(description); + } + + public static Filter issueIdFilter(String issueId) + { + return new Filter().issueId(issueId); + } + + public static Filter projectFilter(String project) + { + return new Filter().project(project); + } + + public static Filter reporterFilter(String reporter) + { + return new Filter().reporter(reporter); + } + + public static Filter resolvedFilter(String date) + { + return new Filter().resolved(date); + } + + public static Filter resolvedFilter(DateValues date) + { + return new Filter().resolved(date); + } + + public static Filter stateFilter(StateValues... state) + { + return new Filter().state(state); + } + + public static Filter stateFilter(String state) + { + return new Filter().state(state); + } + + public static Filter summaryFilter(String summary) + { + return new Filter().summary(summary); + } + + public static Filter unresolvedFilter() + { + return new Filter().unresolved(); + } + + public static Filter updatedFilter(String date) + { + return new Filter().updated(date); + } + + public static Filter updatedFilter(DateValues date) + { + return new Filter().updated(date); + } + + public static Filter updaterFilter(String updater) + { + return new Filter().updater(updater); + } + +// --------------------------- CONSTRUCTORS --------------------------- + + private Filter() + { + + } + +// ------------------------ CANONICAL METHODS ------------------------ + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(); + String space = " "; + for (Condition condition : conditions) { + builder.append(space); + if (condition.field != null) { + builder.append(condition.field.getCommand()); + builder.append(":"); + } + builder.append(condition.value); + } + if (maxResults > 0) { + builder.append("&max=").append(maxResults); + } + if (after > 0) { + builder.append("&after=").append(after); + } + return builder.length() > space.length() ? builder.substring(space.length()) : builder.toString(); + } + +// -------------------------- OTHER METHODS -------------------------- + + public Filter after(long after) + { + this.after = after; + return this; + } + + public Filter created(DateValues date) + { + return created(date.getFilterValue()); + } + + public Filter created(String date) + { + conditions.add(new Condition(Fields.created, date)); + return this; + } + + public Filter description(String description) + { + conditions.add(new Condition(Fields.description, description)); + return this; + } + + public Filter freeText(String text) + { + conditions.add(new Condition(null, text)); + return this; + } + + public Filter issueId(String issueId) + { + conditions.add(new Condition(Fields.issueId, issueId)); + return this; + } + + public Filter maxResults(long maxResults) + { + this.maxResults = maxResults; + return this; + } + + public Filter project(String project) + { + conditions.add(new Condition(Fields.projectShortName, project)); + return this; + } + + public Filter reporter(String reporter) + { + conditions.add(new Condition(Fields.reporterName, reporter)); + return this; + } + + public Filter resolved(DateValues date) + + { + return resolved(date.getFilterValue()); + } + + public Filter resolved(String date) + { + conditions.add(new Condition(Fields.resolved, date)); + return this; + } + + public Filter state(StateValues... state) + { + final StringBuilder stringBuilder = new StringBuilder(); + for (StateValues value : state) { + stringBuilder.append(",").append(value.getFilterValue()); + } + return state(stringBuilder.length() > 0 ? stringBuilder.substring(1) : stringBuilder.toString()); + } + + public Filter summary(String summary) + { + conditions.add(new Condition(Fields.summary, summary)); + return this; + } + + public Filter unresolved() + { + conditions.add(new Condition(Fields.state, StateValues.Unresolved.getFilterValue())); + return this; + } + + public Filter updated(DateValues date) + { + return updated(date.getFilterValue()); + } + + public Filter updated(String date) + { + conditions.add(new Condition(Fields.updated, date)); + return this; + } + + public Filter updater(String updater) + { + conditions.add(new Condition(Fields.updaterName, updater)); + return this; + } + + private Filter state(String state) + { + conditions.add(new Condition(Fields.state, state)); + return this; + } + +// -------------------------- INNER CLASSES -------------------------- + + private class Condition { +// ------------------------------ FIELDS ------------------------------ + + private Fields field; + + private String value; + +// --------------------------- CONSTRUCTORS --------------------------- + + private Condition(Fields field, String value) + { + this.field = field; + this.value = value; + } + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/IssueWrapper.java b/src/main/java/pl/it_crowd/youtrack/api/IssueWrapper.java new file mode 100644 index 0000000..32dd93e --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/IssueWrapper.java @@ -0,0 +1,78 @@ +package pl.it_crowd.youtrack.api; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import pl.it_crowd.youtrack.api.defaults.Fields; +import pl.it_crowd.youtrack.api.rest.Comment; +import pl.it_crowd.youtrack.api.rest.Field; +import pl.it_crowd.youtrack.api.rest.Issue; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class IssueWrapper implements Serializable { +// ------------------------------ FIELDS ------------------------------ + + private static final Log log = LogFactory.getLog(IssueWrapper.class); + + private List comments; + + private Map fieldMap; + + private Issue issue; + +// --------------------------- CONSTRUCTORS --------------------------- + + public IssueWrapper(Issue issue) + { + this.issue = issue; + fieldMap = new HashMap(); + comments = new ArrayList(); + for (Object o : issue.getFieldOrComment()) { + if (o instanceof Field) { + Field field = (Field) o; + fieldMap.put(field.getName().toLowerCase(), field); + } else if (o instanceof Comment) { + comments.add((Comment) o); + } else { + log.warn("Object " + o + " is not Field nor Coment"); + } + } + } + +// -------------------------- OTHER METHODS -------------------------- + + public List getComments() + { + return Collections.unmodifiableList(comments); + } + + public Field getField(String field) + { + return fieldMap.get(field); + } + + public String getFieldValue(String fieldName) + { + Field field = getField(fieldName.toLowerCase()); + if (field == null) { + return null; + } + List values = field.getValues(); + return values.isEmpty() ? null : values.get(0).getContent(); + } + + public String getFieldValue(Fields field) + { + return getFieldValue(field.name()); + } + + public String getId() + { + return issue.getId(); + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/URIUtils.java b/src/main/java/pl/it_crowd/youtrack/api/URIUtils.java new file mode 100644 index 0000000..4d3ef73 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/URIUtils.java @@ -0,0 +1,23 @@ +package pl.it_crowd.youtrack.api; + +import java.net.URI; +import java.net.URISyntaxException; + +public class URIUtils { +// -------------------------- STATIC METHODS -------------------------- + + public static URI buildURI(URI base, String path) + { + return buildURI(base, path, null); + } + + public static URI buildURI(URI base, String path, String query) + { + try { + return new URI(base.getScheme(), base.getUserInfo(), base.getHost(), base.getPort(), base.getPath().replaceAll("/+$", "") + path, query, + base.getFragment()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/YoutrackAPI.java b/src/main/java/pl/it_crowd/youtrack/api/YoutrackAPI.java new file mode 100644 index 0000000..10e6e01 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/YoutrackAPI.java @@ -0,0 +1,389 @@ +package pl.it_crowd.youtrack.api; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.StatusLine; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.HttpResponseException; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.conn.PoolingClientConnectionManager; +import org.apache.http.impl.conn.SchemeRegistryFactory; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import pl.it_crowd.youtrack.api.defaults.Fields; +import pl.it_crowd.youtrack.api.exceptions.NoResultFoundException; +import pl.it_crowd.youtrack.api.exceptions.YoutrackAPIException; +import pl.it_crowd.youtrack.api.exceptions.YoutrackErrorException; +import pl.it_crowd.youtrack.api.rest.AssigneeList; +import pl.it_crowd.youtrack.api.rest.Enumeration; +import pl.it_crowd.youtrack.api.rest.Issue; +import pl.it_crowd.youtrack.api.rest.Issues; +import pl.it_crowd.youtrack.api.rest.User; +import pl.it_crowd.youtrack.api.rest.UserRefs; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static pl.it_crowd.youtrack.api.URIUtils.buildURI; + +public class YoutrackAPI { +// ------------------------------ FIELDS ------------------------------ + + private final static QName Enumeration_QNAME = new QName("", "enumeration"); + + private final static QName Issue_QNAME = new QName("", "issue"); + + private static Log LOG = LogFactory.getLog(YoutrackAPI.class); + + private HttpClient httpClient; + + private String serviceLocation; + + private URI serviceLocationURI; + +// -------------------------- STATIC METHODS -------------------------- + + private static HttpClient getDefaultHttpClient() + { + SSLContext sslContext; + try { + sslContext = SSLContext.getInstance("SSL"); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + // set up a TrustManager that trusts everything + try { + sslContext.init(null, new TrustManager[]{new X509TrustManager() { + public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException + { + } + + public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException + { + } + + public X509Certificate[] getAcceptedIssuers() + { + return new X509Certificate[0]; + } + }}, new SecureRandom()); + } catch (KeyManagementException e) { + throw new RuntimeException(e); + } + + SSLSocketFactory sf = new SSLSocketFactory(sslContext); + Scheme httpsScheme = new Scheme("https", 443, sf); + SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault(); + schemeRegistry.register(schemeRegistry.unregister("https")); + schemeRegistry.register(httpsScheme); + + ClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); + return new DefaultHttpClient(cm); + } + + private static boolean isBlank(String str) + { + int strLen; + if (str == null || (strLen = str.length()) == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if ((!Character.isWhitespace(str.charAt(i)))) { + return false; + } + } + return true; + } + +// --------------------------- CONSTRUCTORS --------------------------- + + public YoutrackAPI(String serviceLocation) + { + this(serviceLocation, null); + } + + public YoutrackAPI(String serviceLocation, HttpClient httpClient) + { + if (serviceLocation == null) { + throw new IllegalArgumentException("serviceLocation cannot be null"); + } + this.serviceLocation = serviceLocation; + try { + serviceLocationURI = new URI(this.serviceLocation); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + this.httpClient = httpClient == null ? getDefaultHttpClient() : httpClient; + } + + public YoutrackAPI(String serviceLocation, String username, String password) throws IOException, JAXBException + { + this(serviceLocation, null, username, password); + } + + public YoutrackAPI(String serviceLocation, HttpClient httpClient, String username, String password) throws IOException, JAXBException + { + this(serviceLocation, httpClient); + login(username, password); + } + +// --------------------- GETTER / SETTER METHODS --------------------- + + public String getServiceLocation() + { + return serviceLocation; + } + +// -------------------------- OTHER METHODS -------------------------- + + public void command(String issueId, String command) throws IOException + { + command(issueId, command, null, null, null, null); + } + + public void command(String issueId, Command command) throws IOException + { + command(issueId, command.toString()); + } + + public void command(String issueId, String command, String comment, String group, Boolean disableNotifications, String runAs) throws IOException + { + final HttpPost request = new HttpPost(buildURI(serviceLocationURI, "/rest/issue/" + issueId + "/execute")); + final List parameters = new ArrayList(); + parameters.add(new BasicNameValuePair("command", command)); + if (!isBlank(comment)) { + parameters.add(new BasicNameValuePair("comment", comment)); + } + if (!isBlank(group)) { + parameters.add(new BasicNameValuePair("group", group)); + } + if (disableNotifications != null) { + parameters.add(new BasicNameValuePair("disableNotifications", disableNotifications.toString())); + } + if (!isBlank(runAs)) { + parameters.add(new BasicNameValuePair("runAs", runAs)); + } + request.setEntity(new UrlEncodedFormEntity(parameters)); + execute(request); + } + + /** + * Creates new issue on Youtrack. + * + * @param project project to create issue in + * @param summary summary of the issue + * @param description longer description of the issue + * + * @return issue id of created issue + * + * @throws IOException in case of communication problems + */ + public String createIssue(String project, String summary, String description) throws IOException + { + final HttpPut request = createPutRequest(buildURI(serviceLocationURI, "/rest/issue"), new BasicNameValuePair("project", project), + new BasicNameValuePair("summary", summary), new BasicNameValuePair("description", description)); + final HttpResponse response = httpClient.execute(request); + final StatusLine statusLine = response.getStatusLine(); + final HttpEntity entity = response.getEntity(); + final String responseText = entity == null ? null : EntityUtils.toString(entity); + throwExceptionsIfNeeded(statusLine, responseText); + + final Header header = response.getFirstHeader(HttpHeaders.LOCATION); + if (header == null) { + throw new YoutrackAPIException("Missing location header despite positive status code: " + statusLine.getStatusCode()); + } + final String issueURL = header.getValue(); + final Matcher matcher = Pattern.compile(".*(" + project + "-\\d+)").matcher(issueURL); + if (!matcher.find() || matcher.groupCount() < 1) { + throw new YoutrackAPIException("Cannot extract issue id from issue URL: " + issueURL); + } + return matcher.group(1); + } + + public void deleteIssue(String issueId) throws IOException + { + execute(new HttpDelete(buildURI(serviceLocationURI, "/rest/issue/" + issueId))); + } + + public AssigneeList getAssignees(String project) throws IOException, JAXBException + { + final String responseString = execute(new HttpGet(buildURI(serviceLocationURI, "/rest/admin/project/" + project + "/assignee"))); + final Object result = YoutrackUnmarshaller.unmarshall(responseString); + if (result instanceof AssigneeList) { + return (AssigneeList) result; + } else { + throw new YoutrackAPIException("Unexpected type: " + result); + } + } + + public Enumeration getBundle(String customField) throws IOException, JAXBException + { + final Object result = YoutrackUnmarshaller.unmarshall(execute(new HttpGet(buildURI(serviceLocationURI, "/rest/admin/customfield/bundle/" + customField)))); + if (result instanceof Enumeration) { + return (Enumeration) result; + } else if (result instanceof JAXBElement) { + final JAXBElement jaxbElement = (JAXBElement) result; + if (Enumeration_QNAME.equals(jaxbElement.getName())) { + return (Enumeration) ((JAXBElement) result).getValue(); + } else { + throw new YoutrackAPIException("Unexpected type: " + jaxbElement.getValue()); + } + } else { + throw new YoutrackAPIException("Unexpected type: " + result); + } + } + + public List getIndividualAssignees(String project) throws IOException, JAXBException + { + final String responseString = execute(new HttpGet(buildURI(serviceLocationURI, "/rest/admin/project/" + project + "/assignee/individual"))); + final Object result = YoutrackUnmarshaller.unmarshall(responseString); + if (result instanceof UserRefs) { + return ((UserRefs) result).getUsers(); + } else { + throw new YoutrackAPIException("Unexpected type: " + result); + } + } + + public IssueWrapper getIssue(String issueId) throws IOException, JAXBException + { + final String responseString; + try { + responseString = execute(new HttpGet(buildURI(serviceLocationURI, "/rest/issue/" + issueId))); + } catch (YoutrackErrorException e) { + if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { + throw new NoResultFoundException(e.getMessage(), e); + } else { + throw e; + } + } + final Object result = YoutrackUnmarshaller.unmarshall(responseString); + if (result instanceof pl.it_crowd.youtrack.api.rest.Issue) { + return new IssueWrapper((Issue) result); + } else if (result instanceof JAXBElement) { + final JAXBElement jaxbElement = (JAXBElement) result; + if (Issue_QNAME.equals(jaxbElement.getName())) { + return new IssueWrapper((Issue) jaxbElement.getValue()); + } else { + throw new YoutrackAPIException("Unexpected type: " + jaxbElement.getValue()); + } + } else { + throw new YoutrackAPIException("Unexpected type " + result); + } + } + + public void login(String username, String password) throws IOException, JAXBException + { + final HttpPost request = new HttpPost(buildURI(serviceLocationURI, "/rest/user/login")); + request.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair("login", username), new BasicNameValuePair("password", password)))); + execute(request); + } + + public List searchIssuesByProject(String project, Object filter) throws JAXBException, IOException + { + final Object result = YoutrackUnmarshaller.unmarshall( + execute(new HttpGet(buildURI(serviceLocationURI, "/rest/issue/byproject/" + project, "filter=" + (filter == null ? "" : filter))))); + if (!(result instanceof Issues)) { + throw new YoutrackAPIException("Unmarshalling problem. Expected Issues, received: " + result.getClass() + " " + result); + } + List issues = ((Issues) result).getIssues(); + List wrappedIssues = new ArrayList(); + for (Issue issue : issues) { + wrappedIssues.add(new IssueWrapper(issue)); + } + return wrappedIssues; + } + + public void updateIssue(String issueId, String summary, String description) throws IOException + { + final HttpPost request = createPostRequest(buildURI(serviceLocationURI, "/rest/issue/" + issueId), new BasicNameValuePair(Fields.summary.name(), summary), + new BasicNameValuePair(Fields.description.name(), description)); + final HttpResponse response = httpClient.execute(request); + final StatusLine statusLine = response.getStatusLine(); + final HttpEntity entity = response.getEntity(); + final String responseText = entity == null ? null : EntityUtils.toString(entity); + throwExceptionsIfNeeded(statusLine, responseText); + } + + private HttpPost createPostRequest(URI uri, NameValuePair... nameValuePair) throws UnsupportedEncodingException + { + return setEntity(new HttpPost(uri), nameValuePair); + } + + private HttpPut createPutRequest(URI uri, NameValuePair... nameValuePair) throws UnsupportedEncodingException + { + return setEntity(new HttpPut(uri), nameValuePair); + } + + private String execute(HttpUriRequest request) throws IOException + { + final HttpResponse response = httpClient.execute(request); + final StatusLine statusLine = response.getStatusLine(); + final HttpEntity entity = response.getEntity(); + String responseText = entity == null ? null : EntityUtils.toString(entity); + if (statusLine.getStatusCode() >= 300) { + try { + final String error = ErrorUnmarshaller.unmarshal(responseText); + throw new YoutrackErrorException(error, statusLine.getStatusCode()); + } catch (JAXBException e) { + LOG.error("Cannot unmarshal following response text:\n" + responseText, e); + throw new HttpResponseException(statusLine.getStatusCode(), responseText); + } + } + if (entity == null) { + throw new ClientProtocolException("Response contains no content"); + } + return responseText; + } + + private T setEntity(T request, NameValuePair[] nameValuePair) throws UnsupportedEncodingException + { + final ArrayList list = new ArrayList(); + Collections.addAll(list, nameValuePair); + request.setEntity(new UrlEncodedFormEntity(list)); + return request; + } + + private void throwExceptionsIfNeeded(StatusLine statusLine, String responseText) throws IOException + { + if (statusLine.getStatusCode() >= 300) { + throw new HttpResponseException(statusLine.getStatusCode(), responseText); + } + } +} \ No newline at end of file diff --git a/src/main/java/pl/it_crowd/youtrack/api/YoutrackUnmarshaller.java b/src/main/java/pl/it_crowd/youtrack/api/YoutrackUnmarshaller.java new file mode 100644 index 0000000..289c354 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/YoutrackUnmarshaller.java @@ -0,0 +1,28 @@ +package pl.it_crowd.youtrack.api; + +import pl.it_crowd.youtrack.api.rest.ObjectFactory; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import java.io.Reader; +import java.io.StringReader; + +public final class YoutrackUnmarshaller { +// -------------------------- STATIC METHODS -------------------------- + + public static Object unmarshall(String string) throws JAXBException + { + return unmarshall(new StringReader(string)); + } + + public static Object unmarshall(Reader reader) throws JAXBException + { + return JAXBContext.newInstance(ObjectFactory.class).createUnmarshaller().unmarshal(reader); + } + +// --------------------------- CONSTRUCTORS --------------------------- + + private YoutrackUnmarshaller() + { + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/defaults/DateValues.java b/src/main/java/pl/it_crowd/youtrack/api/defaults/DateValues.java new file mode 100644 index 0000000..425667b --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/defaults/DateValues.java @@ -0,0 +1,29 @@ +package pl.it_crowd.youtrack.api.defaults; + +public enum DateValues { + Today, Yesterday, Saturday, Friday, Thursday, Wednesday, Tuesday, Monday, Sunday, ThisWeek("{This week}"), LastWeek("{Last week}"), TwoWeeksAgo( + "{Two weeks ago}"), ThreeWeeksAgo("{Three weeks ago}"), ThisMonth("{This month}"), LastMonth("{Last month}"); + +// ------------------------------ FIELDS ------------------------------ + + private String filterValue; + +// --------------------------- CONSTRUCTORS --------------------------- + + private DateValues() + { + filterValue = name(); + } + + private DateValues(String filterValue) + { + this.filterValue = filterValue; + } + +// --------------------- GETTER / SETTER METHODS --------------------- + + public String getFilterValue() + { + return filterValue; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/defaults/Fields.java b/src/main/java/pl/it_crowd/youtrack/api/defaults/Fields.java new file mode 100644 index 0000000..3e2bb39 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/defaults/Fields.java @@ -0,0 +1,44 @@ +package pl.it_crowd.youtrack.api.defaults; + +import pl.it_crowd.youtrack.api.Commander; + +public enum Fields implements Commander { + assignee, + issueId("issue id"), + state, + created("created"), + description, + numberInProject(null), + projectShortName("project"), + reporterName("reporter"), + resolved("resolved date"), + summary, + updated, + updaterName("updated by"); + +// ------------------------------ FIELDS ------------------------------ + + private String command; + +// --------------------------- CONSTRUCTORS --------------------------- + + private Fields() + { + command = name(); + } + + private Fields(String command) + { + this.command = command; + } + +// --------------------- GETTER / SETTER METHODS --------------------- + + public String getCommand() + { + if (command == null) { + throw new UnsupportedOperationException("There is no command for field: " + name()); + } + return command; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/defaults/StateValues.java b/src/main/java/pl/it_crowd/youtrack/api/defaults/StateValues.java new file mode 100644 index 0000000..ea4579a --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/defaults/StateValues.java @@ -0,0 +1,89 @@ +package pl.it_crowd.youtrack.api.defaults; + +public enum StateValues { + Submitted, + Open, + InProgress("{In Progress}", "In Progress"), + ToBeDiscussed("{To be discussed}", "To be discussed"), + Reopened, + CantReproduce("{Can't Reproduce}", "Can't Reproduce"), + Duplicate, + Fixed, + WontFix("{Won't fix}", "Won't fix"), + Incomplete, + Obsolete, + Verified, + New, + NotSubmitted(true, Submitted), + NotOpen(true, Open), + NotInProgress(true, InProgress), + NotToBeDiscussed(true, ToBeDiscussed), + NotReopened(true, Reopened), + NotCantReproduce(true, CantReproduce), + NotDuplicate(true, Duplicate), + NotFixed(true, Fixed), + NotWontFix(true, WontFix), + NotIncomplete(true, Incomplete), + NotObsolete(true, Open), + NotVerified(true, Verified), + NotNew(true, New), + Resolved("Resolved", null), + Unresolved("Unresolved", null); + +// ------------------------------ FIELDS ------------------------------ + + private String commandValue; + + private String filterValue; + + private boolean not; + +// --------------------------- CONSTRUCTORS --------------------------- + + private StateValues() + { + this(false); + } + + private StateValues(boolean not) + { + this(not, null, null); + } + + private StateValues(String filterValue, String commandValue) + { + this(false, filterValue, commandValue); + } + + private StateValues(boolean not, StateValues value) + { + this(not, value.getFilterValue(), value.getCommandValue()); + } + + private StateValues(boolean not, String filterValue, String commandValue) + { + this.not = not; + this.filterValue = filterValue == null ? name() : filterValue; + this.commandValue = commandValue == null ? name() : commandValue; + } + +// ------------------------ CANONICAL METHODS ------------------------ + + @Override + public String toString() + { + return getCommandValue(); + } + +// -------------------------- OTHER METHODS -------------------------- + + public String getCommandValue() + { + return (not ? "-" : "") + commandValue; + } + + public String getFilterValue() + { + return (not ? "-" : "") + filterValue; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/exceptions/NoResultFoundException.java b/src/main/java/pl/it_crowd/youtrack/api/exceptions/NoResultFoundException.java new file mode 100644 index 0000000..aa47638 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/exceptions/NoResultFoundException.java @@ -0,0 +1,10 @@ +package pl.it_crowd.youtrack.api.exceptions; + +public class NoResultFoundException extends RuntimeException { +// --------------------------- CONSTRUCTORS --------------------------- + + public NoResultFoundException(String message, Throwable cause) + { + super(message, cause); + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java b/src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java new file mode 100644 index 0000000..3e64386 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackAPIException.java @@ -0,0 +1,14 @@ +package pl.it_crowd.youtrack.api.exceptions; + +public class YoutrackAPIException extends RuntimeException { +// --------------------------- CONSTRUCTORS --------------------------- + + public YoutrackAPIException() + { + } + + public YoutrackAPIException(String message) + { + super(message); + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java b/src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java new file mode 100644 index 0000000..f8490b9 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/exceptions/YoutrackErrorException.java @@ -0,0 +1,22 @@ +package pl.it_crowd.youtrack.api.exceptions; + +public class YoutrackErrorException extends RuntimeException { +// ------------------------------ FIELDS ------------------------------ + + private int statusCode; + +// --------------------------- CONSTRUCTORS --------------------------- + + public YoutrackErrorException(String message, int statusCode) + { + super(message); + this.statusCode = statusCode; + } + +// --------------------- GETTER / SETTER METHODS --------------------- + + public int getStatusCode() + { + return statusCode; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/AssignedByType.java b/src/main/java/pl/it_crowd/youtrack/api/rest/AssignedByType.java new file mode 100644 index 0000000..1ad9eb1 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/AssignedByType.java @@ -0,0 +1,61 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

Java class for assignedByType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="assignedByType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="userGroupRef" type="{}userGroupRefType"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "assignedByType", propOrder = {"userGroupRef"}) +public class AssignedByType { +// ------------------------------ FIELDS ------------------------------ + + @XmlElement(required = true) + protected UserGroupRefType userGroupRef; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the userGroupRef property. + * + * @return possible object is + * {@link UserGroupRefType } + */ + public UserGroupRefType getUserGroupRef() + { + return userGroupRef; + } + + /** + * Sets the value of the userGroupRef property. + * + * @param value allowed object is + * {@link UserGroupRefType } + */ + public void setUserGroupRef(UserGroupRefType value) + { + this.userGroupRef = value; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeList.java b/src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeList.java new file mode 100644 index 0000000..a17ce9c --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeList.java @@ -0,0 +1,186 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + *

Java class for anonymous complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="assignees">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="assignee" type="{}assigneeType" maxOccurs="unbounded" minOccurs="0"/>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *       <attribute name="groupsUrl" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="individualsUrl" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = {"assignees"}) +@XmlRootElement(name = "assigneeList") +public class AssigneeList { +// ------------------------------ FIELDS ------------------------------ + + @XmlElement(required = true) + protected AssigneeList.Assignees assignees; + + @XmlAttribute + protected String groupsUrl; + + @XmlAttribute + protected String individualsUrl; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the assignees property. + * + * @return possible object is + * {@link AssigneeList.Assignees } + */ + public AssigneeList.Assignees getAssignees() + { + return assignees; + } + + /** + * Sets the value of the assignees property. + * + * @param value allowed object is + * {@link AssigneeList.Assignees } + */ + public void setAssignees(AssigneeList.Assignees value) + { + this.assignees = value; + } + + /** + * Gets the value of the groupsUrl property. + * + * @return possible object is + * {@link String } + */ + public String getGroupsUrl() + { + return groupsUrl; + } + + /** + * Sets the value of the groupsUrl property. + * + * @param value allowed object is + * {@link String } + */ + public void setGroupsUrl(String value) + { + this.groupsUrl = value; + } + + /** + * Gets the value of the individualsUrl property. + * + * @return possible object is + * {@link String } + */ + public String getIndividualsUrl() + { + return individualsUrl; + } + + /** + * Sets the value of the individualsUrl property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndividualsUrl(String value) + { + this.individualsUrl = value; + } + +// -------------------------- INNER CLASSES -------------------------- + + /** + *

Java class for anonymous complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <element name="assignee" type="{}assigneeType" maxOccurs="unbounded" minOccurs="0"/>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"assignees"}) + public static class Assignees { +// ------------------------------ FIELDS ------------------------------ + + @XmlElement(name = "assignee") + protected List assignees; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the assignees property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the assignees property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+         *    getAssignees().add(newItem);
+         * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link AssigneeType } + */ + public List getAssignees() + { + if (assignees == null) { + assignees = new ArrayList(); + } + return this.assignees; + } + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeType.java b/src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeType.java new file mode 100644 index 0000000..0d6af47 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/AssigneeType.java @@ -0,0 +1,114 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

Java class for assigneeType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="assigneeType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="assignedBy" type="{}assignedByType"/>
+ *       </sequence>
+ *       <attribute name="login" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="isIndividualAssignee" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "assigneeType", propOrder = {"assignedBy"}) +public class AssigneeType { +// ------------------------------ FIELDS ------------------------------ + + @XmlElement(required = true) + protected AssignedByType assignedBy; + + @XmlAttribute + protected String isIndividualAssignee; + + @XmlAttribute + protected String login; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the assignedBy property. + * + * @return possible object is + * {@link AssignedByType } + */ + public AssignedByType getAssignedBy() + { + return assignedBy; + } + + /** + * Sets the value of the assignedBy property. + * + * @param value allowed object is + * {@link AssignedByType } + */ + public void setAssignedBy(AssignedByType value) + { + this.assignedBy = value; + } + + /** + * Gets the value of the isIndividualAssignee property. + * + * @return possible object is + * {@link String } + */ + public String getIsIndividualAssignee() + { + return isIndividualAssignee; + } + + /** + * Sets the value of the isIndividualAssignee property. + * + * @param value allowed object is + * {@link String } + */ + public void setIsIndividualAssignee(String value) + { + this.isIndividualAssignee = value; + } + + /** + * Gets the value of the login property. + * + * @return possible object is + * {@link String } + */ + public String getLogin() + { + return login; + } + + /** + * Sets the value of the login property. + * + * @param value allowed object is + * {@link String } + */ + public void setLogin(String value) + { + this.login = value; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/Comment.java b/src/main/java/pl/it_crowd/youtrack/api/rest/Comment.java new file mode 100644 index 0000000..d2d9e3a --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/Comment.java @@ -0,0 +1,423 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + *

Java class for commentType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="commentType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="replies" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="value" maxOccurs="unbounded" minOccurs="0">
+ *           <complexType>
+ *             <simpleContent>
+ *               <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *                 <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </extension>
+ *             </simpleContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *       <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="author" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="issueId" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="deleted" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="text" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="shownForIssueAuthor" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="created" type="{http://www.w3.org/2001/XMLSchema}long" />
+ *       <attribute name="updated" type="{http://www.w3.org/2001/XMLSchema}long" />
+ *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "commentType", propOrder = {"content"}) +public class Comment { +// ------------------------------ FIELDS ------------------------------ + + @XmlAttribute + protected String author; + + @XmlElementRefs({@XmlElementRef(name = "value", type = JAXBElement.class), @XmlElementRef(name = "replies", type = JAXBElement.class)}) + @XmlMixed + protected List content; + + @XmlAttribute + protected Long created; + + @XmlAttribute + protected String deleted; + + @XmlAttribute + protected String id; + + @XmlAttribute + protected String issueId; + + @XmlAttribute + protected String name; + + @XmlAttribute + protected String shownForIssueAuthor; + + @XmlAttribute + protected String text; + + @XmlAttribute + protected Long updated; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the author property. + * + * @return possible object is + * {@link String } + */ + public String getAuthor() + { + return author; + } + + /** + * Sets the value of the author property. + * + * @param value allowed object is + * {@link String } + */ + public void setAuthor(String value) + { + this.author = value; + } + + /** + * Gets the value of the content property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the content property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+     *    getContent().add(newItem);
+     * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * {@link JAXBElement }{@code <}{@link Comment.Value }{@code >} + * {@link JAXBElement }{@code <}{@link String }{@code >} + */ + public List getContent() + { + if (content == null) { + content = new ArrayList(); + } + return this.content; + } + + /** + * Gets the value of the created property. + * + * @return possible object is + * {@link Long } + */ + public Long getCreated() + { + return created; + } + + /** + * Sets the value of the created property. + * + * @param value allowed object is + * {@link Long } + */ + public void setCreated(Long value) + { + this.created = value; + } + + /** + * Gets the value of the deleted property. + * + * @return possible object is + * {@link String } + */ + public String getDeleted() + { + return deleted; + } + + /** + * Sets the value of the deleted property. + * + * @param value allowed object is + * {@link String } + */ + public void setDeleted(String value) + { + this.deleted = value; + } + + /** + * Gets the value of the id property. + * + * @return possible object is + * {@link String } + */ + public String getId() + { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is + * {@link String } + */ + public void setId(String value) + { + this.id = value; + } + + /** + * Gets the value of the issueId property. + * + * @return possible object is + * {@link String } + */ + public String getIssueId() + { + return issueId; + } + + /** + * Sets the value of the issueId property. + * + * @param value allowed object is + * {@link String } + */ + public void setIssueId(String value) + { + this.issueId = value; + } + + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() + { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) + { + this.name = value; + } + + /** + * Gets the value of the shownForIssueAuthor property. + * + * @return possible object is + * {@link String } + */ + public String getShownForIssueAuthor() + { + return shownForIssueAuthor; + } + + /** + * Sets the value of the shownForIssueAuthor property. + * + * @param value allowed object is + * {@link String } + */ + public void setShownForIssueAuthor(String value) + { + this.shownForIssueAuthor = value; + } + + /** + * Gets the value of the text property. + * + * @return possible object is + * {@link String } + */ + public String getText() + { + return text; + } + + /** + * Sets the value of the text property. + * + * @param value allowed object is + * {@link String } + */ + public void setText(String value) + { + this.text = value; + } + + /** + * Gets the value of the updated property. + * + * @return possible object is + * {@link Long } + */ + public Long getUpdated() + { + return updated; + } + + /** + * Sets the value of the updated property. + * + * @param value allowed object is + * {@link Long } + */ + public void setUpdated(Long value) + { + this.updated = value; + } + +// -------------------------- INNER CLASSES -------------------------- + + /** + *

Java class for anonymous complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+     * <complexType>
+     *   <simpleContent>
+     *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
+     *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *       <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *     </extension>
+     *   </simpleContent>
+     * </complexType>
+     * 
+ */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"value"}) + public static class Value { +// ------------------------------ FIELDS ------------------------------ + + @XmlAttribute + protected String role; + + @XmlAttribute + protected String type; + + @XmlValue + protected String value; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the role property. + * + * @return possible object is + * {@link String } + */ + public String getRole() + { + return role; + } + + /** + * Sets the value of the role property. + * + * @param value allowed object is + * {@link String } + */ + public void setRole(String value) + { + this.role = value; + } + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() + { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link String } + */ + public void setType(String value) + { + this.type = value; + } + + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() + { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) + { + this.value = value; + } + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/Enumeration.java b/src/main/java/pl/it_crowd/youtrack/api/rest/Enumeration.java new file mode 100644 index 0000000..ae0b9bf --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/Enumeration.java @@ -0,0 +1,96 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + *

Java class for enumerationType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="enumerationType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="value" type="{}enumerationValueType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "enumerationType", propOrder = {"values"}) +public class Enumeration { +// ------------------------------ FIELDS ------------------------------ + + @XmlAttribute + protected String name; + + @XmlElement(name = "value") + protected List values; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() + { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) + { + this.name = value; + } + + /** + * Gets the value of the values property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the values property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+     *    getValues().add(newItem);
+     * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link EnumerationValue } + */ + public List getValues() + { + if (values == null) { + values = new ArrayList(); + } + return this.values; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/EnumerationValue.java b/src/main/java/pl/it_crowd/youtrack/api/rest/EnumerationValue.java new file mode 100644 index 0000000..68eb7ac --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/EnumerationValue.java @@ -0,0 +1,85 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; + +/** + *

Java class for enumerationValueType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="enumerationValueType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *       <attribute name="colorIndex" type="{http://www.w3.org/2001/XMLSchema}long" />
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "enumerationValueType", propOrder = {"value"}) +public class EnumerationValue { +// ------------------------------ FIELDS ------------------------------ + + @XmlAttribute + protected Long colorIndex; + + @XmlValue + protected String value; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the colorIndex property. + * + * @return possible object is + * {@link Long } + */ + public Long getColorIndex() + { + return colorIndex; + } + + /** + * Sets the value of the colorIndex property. + * + * @param value allowed object is + * {@link Long } + */ + public void setColorIndex(Long value) + { + this.colorIndex = value; + } + + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() + { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) + { + this.value = value; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/Field.java b/src/main/java/pl/it_crowd/youtrack/api/rest/Field.java new file mode 100644 index 0000000..30fff21 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/Field.java @@ -0,0 +1,207 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import java.util.ArrayList; +import java.util.List; + +/** + *

Java class for fieldType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="fieldType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence maxOccurs="unbounded" minOccurs="0">
+ *         <element name="value">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "fieldType", propOrder = {"values"}) +public class Field { +// ------------------------------ FIELDS ------------------------------ + + @XmlAttribute + protected String name; + + @XmlElement(name = "value") + protected List values; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() + { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) + { + this.name = value; + } + + /** + * Gets the value of the values property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the values property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+     *    getValues().add(newItem);
+     * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Field.Value } + */ + public List getValues() + { + if (values == null) { + values = new ArrayList(); + } + return this.values; + } + +// -------------------------- INNER CLASSES -------------------------- + + /** + *

Java class for anonymous complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *       <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"content"}) + public static class Value { +// ------------------------------ FIELDS ------------------------------ + + @XmlValue + protected String content; + + @XmlAttribute + protected String role; + + @XmlAttribute + protected String type; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the content property. + * + * @return possible object is + * {@link String } + */ + public String getContent() + { + return content; + } + + /** + * Sets the value of the content property. + * + * @param value allowed object is + * {@link String } + */ + public void setContent(String value) + { + this.content = value; + } + + /** + * Gets the value of the role property. + * + * @return possible object is + * {@link String } + */ + public String getRole() + { + return role; + } + + /** + * Sets the value of the role property. + * + * @param value allowed object is + * {@link String } + */ + public void setRole(String value) + { + this.role = value; + } + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() + { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link String } + */ + public void setType(String value) + { + this.type = value; + } + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/Issue.java b/src/main/java/pl/it_crowd/youtrack/api/rest/Issue.java new file mode 100644 index 0000000..8b1088c --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/Issue.java @@ -0,0 +1,99 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + *

Java class for issueType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="issueType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice maxOccurs="unbounded" minOccurs="0">
+ *         <element name="field" type="{}fieldType"/>
+ *         <element name="comment" type="{}commentType"/>
+ *       </choice>
+ *       <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "issueType", propOrder = {"fieldOrComment"}) +public class Issue { +// ------------------------------ FIELDS ------------------------------ + + @XmlElements({@XmlElement(name = "comment", type = Comment.class), @XmlElement(name = "field", type = Field.class)}) + protected List fieldOrComment; + + @XmlAttribute + protected String id; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the fieldOrComment property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the fieldOrComment property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+     *    getFieldOrComment().add(newItem);
+     * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Comment } + * {@link Field } + */ + public List getFieldOrComment() + { + if (fieldOrComment == null) { + fieldOrComment = new ArrayList(); + } + return this.fieldOrComment; + } + + /** + * Gets the value of the id property. + * + * @return possible object is + * {@link String } + */ + public String getId() + { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is + * {@link String } + */ + public void setId(String value) + { + this.id = value; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/Issues.java b/src/main/java/pl/it_crowd/youtrack/api/rest/Issues.java new file mode 100644 index 0000000..ac63447 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/Issues.java @@ -0,0 +1,71 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + *

Java class for anonymous complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence maxOccurs="unbounded" minOccurs="0">
+ *         <element name="issue" type="{}issueType"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = {"issues"}) +@XmlRootElement(name = "issues") +public class Issues { +// ------------------------------ FIELDS ------------------------------ + + @XmlElement(name = "issue") + protected List issues; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the issues property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the issues property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+     *    getIssues().add(newItem);
+     * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Issue } + */ + public List getIssues() + { + if (issues == null) { + issues = new ArrayList(); + } + return this.issues; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/ObjectFactory.java b/src/main/java/pl/it_crowd/youtrack/api/rest/ObjectFactory.java new file mode 100644 index 0000000..448b649 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/ObjectFactory.java @@ -0,0 +1,226 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the pl.it_crowd.youtrack.api.rest package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + */ +@XmlRegistry +public class ObjectFactory { +// ------------------------------ FIELDS ------------------------------ + + private final static QName _CommentReplies_QNAME = new QName("", "replies"); + + private final static QName _CommentValue_QNAME = new QName("", "value"); + + private final static QName _Enumeration_QNAME = new QName("", "enumeration"); + + private final static QName _Error_QNAME = new QName("", "error"); + + private final static QName _Int_QNAME = new QName("", "int"); + + private final static QName _Issue_QNAME = new QName("", "issue"); + +// --------------------------- CONSTRUCTORS --------------------------- + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pl.it_crowd.youtrack.api.rest + */ + public ObjectFactory() + { + } + +// -------------------------- OTHER METHODS -------------------------- + + /** + * Create an instance of {@link AssignedByType } + */ + public AssignedByType createAssignedByType() + { + return new AssignedByType(); + } + + /** + * Create an instance of {@link AssigneeList } + */ + public AssigneeList createAssigneeList() + { + return new AssigneeList(); + } + + /** + * Create an instance of {@link AssigneeList.Assignees } + */ + public AssigneeList.Assignees createAssigneeListAssignees() + { + return new AssigneeList.Assignees(); + } + + /** + * Create an instance of {@link AssigneeType } + */ + public AssigneeType createAssigneeType() + { + return new AssigneeType(); + } + + /** + * Create an instance of {@link Comment } + */ + public Comment createComment() + { + return new Comment(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + */ + @XmlElementDecl(namespace = "", name = "replies", scope = Comment.class) + public JAXBElement createCommentReplies(String value) + { + return new JAXBElement(_CommentReplies_QNAME, String.class, Comment.class, value); + } + + /** + * Create an instance of {@link Comment.Value } + */ + public Comment.Value createCommentValue() + { + return new Comment.Value(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Comment.Value }{@code >}} + */ + @XmlElementDecl(namespace = "", name = "value", scope = Comment.class) + public JAXBElement createCommentValue(Comment.Value value) + { + return new JAXBElement(_CommentValue_QNAME, Comment.Value.class, Comment.class, value); + } + + /** + * Create an instance of {@link Enumeration } + */ + public Enumeration createEnumeration() + { + return new Enumeration(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Enumeration }{@code >}} + */ + @XmlElementDecl(namespace = "", name = "enumeration") + public JAXBElement createEnumeration(Enumeration value) + { + return new JAXBElement(_Enumeration_QNAME, Enumeration.class, null, value); + } + + /** + * Create an instance of {@link EnumerationValue } + */ + public EnumerationValue createEnumerationValue() + { + return new EnumerationValue(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + */ + @XmlElementDecl(namespace = "", name = "error") + public JAXBElement createError(String value) + { + return new JAXBElement(_Error_QNAME, String.class, null, value); + } + + /** + * Create an instance of {@link Field } + */ + public Field createField() + { + return new Field(); + } + + /** + * Create an instance of {@link Field.Value } + */ + public Field.Value createFieldValue() + { + return new Field.Value(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Short }{@code >}} + */ + @XmlElementDecl(namespace = "", name = "int") + public JAXBElement createInt(Short value) + { + return new JAXBElement(_Int_QNAME, Short.class, null, value); + } + + /** + * Create an instance of {@link Issue } + */ + public Issue createIssue() + { + return new Issue(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Issue }{@code >}} + */ + @XmlElementDecl(namespace = "", name = "issue") + public JAXBElement createIssue(Issue value) + { + return new JAXBElement(_Issue_QNAME, Issue.class, null, value); + } + + /** + * Create an instance of {@link Issues } + */ + public Issues createIssues() + { + return new Issues(); + } + + /** + * Create an instance of {@link User } + */ + public User createUser() + { + return new User(); + } + + /** + * Create an instance of {@link UserGroupRefType } + */ + public UserGroupRefType createUserGroupRefType() + { + return new UserGroupRefType(); + } + + /** + * Create an instance of {@link UserRefs } + */ + public UserRefs createUserRefs() + { + return new UserRefs(); + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/User.java b/src/main/java/pl/it_crowd/youtrack/api/rest/User.java new file mode 100644 index 0000000..25b3daa --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/User.java @@ -0,0 +1,87 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + +/** + *

Java class for userType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="userType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="login" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="url" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "userType") +public class User { +// ------------------------------ FIELDS ------------------------------ + + @XmlAttribute(required = true) + protected String login; + + @XmlAttribute + @XmlSchemaType(name = "anyURI") + protected String url; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the login property. + * + * @return possible object is + * {@link String } + */ + public String getLogin() + { + return login; + } + + /** + * Sets the value of the login property. + * + * @param value allowed object is + * {@link String } + */ + public void setLogin(String value) + { + this.login = value; + } + + /** + * Gets the value of the url property. + * + * @return possible object is + * {@link String } + */ + public String getUrl() + { + return url; + } + + /** + * Sets the value of the url property. + * + * @param value allowed object is + * {@link String } + */ + public void setUrl(String value) + { + this.url = value; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/UserGroupRefType.java b/src/main/java/pl/it_crowd/youtrack/api/rest/UserGroupRefType.java new file mode 100644 index 0000000..7563d0c --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/UserGroupRefType.java @@ -0,0 +1,111 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; + +/** + *

Java class for userGroupRefType complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="userGroupRefType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="url" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "userGroupRefType", propOrder = {"value"}) +public class UserGroupRefType { +// ------------------------------ FIELDS ------------------------------ + + @XmlAttribute + protected String name; + + @XmlAttribute + protected String url; + + @XmlValue + protected String value; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() + { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) + { + this.name = value; + } + + /** + * Gets the value of the url property. + * + * @return possible object is + * {@link String } + */ + public String getUrl() + { + return url; + } + + /** + * Sets the value of the url property. + * + * @param value allowed object is + * {@link String } + */ + public void setUrl(String value) + { + this.url = value; + } + + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() + { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) + { + this.value = value; + } +} diff --git a/src/main/java/pl/it_crowd/youtrack/api/rest/UserRefs.java b/src/main/java/pl/it_crowd/youtrack/api/rest/UserRefs.java new file mode 100644 index 0000000..e6844b9 --- /dev/null +++ b/src/main/java/pl/it_crowd/youtrack/api/rest/UserRefs.java @@ -0,0 +1,71 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// +package pl.it_crowd.youtrack.api.rest; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + *

Java class for anonymous complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="user" type="{}userType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = {"users"}) +@XmlRootElement(name = "userRefs") +public class UserRefs { +// ------------------------------ FIELDS ------------------------------ + + @XmlElement(name = "user") + protected List users; + +// --------------------- GETTER / SETTER METHODS --------------------- + + /** + * Gets the value of the users property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the users property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+     *    getUsers().add(newItem);
+     * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link User } + */ + public List getUsers() + { + if (users == null) { + users = new ArrayList(); + } + return this.users; + } +} diff --git a/src/main/xjb/bindings.xjb b/src/main/xjb/bindings.xjb index fb0e0d9..a617032 100644 --- a/src/main/xjb/bindings.xjb +++ b/src/main/xjb/bindings.xjb @@ -1,4 +1,5 @@ - diff --git a/src/test/java/pl/com/it_crowd/youtrack/api/rest/CommandTest.java b/src/test/java/pl/com/it_crowd/youtrack/api/rest/CommandTest.java deleted file mode 100644 index 24235c7..0000000 --- a/src/test/java/pl/com/it_crowd/youtrack/api/rest/CommandTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package pl.com.it_crowd.youtrack.api.rest; - -import junit.framework.Assert; -import org.junit.Test; -import pl.com.it_crowd.youtrack.api.Command; -import pl.com.it_crowd.youtrack.api.defaults.StateValues; - -public class CommandTest { -// -------------------------- OTHER METHODS -------------------------- - - @Test - public void assignee() - { - Assert.assertEquals("state Fixed assignee Tomek", Command.stateCommand("Fixed").assignee("Tomek").toString()); - } - - @Test - public void assigneeChaining() - { - Assert.assertEquals("assignee Jacek assignee Tomek assignee Bernard", - Command.assigneeCommand("Jacek").assignee("Tomek").assignee("Bernard").toString()); - } - - @Test - public void assigneeCommand() - { - Assert.assertEquals("assignee Jacek", Command.assigneeCommand("Jacek").toString()); - } - - @Test - public void state() - { - Assert.assertEquals("assignee Tomek state Open", Command.assigneeCommand("Tomek").state("Open").toString()); - Assert.assertEquals("assignee Tomek state To be discussed", Command.assigneeCommand("Tomek").state(StateValues.ToBeDiscussed).toString()); - } - - @Test - public void stateChaining() - { - Assert.assertEquals("state Fixed state Open state Obsolete", Command.stateCommand("Fixed").state("Open").state("Obsolete").toString()); - Assert.assertEquals("state Fixed state Open state Obsolete", Command.stateCommand("Fixed").state(StateValues.Open).state("Obsolete").toString()); - } - - @Test - public void stateCommand() - { - Assert.assertEquals("state Fixed", Command.stateCommand("Fixed").toString()); - Assert.assertEquals("state In Progress", Command.stateCommand(StateValues.InProgress).toString()); - } -} diff --git a/src/test/java/pl/com/it_crowd/youtrack/api/rest/FilterTest.java b/src/test/java/pl/com/it_crowd/youtrack/api/rest/FilterTest.java deleted file mode 100644 index 7f49ad3..0000000 --- a/src/test/java/pl/com/it_crowd/youtrack/api/rest/FilterTest.java +++ /dev/null @@ -1,140 +0,0 @@ -package pl.com.it_crowd.youtrack.api.rest; - -import junit.framework.Assert; -import org.junit.Test; -import pl.com.it_crowd.youtrack.api.Filter; -import pl.com.it_crowd.youtrack.api.defaults.DateValues; -import pl.com.it_crowd.youtrack.api.defaults.StateValues; - -public class FilterTest { -// -------------------------- OTHER METHODS -------------------------- - - @Test - public void chaining() - { - final String reporterBernard = "reporter:bernard"; - final String updaterJacek = "updated by:Jacek"; - final String projectTST_QA = "project:TST_QA"; - final String resolvedSunday = "resolved date:Sunday"; - final String updatedThreeWeeksAgo = "updated:{Three weeks ago}"; - final String createdLastMonth = "created:{Last month}"; - final String stateDuplicate = "state:Duplicate"; - final String space = " "; - Assert.assertEquals(stateDuplicate + space + createdLastMonth, Filter.stateFilter(StateValues.Duplicate).created(DateValues.LastMonth).toString()); - Assert.assertEquals(createdLastMonth + space + stateDuplicate, Filter.createdFilter(DateValues.LastMonth).state(StateValues.Duplicate).toString()); - Assert.assertEquals(createdLastMonth + space + stateDuplicate + space + "description:pikachu", - Filter.createdFilter(DateValues.LastMonth).state(StateValues.Duplicate).description("pikachu").toString()); - Assert.assertEquals(reporterBernard + space + projectTST_QA, Filter.reporterFilter("bernard").project("TST_QA").toString()); - Assert.assertEquals(projectTST_QA + space + reporterBernard, Filter.projectFilter("TST_QA").reporter("bernard").toString()); - Assert.assertEquals(resolvedSunday + space + updatedThreeWeeksAgo, Filter.resolvedFilter("Sunday").updated(DateValues.ThreeWeeksAgo).toString()); - Assert.assertEquals(updatedThreeWeeksAgo + space + resolvedSunday, Filter.updatedFilter(DateValues.ThreeWeeksAgo).resolved("Sunday").toString()); - Assert.assertEquals(updatedThreeWeeksAgo + space + updaterJacek, Filter.updatedFilter("{Three weeks ago}").updater("Jacek").toString()); - Assert.assertEquals(updaterJacek + space + updatedThreeWeeksAgo, Filter.updaterFilter("Jacek").updated("{Three weeks ago}").toString()); - } - - @Test - public void createdFilter() - { - Assert.assertEquals("created:2012-01-01", Filter.createdFilter("2012-01-01").toString()); - Assert.assertEquals("created:{Last month}", Filter.createdFilter(DateValues.LastMonth).toString()); - Assert.assertEquals("created:{This month}", Filter.createdFilter(DateValues.ThisMonth).toString()); - Assert.assertEquals("created:{Two weeks ago}", Filter.createdFilter(DateValues.TwoWeeksAgo).toString()); - Assert.assertEquals("created:{Three weeks ago}", Filter.createdFilter(DateValues.ThreeWeeksAgo).toString()); - Assert.assertEquals("created:{Last week}", Filter.createdFilter(DateValues.LastWeek).toString()); - Assert.assertEquals("created:{This week}", Filter.createdFilter(DateValues.ThisWeek).toString()); - Assert.assertEquals("created:Saturday", Filter.createdFilter(DateValues.Saturday).toString()); - Assert.assertEquals("created:Friday", Filter.createdFilter(DateValues.Friday).toString()); - Assert.assertEquals("created:Thursday", Filter.createdFilter(DateValues.Thursday).toString()); - Assert.assertEquals("created:Wednesday", Filter.createdFilter(DateValues.Wednesday).toString()); - Assert.assertEquals("created:Tuesday", Filter.createdFilter(DateValues.Tuesday).toString()); - Assert.assertEquals("created:Monday", Filter.createdFilter(DateValues.Monday).toString()); - Assert.assertEquals("created:Sunday", Filter.createdFilter(DateValues.Sunday).toString()); - } - - @Test - public void descriptionFilter() - { - Assert.assertEquals("description:Wacek Ramtamtamski's", Filter.descriptionFilter("Wacek Ramtamtamski's").toString()); - } - - @Test - public void projectFilter() - { - Assert.assertEquals("project:TST", Filter.projectFilter("TST").toString()); - } - - @Test - public void reporterFilter() - { - Assert.assertEquals("reporter:bernard", Filter.reporterFilter("bernard").toString()); - } - - @Test - public void resolvedFilter() - { - Assert.assertEquals("resolved date:2012-01-01", Filter.resolvedFilter("2012-01-01").toString()); - Assert.assertEquals("resolved date:{Last month}", Filter.resolvedFilter(DateValues.LastMonth).toString()); - Assert.assertEquals("resolved date:{This month}", Filter.resolvedFilter(DateValues.ThisMonth).toString()); - Assert.assertEquals("resolved date:{Two weeks ago}", Filter.resolvedFilter(DateValues.TwoWeeksAgo).toString()); - Assert.assertEquals("resolved date:{Three weeks ago}", Filter.resolvedFilter(DateValues.ThreeWeeksAgo).toString()); - Assert.assertEquals("resolved date:{Last week}", Filter.resolvedFilter(DateValues.LastWeek).toString()); - Assert.assertEquals("resolved date:{This week}", Filter.resolvedFilter(DateValues.ThisWeek).toString()); - Assert.assertEquals("resolved date:Saturday", Filter.resolvedFilter(DateValues.Saturday).toString()); - Assert.assertEquals("resolved date:Friday", Filter.resolvedFilter(DateValues.Friday).toString()); - Assert.assertEquals("resolved date:Thursday", Filter.resolvedFilter(DateValues.Thursday).toString()); - Assert.assertEquals("resolved date:Wednesday", Filter.resolvedFilter(DateValues.Wednesday).toString()); - Assert.assertEquals("resolved date:Tuesday", Filter.resolvedFilter(DateValues.Tuesday).toString()); - Assert.assertEquals("resolved date:Monday", Filter.resolvedFilter(DateValues.Monday).toString()); - Assert.assertEquals("resolved date:Sunday", Filter.resolvedFilter(DateValues.Sunday).toString()); - } - - @Test - public void stateFilter() - { - Assert.assertEquals("state:{Can't Reproduce}", Filter.stateFilter(StateValues.CantReproduce).toString()); - Assert.assertEquals("state:Verified", Filter.stateFilter(StateValues.Verified).toString()); - Assert.assertEquals("state:Submitted", Filter.stateFilter(StateValues.Submitted).toString()); - Assert.assertEquals("state:Reopened", Filter.stateFilter(StateValues.Reopened).toString()); - Assert.assertEquals("state:{To be discussed}", Filter.stateFilter(StateValues.ToBeDiscussed).toString()); - Assert.assertEquals("state:Duplicate", Filter.stateFilter(StateValues.Duplicate).toString()); - Assert.assertEquals("state:Resolved", Filter.stateFilter(StateValues.Resolved).toString()); - Assert.assertEquals("state:Fixed", Filter.stateFilter(StateValues.Fixed).toString()); - Assert.assertEquals("state:Incomplete", Filter.stateFilter(StateValues.Incomplete).toString()); - Assert.assertEquals("state:{In Progress}", Filter.stateFilter(StateValues.InProgress).toString()); - Assert.assertEquals("state:New", Filter.stateFilter(StateValues.New).toString()); - Assert.assertEquals("state:Obsolete", Filter.stateFilter(StateValues.Obsolete).toString()); - Assert.assertEquals("state:Open", Filter.stateFilter(StateValues.Open).toString()); - Assert.assertEquals("state:{Won't fix}", Filter.stateFilter(StateValues.WontFix).toString()); - Assert.assertEquals("state:-{Won't fix}", Filter.stateFilter(StateValues.NotWontFix).toString()); - Assert.assertEquals("state:-Verified", Filter.stateFilter(StateValues.NotVerified).toString()); - Assert.assertEquals("state:-Verified,{Can't Reproduce},Obsolete,{Won't fix}", - Filter.stateFilter(StateValues.NotVerified, StateValues.CantReproduce, StateValues.Obsolete, StateValues.WontFix).toString()); - } - - @Test - public void updatedFilter() - { - Assert.assertEquals("updated:Today", Filter.updatedFilter(DateValues.Today).toString()); - Assert.assertEquals("updated:Yesterday", Filter.updatedFilter(DateValues.Yesterday).toString()); - Assert.assertEquals("updated:2012-01-01", Filter.updatedFilter("2012-01-01").toString()); - Assert.assertEquals("updated:{Last month}", Filter.updatedFilter(DateValues.LastMonth).toString()); - Assert.assertEquals("updated:{This month}", Filter.updatedFilter(DateValues.ThisMonth).toString()); - Assert.assertEquals("updated:{Two weeks ago}", Filter.updatedFilter(DateValues.TwoWeeksAgo).toString()); - Assert.assertEquals("updated:{Three weeks ago}", Filter.updatedFilter(DateValues.ThreeWeeksAgo).toString()); - Assert.assertEquals("updated:{Last week}", Filter.updatedFilter(DateValues.LastWeek).toString()); - Assert.assertEquals("updated:{This week}", Filter.updatedFilter(DateValues.ThisWeek).toString()); - Assert.assertEquals("updated:Saturday", Filter.updatedFilter(DateValues.Saturday).toString()); - Assert.assertEquals("updated:Friday", Filter.updatedFilter(DateValues.Friday).toString()); - Assert.assertEquals("updated:Thursday", Filter.updatedFilter(DateValues.Thursday).toString()); - Assert.assertEquals("updated:Wednesday", Filter.updatedFilter(DateValues.Wednesday).toString()); - Assert.assertEquals("updated:Tuesday", Filter.updatedFilter(DateValues.Tuesday).toString()); - Assert.assertEquals("updated:Monday", Filter.updatedFilter(DateValues.Monday).toString()); - Assert.assertEquals("updated:Sunday", Filter.updatedFilter(DateValues.Sunday).toString()); - } - - @Test - public void updaterFilter() - { - Assert.assertEquals("updated by:bernard", Filter.updaterFilter("bernard").toString()); - } -} diff --git a/src/test/java/pl/com/it_crowd/youtrack/api/rest/URIUtilsTest.java b/src/test/java/pl/com/it_crowd/youtrack/api/rest/URIUtilsTest.java deleted file mode 100644 index f126e47..0000000 --- a/src/test/java/pl/com/it_crowd/youtrack/api/rest/URIUtilsTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package pl.com.it_crowd.youtrack.api.rest; - -import org.junit.Test; -import pl.com.it_crowd.youtrack.api.Filter; -import pl.com.it_crowd.youtrack.api.URIUtils; -import pl.com.it_crowd.youtrack.api.defaults.StateValues; - -import java.net.URI; -import java.net.URISyntaxException; - -import static org.junit.Assert.assertEquals; - -public class URIUtilsTest { -// -------------------------- OTHER METHODS -------------------------- - - @Test - public void buildURI() throws URISyntaxException - { -// Given - final URI baseA = new URI("http://localhost:8080/youtrack/"); - final URI baseB = new URI("http://localhost/youtrack/"); - final String pathA = "/rest/admin/bundle/QA note types"; - final String queryA = "q=" + Filter.stateFilter(StateValues.NotWontFix).maxResults(20); - -// When - final URI uriA = URIUtils.buildURI(baseA, pathA); - final URI uriB = URIUtils.buildURI(baseA, pathA, queryA); - final URI uriC = URIUtils.buildURI(baseB, pathA, queryA); - -// Then - assertEquals("http://localhost:8080/youtrack/rest/admin/bundle/QA%20note%20types", uriA.toString()); - assertEquals("http://localhost:8080/youtrack/rest/admin/bundle/QA%20note%20types?q=state:-%7BWon't%20fix%7D&max=20", uriB.toString()); - assertEquals("http://localhost/youtrack/rest/admin/bundle/QA%20note%20types?q=state:-%7BWon't%20fix%7D&max=20", uriC.toString()); - } -} 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 deleted file mode 100644 index 67f748f..0000000 --- a/src/test/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPITest.java +++ /dev/null @@ -1,244 +0,0 @@ -package pl.com.it_crowd.youtrack.api.rest; - -import junit.framework.Assert; -import org.apache.commons.io.input.ReaderInputStream; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.StatusLine; -import org.apache.http.auth.AuthenticationException; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpUriRequest; -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; -import pl.com.it_crowd.youtrack.api.defaults.StateValues; -import pl.com.it_crowd.youtrack.api.exceptions.NoResultFoundException; -import pl.com.it_crowd.youtrack.api.exceptions.YoutrackErrorException; - -import javax.xml.bind.JAXBException; -import java.io.IOException; -import java.io.StringReader; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * This test requires Youtrack instance with "Test(TST)" project to be running and expects following JVM params: - * youtrackLocation, youtrackUsername and youtrackPassword. - * There should be no assigner "wacek" for project TST. - * There should be following assigners for TST project: bernard,root. - * Ticket TST-2 should be deleted. - */ -public class YoutrackAPITest { -// -------------------------- OTHER METHODS -------------------------- - - @Test - public void command() throws IOException, JAXBException - { - final YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); - final String issueId = "TST-1"; - IssueWrapper issue; - try { - api.command(issueId, Command.assigneeCommand("wacek").toString()); - Assert.fail("Command should fail"); - } catch (YoutrackErrorException e) { -// There is no such assignee - Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, e.getStatusCode()); - } - api.command(issueId, Command.assigneeCommand("bernard").assignee("root")); - issue = api.getIssue(issueId); - Assert.assertNotNull(issue); - Assert.assertEquals("root", issue.getFieldValue(Fields.assignee)); - - api.command(issueId, Command.assigneeCommand("bernard")); - issue = api.getIssue(issueId); - Assert.assertNotNull(issue); - Assert.assertEquals("bernard", issue.getFieldValue(Fields.assignee)); - - api.command(issueId, Command.stateCommand(StateValues.InProgress)); - issue = api.getIssue(issueId); - Assert.assertNotNull(issue); - Assert.assertEquals("In Progress", issue.getFieldValue(Fields.state)); - - api.command(issueId, Command.stateCommand(StateValues.InProgress).assignee("root")); - issue = api.getIssue(issueId); - Assert.assertNotNull(issue); - Assert.assertEquals("In Progress", issue.getFieldValue(Fields.state)); - Assert.assertEquals("root", issue.getFieldValue(Fields.assignee)); - - api.command(issueId, Command.assigneeCommand("bernard").state(StateValues.New)); - issue = api.getIssue(issueId); - Assert.assertNotNull(issue); - Assert.assertEquals("New", issue.getFieldValue(Fields.state)); - Assert.assertEquals("bernard", issue.getFieldValue(Fields.assignee)); - } - - @Test - public void commandAllStates() throws IOException, JAXBException - { - final YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); - final String issueId = "TST-1"; - IssueWrapper issue; - final StateValues[] stateValueses = StateValues.values(); - for (StateValues state : stateValueses) { - if (state.getCommandValue() != null && !StateValues.Duplicate.equals(state)) { - api.command(issueId, Command.stateCommand(state)); - issue = api.getIssue(issueId); - Assert.assertNotNull(issue); - Assert.assertEquals(state.getCommandValue(), issue.getFieldValue(Fields.state)); - } - } - } - - @Test - public void createIssue() throws IOException, AuthenticationException, JAXBException - { - YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); - final String issueId = api.createIssue("TST", "Test summary", "Test description"); - Assert.assertNotNull(issueId); - Assert.assertTrue(issueId.startsWith("TST")); - } - - @Test - public void getAssignees() throws IOException, AuthenticationException, JAXBException - { - YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); - final AssigneeList assigneeList = api.getAssignees("TST"); - Assert.assertNotNull(assigneeList); - Assert.assertEquals(2, assigneeList.getAssignees().getAssignees().size()); - } - - @Test - public void getBundle() throws Exception - { -// Given - final HttpResponse httpResponse = mock(HttpResponse.class); - final HttpEntity httpEntity = mock(HttpEntity.class); - final String response = "Show-stopperCriticalMajorNormalMinor"; - when(httpEntity.getContent()).thenReturn(new ReaderInputStream(new StringReader(response))); - when(httpEntity.getContentLength()).thenReturn((long) response.getBytes().length); - when(httpResponse.getEntity()).thenReturn(httpEntity); - final StatusLine statusLine = mock(StatusLine.class); - when(statusLine.getStatusCode()).thenReturn(200); - when(httpResponse.getStatusLine()).thenReturn(statusLine); - final HttpClient httpClient = mock(HttpClient.class); - when(httpClient.execute(any(HttpUriRequest.class))).thenReturn(httpResponse); - final YoutrackAPI youtrackAPI = new YoutrackAPI("zonk", httpClient); - -// When - final Enumeration priorities = youtrackAPI.getBundle("Priorities"); - -// Then - assertNotNull(priorities); - assertEquals("Priorities", priorities.getName()); - assertNotNull(priorities.getValues()); - assertEquals(5, priorities.getValues().size()); - assertEquals("Show-stopper", priorities.getValues().get(0).getValue()); - assertEquals(new Long(20), priorities.getValues().get(0).getColorIndex()); - assertEquals("Critical", priorities.getValues().get(1).getValue()); - assertEquals(new Long(19), priorities.getValues().get(1).getColorIndex()); - assertEquals("Major", priorities.getValues().get(2).getValue()); - assertEquals(new Long(18), priorities.getValues().get(2).getColorIndex()); - assertEquals("Normal", priorities.getValues().get(3).getValue()); - assertEquals(new Long(17), priorities.getValues().get(3).getColorIndex()); - assertEquals("Minor", priorities.getValues().get(4).getValue()); - assertEquals(new Long(16), priorities.getValues().get(4).getColorIndex()); - } - - @Test - public void getIndividualAssignees() throws IOException, JAXBException - { - final YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); - final List assignees = api.getIndividualAssignees("TST"); - Assert.assertNotNull(assignees); - Assert.assertEquals(2, assignees.size()); - for (User user : assignees) { - Assert.assertTrue("bernard".equals(user.getLogin()) || "root".equals(user.getLogin())); - } - } - - @Test - public void getIssue() throws IOException, AuthenticationException, JAXBException - { - YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); - final IssueWrapper issue = api.getIssue("TST-1"); - Assert.assertNotNull(issue); - Assert.assertEquals("1", issue.getFieldValue(Fields.numberInProject)); - - try { - api.getIssue("TST-2"); - Assert.fail("YoutrackErrorException expected"); - } catch (NoResultFoundException e) { - Assert.assertEquals("Issue not found.", e.getMessage()); - } - try { - api.getIssue("TSTX-1"); - Assert.fail("YoutrackErrorException expected"); - } catch (NoResultFoundException e) { - Assert.assertEquals("Issue not found.", e.getMessage()); - } - } - - @Test(expected = YoutrackErrorException.class) - public void loginFailure() throws IOException, JAXBException - { - final String username = "someFakeLogin"; - final String password = "someFakePassword"; - try { - new YoutrackAPI(getServiceLocation(), username, password); - } catch (YoutrackErrorException e) { - Assert.assertEquals("Incorrect login or password.", e.getMessage()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, e.getStatusCode()); - throw e; - } - } - - @Test - public void loginSuccess() throws IOException, AuthenticationException, JAXBException - { - final String username = getUsername(); - final String password = getPassword(); - new YoutrackAPI(getServiceLocation(), username, password); - YoutrackAPI api = new YoutrackAPI(getServiceLocation()); - api.login(username, password); - } - - @Test - public void searchIssuesByProject() throws IOException, AuthenticationException, JAXBException - { - YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); - List issues = api.searchIssuesByProject("TST", null); - Assert.assertTrue(!issues.isEmpty()); - for (IssueWrapper issue : issues) { - String summary = issue.getFieldValue(Fields.summary); - 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() - { - return System.getProperty("youtrackPassword"); - } - - private String getServiceLocation() - { - return System.getProperty("youtrackLocation"); - } - - private String getUsername() - { - return System.getProperty("youtrackUsername"); - } -} diff --git a/src/test/java/pl/it_crowd/youtrack/api/rest/CommandTest.java b/src/test/java/pl/it_crowd/youtrack/api/rest/CommandTest.java new file mode 100644 index 0000000..7bd0bc7 --- /dev/null +++ b/src/test/java/pl/it_crowd/youtrack/api/rest/CommandTest.java @@ -0,0 +1,50 @@ +package pl.it_crowd.youtrack.api.rest; + +import junit.framework.Assert; +import org.junit.Test; +import pl.it_crowd.youtrack.api.Command; +import pl.it_crowd.youtrack.api.defaults.StateValues; + +public class CommandTest { +// -------------------------- OTHER METHODS -------------------------- + + @Test + public void assignee() + { + Assert.assertEquals("state Fixed assignee Tomek", Command.stateCommand("Fixed").assignee("Tomek").toString()); + } + + @Test + public void assigneeChaining() + { + Assert.assertEquals("assignee Jacek assignee Tomek assignee Bernard", + Command.assigneeCommand("Jacek").assignee("Tomek").assignee("Bernard").toString()); + } + + @Test + public void assigneeCommand() + { + Assert.assertEquals("assignee Jacek", Command.assigneeCommand("Jacek").toString()); + } + + @Test + public void state() + { + Assert.assertEquals("assignee Tomek state Open", Command.assigneeCommand("Tomek").state("Open").toString()); + Assert.assertEquals("assignee Tomek state To be discussed", Command.assigneeCommand("Tomek").state(StateValues.ToBeDiscussed).toString()); + } + + @Test + public void stateChaining() + { + Assert.assertEquals("state Fixed state Open state Obsolete", Command.stateCommand("Fixed").state("Open").state("Obsolete").toString()); + Assert.assertEquals("state Fixed state Open state Obsolete", Command.stateCommand("Fixed").state(StateValues.Open).state("Obsolete").toString()); + } + + @Test + public void stateCommand() + { + Assert.assertEquals("state Fixed", Command.stateCommand("Fixed").toString()); + Assert.assertEquals("state In Progress", Command.stateCommand(StateValues.InProgress).toString()); + } +} diff --git a/src/test/java/pl/it_crowd/youtrack/api/rest/FilterTest.java b/src/test/java/pl/it_crowd/youtrack/api/rest/FilterTest.java new file mode 100644 index 0000000..01f1fe9 --- /dev/null +++ b/src/test/java/pl/it_crowd/youtrack/api/rest/FilterTest.java @@ -0,0 +1,140 @@ +package pl.it_crowd.youtrack.api.rest; + +import junit.framework.Assert; +import org.junit.Test; +import pl.it_crowd.youtrack.api.Filter; +import pl.it_crowd.youtrack.api.defaults.DateValues; +import pl.it_crowd.youtrack.api.defaults.StateValues; + +public class FilterTest { +// -------------------------- OTHER METHODS -------------------------- + + @Test + public void chaining() + { + final String reporterBernard = "reporter:bernard"; + final String updaterJacek = "updated by:Jacek"; + final String projectTST_QA = "project:TST_QA"; + final String resolvedSunday = "resolved date:Sunday"; + final String updatedThreeWeeksAgo = "updated:{Three weeks ago}"; + final String createdLastMonth = "created:{Last month}"; + final String stateDuplicate = "state:Duplicate"; + final String space = " "; + Assert.assertEquals(stateDuplicate + space + createdLastMonth, Filter.stateFilter(StateValues.Duplicate).created(DateValues.LastMonth).toString()); + Assert.assertEquals(createdLastMonth + space + stateDuplicate, Filter.createdFilter(DateValues.LastMonth).state(StateValues.Duplicate).toString()); + Assert.assertEquals(createdLastMonth + space + stateDuplicate + space + "description:pikachu", + Filter.createdFilter(DateValues.LastMonth).state(StateValues.Duplicate).description("pikachu").toString()); + Assert.assertEquals(reporterBernard + space + projectTST_QA, Filter.reporterFilter("bernard").project("TST_QA").toString()); + Assert.assertEquals(projectTST_QA + space + reporterBernard, Filter.projectFilter("TST_QA").reporter("bernard").toString()); + Assert.assertEquals(resolvedSunday + space + updatedThreeWeeksAgo, Filter.resolvedFilter("Sunday").updated(DateValues.ThreeWeeksAgo).toString()); + Assert.assertEquals(updatedThreeWeeksAgo + space + resolvedSunday, Filter.updatedFilter(DateValues.ThreeWeeksAgo).resolved("Sunday").toString()); + Assert.assertEquals(updatedThreeWeeksAgo + space + updaterJacek, Filter.updatedFilter("{Three weeks ago}").updater("Jacek").toString()); + Assert.assertEquals(updaterJacek + space + updatedThreeWeeksAgo, Filter.updaterFilter("Jacek").updated("{Three weeks ago}").toString()); + } + + @Test + public void createdFilter() + { + Assert.assertEquals("created:2012-01-01", Filter.createdFilter("2012-01-01").toString()); + Assert.assertEquals("created:{Last month}", Filter.createdFilter(DateValues.LastMonth).toString()); + Assert.assertEquals("created:{This month}", Filter.createdFilter(DateValues.ThisMonth).toString()); + Assert.assertEquals("created:{Two weeks ago}", Filter.createdFilter(DateValues.TwoWeeksAgo).toString()); + Assert.assertEquals("created:{Three weeks ago}", Filter.createdFilter(DateValues.ThreeWeeksAgo).toString()); + Assert.assertEquals("created:{Last week}", Filter.createdFilter(DateValues.LastWeek).toString()); + Assert.assertEquals("created:{This week}", Filter.createdFilter(DateValues.ThisWeek).toString()); + Assert.assertEquals("created:Saturday", Filter.createdFilter(DateValues.Saturday).toString()); + Assert.assertEquals("created:Friday", Filter.createdFilter(DateValues.Friday).toString()); + Assert.assertEquals("created:Thursday", Filter.createdFilter(DateValues.Thursday).toString()); + Assert.assertEquals("created:Wednesday", Filter.createdFilter(DateValues.Wednesday).toString()); + Assert.assertEquals("created:Tuesday", Filter.createdFilter(DateValues.Tuesday).toString()); + Assert.assertEquals("created:Monday", Filter.createdFilter(DateValues.Monday).toString()); + Assert.assertEquals("created:Sunday", Filter.createdFilter(DateValues.Sunday).toString()); + } + + @Test + public void descriptionFilter() + { + Assert.assertEquals("description:Wacek Ramtamtamski's", Filter.descriptionFilter("Wacek Ramtamtamski's").toString()); + } + + @Test + public void projectFilter() + { + Assert.assertEquals("project:TST", Filter.projectFilter("TST").toString()); + } + + @Test + public void reporterFilter() + { + Assert.assertEquals("reporter:bernard", Filter.reporterFilter("bernard").toString()); + } + + @Test + public void resolvedFilter() + { + Assert.assertEquals("resolved date:2012-01-01", Filter.resolvedFilter("2012-01-01").toString()); + Assert.assertEquals("resolved date:{Last month}", Filter.resolvedFilter(DateValues.LastMonth).toString()); + Assert.assertEquals("resolved date:{This month}", Filter.resolvedFilter(DateValues.ThisMonth).toString()); + Assert.assertEquals("resolved date:{Two weeks ago}", Filter.resolvedFilter(DateValues.TwoWeeksAgo).toString()); + Assert.assertEquals("resolved date:{Three weeks ago}", Filter.resolvedFilter(DateValues.ThreeWeeksAgo).toString()); + Assert.assertEquals("resolved date:{Last week}", Filter.resolvedFilter(DateValues.LastWeek).toString()); + Assert.assertEquals("resolved date:{This week}", Filter.resolvedFilter(DateValues.ThisWeek).toString()); + Assert.assertEquals("resolved date:Saturday", Filter.resolvedFilter(DateValues.Saturday).toString()); + Assert.assertEquals("resolved date:Friday", Filter.resolvedFilter(DateValues.Friday).toString()); + Assert.assertEquals("resolved date:Thursday", Filter.resolvedFilter(DateValues.Thursday).toString()); + Assert.assertEquals("resolved date:Wednesday", Filter.resolvedFilter(DateValues.Wednesday).toString()); + Assert.assertEquals("resolved date:Tuesday", Filter.resolvedFilter(DateValues.Tuesday).toString()); + Assert.assertEquals("resolved date:Monday", Filter.resolvedFilter(DateValues.Monday).toString()); + Assert.assertEquals("resolved date:Sunday", Filter.resolvedFilter(DateValues.Sunday).toString()); + } + + @Test + public void stateFilter() + { + Assert.assertEquals("state:{Can't Reproduce}", Filter.stateFilter(StateValues.CantReproduce).toString()); + Assert.assertEquals("state:Verified", Filter.stateFilter(StateValues.Verified).toString()); + Assert.assertEquals("state:Submitted", Filter.stateFilter(StateValues.Submitted).toString()); + Assert.assertEquals("state:Reopened", Filter.stateFilter(StateValues.Reopened).toString()); + Assert.assertEquals("state:{To be discussed}", Filter.stateFilter(StateValues.ToBeDiscussed).toString()); + Assert.assertEquals("state:Duplicate", Filter.stateFilter(StateValues.Duplicate).toString()); + Assert.assertEquals("state:Resolved", Filter.stateFilter(StateValues.Resolved).toString()); + Assert.assertEquals("state:Fixed", Filter.stateFilter(StateValues.Fixed).toString()); + Assert.assertEquals("state:Incomplete", Filter.stateFilter(StateValues.Incomplete).toString()); + Assert.assertEquals("state:{In Progress}", Filter.stateFilter(StateValues.InProgress).toString()); + Assert.assertEquals("state:New", Filter.stateFilter(StateValues.New).toString()); + Assert.assertEquals("state:Obsolete", Filter.stateFilter(StateValues.Obsolete).toString()); + Assert.assertEquals("state:Open", Filter.stateFilter(StateValues.Open).toString()); + Assert.assertEquals("state:{Won't fix}", Filter.stateFilter(StateValues.WontFix).toString()); + Assert.assertEquals("state:-{Won't fix}", Filter.stateFilter(StateValues.NotWontFix).toString()); + Assert.assertEquals("state:-Verified", Filter.stateFilter(StateValues.NotVerified).toString()); + Assert.assertEquals("state:-Verified,{Can't Reproduce},Obsolete,{Won't fix}", + Filter.stateFilter(StateValues.NotVerified, StateValues.CantReproduce, StateValues.Obsolete, StateValues.WontFix).toString()); + } + + @Test + public void updatedFilter() + { + Assert.assertEquals("updated:Today", Filter.updatedFilter(DateValues.Today).toString()); + Assert.assertEquals("updated:Yesterday", Filter.updatedFilter(DateValues.Yesterday).toString()); + Assert.assertEquals("updated:2012-01-01", Filter.updatedFilter("2012-01-01").toString()); + Assert.assertEquals("updated:{Last month}", Filter.updatedFilter(DateValues.LastMonth).toString()); + Assert.assertEquals("updated:{This month}", Filter.updatedFilter(DateValues.ThisMonth).toString()); + Assert.assertEquals("updated:{Two weeks ago}", Filter.updatedFilter(DateValues.TwoWeeksAgo).toString()); + Assert.assertEquals("updated:{Three weeks ago}", Filter.updatedFilter(DateValues.ThreeWeeksAgo).toString()); + Assert.assertEquals("updated:{Last week}", Filter.updatedFilter(DateValues.LastWeek).toString()); + Assert.assertEquals("updated:{This week}", Filter.updatedFilter(DateValues.ThisWeek).toString()); + Assert.assertEquals("updated:Saturday", Filter.updatedFilter(DateValues.Saturday).toString()); + Assert.assertEquals("updated:Friday", Filter.updatedFilter(DateValues.Friday).toString()); + Assert.assertEquals("updated:Thursday", Filter.updatedFilter(DateValues.Thursday).toString()); + Assert.assertEquals("updated:Wednesday", Filter.updatedFilter(DateValues.Wednesday).toString()); + Assert.assertEquals("updated:Tuesday", Filter.updatedFilter(DateValues.Tuesday).toString()); + Assert.assertEquals("updated:Monday", Filter.updatedFilter(DateValues.Monday).toString()); + Assert.assertEquals("updated:Sunday", Filter.updatedFilter(DateValues.Sunday).toString()); + } + + @Test + public void updaterFilter() + { + Assert.assertEquals("updated by:bernard", Filter.updaterFilter("bernard").toString()); + } +} diff --git a/src/test/java/pl/it_crowd/youtrack/api/rest/URIUtilsTest.java b/src/test/java/pl/it_crowd/youtrack/api/rest/URIUtilsTest.java new file mode 100644 index 0000000..0b80f93 --- /dev/null +++ b/src/test/java/pl/it_crowd/youtrack/api/rest/URIUtilsTest.java @@ -0,0 +1,35 @@ +package pl.it_crowd.youtrack.api.rest; + +import org.junit.Test; +import pl.it_crowd.youtrack.api.Filter; +import pl.it_crowd.youtrack.api.URIUtils; +import pl.it_crowd.youtrack.api.defaults.StateValues; + +import java.net.URI; +import java.net.URISyntaxException; + +import static org.junit.Assert.assertEquals; + +public class URIUtilsTest { +// -------------------------- OTHER METHODS -------------------------- + + @Test + public void buildURI() throws URISyntaxException + { +// Given + final URI baseA = new URI("http://localhost:8080/youtrack/"); + final URI baseB = new URI("http://localhost/youtrack/"); + final String pathA = "/rest/admin/bundle/QA note types"; + final String queryA = "q=" + Filter.stateFilter(StateValues.NotWontFix).maxResults(20); + +// When + final URI uriA = URIUtils.buildURI(baseA, pathA); + final URI uriB = URIUtils.buildURI(baseA, pathA, queryA); + final URI uriC = URIUtils.buildURI(baseB, pathA, queryA); + +// Then + assertEquals("http://localhost:8080/youtrack/rest/admin/bundle/QA%20note%20types", uriA.toString()); + assertEquals("http://localhost:8080/youtrack/rest/admin/bundle/QA%20note%20types?q=state:-%7BWon't%20fix%7D&max=20", uriB.toString()); + assertEquals("http://localhost/youtrack/rest/admin/bundle/QA%20note%20types?q=state:-%7BWon't%20fix%7D&max=20", uriC.toString()); + } +} diff --git a/src/test/java/pl/it_crowd/youtrack/api/rest/YoutrackAPITest.java b/src/test/java/pl/it_crowd/youtrack/api/rest/YoutrackAPITest.java new file mode 100644 index 0000000..2bde483 --- /dev/null +++ b/src/test/java/pl/it_crowd/youtrack/api/rest/YoutrackAPITest.java @@ -0,0 +1,244 @@ +package pl.it_crowd.youtrack.api.rest; + +import junit.framework.Assert; +import org.apache.commons.io.input.ReaderInputStream; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.StatusLine; +import org.apache.http.auth.AuthenticationException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpUriRequest; +import org.junit.Test; +import pl.it_crowd.youtrack.api.Command; +import pl.it_crowd.youtrack.api.Filter; +import pl.it_crowd.youtrack.api.IssueWrapper; +import pl.it_crowd.youtrack.api.YoutrackAPI; +import pl.it_crowd.youtrack.api.defaults.Fields; +import pl.it_crowd.youtrack.api.defaults.StateValues; +import pl.it_crowd.youtrack.api.exceptions.NoResultFoundException; +import pl.it_crowd.youtrack.api.exceptions.YoutrackErrorException; + +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.io.StringReader; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * This test requires Youtrack instance with "Test(TST)" project to be running and expects following JVM params: + * youtrackLocation, youtrackUsername and youtrackPassword. + * There should be no assigner "wacek" for project TST. + * There should be following assigners for TST project: bernard,root. + * Ticket TST-2 should be deleted. + */ +public class YoutrackAPITest { +// -------------------------- OTHER METHODS -------------------------- + + @Test + public void command() throws IOException, JAXBException + { + final YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); + final String issueId = "TST-1"; + IssueWrapper issue; + try { + api.command(issueId, Command.assigneeCommand("wacek").toString()); + Assert.fail("Command should fail"); + } catch (YoutrackErrorException e) { +// There is no such assignee + Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, e.getStatusCode()); + } + api.command(issueId, Command.assigneeCommand("bernard").assignee("root")); + issue = api.getIssue(issueId); + Assert.assertNotNull(issue); + Assert.assertEquals("root", issue.getFieldValue(Fields.assignee)); + + api.command(issueId, Command.assigneeCommand("bernard")); + issue = api.getIssue(issueId); + Assert.assertNotNull(issue); + Assert.assertEquals("bernard", issue.getFieldValue(Fields.assignee)); + + api.command(issueId, Command.stateCommand(StateValues.InProgress)); + issue = api.getIssue(issueId); + Assert.assertNotNull(issue); + Assert.assertEquals("In Progress", issue.getFieldValue(Fields.state)); + + api.command(issueId, Command.stateCommand(StateValues.InProgress).assignee("root")); + issue = api.getIssue(issueId); + Assert.assertNotNull(issue); + Assert.assertEquals("In Progress", issue.getFieldValue(Fields.state)); + Assert.assertEquals("root", issue.getFieldValue(Fields.assignee)); + + api.command(issueId, Command.assigneeCommand("bernard").state(StateValues.New)); + issue = api.getIssue(issueId); + Assert.assertNotNull(issue); + Assert.assertEquals("New", issue.getFieldValue(Fields.state)); + Assert.assertEquals("bernard", issue.getFieldValue(Fields.assignee)); + } + + @Test + public void commandAllStates() throws IOException, JAXBException + { + final YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); + final String issueId = "TST-1"; + IssueWrapper issue; + final StateValues[] stateValueses = StateValues.values(); + for (StateValues state : stateValueses) { + if (state.getCommandValue() != null && !StateValues.Duplicate.equals(state)) { + api.command(issueId, Command.stateCommand(state)); + issue = api.getIssue(issueId); + Assert.assertNotNull(issue); + Assert.assertEquals(state.getCommandValue(), issue.getFieldValue(Fields.state)); + } + } + } + + @Test + public void createIssue() throws IOException, AuthenticationException, JAXBException + { + YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); + final String issueId = api.createIssue("TST", "Test summary", "Test description"); + Assert.assertNotNull(issueId); + Assert.assertTrue(issueId.startsWith("TST")); + } + + @Test + public void getAssignees() throws IOException, AuthenticationException, JAXBException + { + YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); + final AssigneeList assigneeList = api.getAssignees("TST"); + Assert.assertNotNull(assigneeList); + Assert.assertEquals(2, assigneeList.getAssignees().getAssignees().size()); + } + + @Test + public void getBundle() throws Exception + { +// Given + final HttpResponse httpResponse = mock(HttpResponse.class); + final HttpEntity httpEntity = mock(HttpEntity.class); + final String response = "Show-stopperCriticalMajorNormalMinor"; + when(httpEntity.getContent()).thenReturn(new ReaderInputStream(new StringReader(response))); + when(httpEntity.getContentLength()).thenReturn((long) response.getBytes().length); + when(httpResponse.getEntity()).thenReturn(httpEntity); + final StatusLine statusLine = mock(StatusLine.class); + when(statusLine.getStatusCode()).thenReturn(200); + when(httpResponse.getStatusLine()).thenReturn(statusLine); + final HttpClient httpClient = mock(HttpClient.class); + when(httpClient.execute(any(HttpUriRequest.class))).thenReturn(httpResponse); + final YoutrackAPI youtrackAPI = new YoutrackAPI("zonk", httpClient); + +// When + final Enumeration priorities = youtrackAPI.getBundle("Priorities"); + +// Then + assertNotNull(priorities); + assertEquals("Priorities", priorities.getName()); + assertNotNull(priorities.getValues()); + assertEquals(5, priorities.getValues().size()); + assertEquals("Show-stopper", priorities.getValues().get(0).getValue()); + assertEquals(new Long(20), priorities.getValues().get(0).getColorIndex()); + assertEquals("Critical", priorities.getValues().get(1).getValue()); + assertEquals(new Long(19), priorities.getValues().get(1).getColorIndex()); + assertEquals("Major", priorities.getValues().get(2).getValue()); + assertEquals(new Long(18), priorities.getValues().get(2).getColorIndex()); + assertEquals("Normal", priorities.getValues().get(3).getValue()); + assertEquals(new Long(17), priorities.getValues().get(3).getColorIndex()); + assertEquals("Minor", priorities.getValues().get(4).getValue()); + assertEquals(new Long(16), priorities.getValues().get(4).getColorIndex()); + } + + @Test + public void getIndividualAssignees() throws IOException, JAXBException + { + final YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); + final List assignees = api.getIndividualAssignees("TST"); + Assert.assertNotNull(assignees); + Assert.assertEquals(2, assignees.size()); + for (User user : assignees) { + Assert.assertTrue("bernard".equals(user.getLogin()) || "root".equals(user.getLogin())); + } + } + + @Test + public void getIssue() throws IOException, AuthenticationException, JAXBException + { + YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); + final IssueWrapper issue = api.getIssue("TST-1"); + Assert.assertNotNull(issue); + Assert.assertEquals("1", issue.getFieldValue(Fields.numberInProject)); + + try { + api.getIssue("TST-2"); + Assert.fail("YoutrackErrorException expected"); + } catch (NoResultFoundException e) { + Assert.assertEquals("Issue not found.", e.getMessage()); + } + try { + api.getIssue("TSTX-1"); + Assert.fail("YoutrackErrorException expected"); + } catch (NoResultFoundException e) { + Assert.assertEquals("Issue not found.", e.getMessage()); + } + } + + @Test(expected = YoutrackErrorException.class) + public void loginFailure() throws IOException, JAXBException + { + final String username = "someFakeLogin"; + final String password = "someFakePassword"; + try { + new YoutrackAPI(getServiceLocation(), username, password); + } catch (YoutrackErrorException e) { + Assert.assertEquals("Incorrect login or password.", e.getMessage()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, e.getStatusCode()); + throw e; + } + } + + @Test + public void loginSuccess() throws IOException, AuthenticationException, JAXBException + { + final String username = getUsername(); + final String password = getPassword(); + new YoutrackAPI(getServiceLocation(), username, password); + YoutrackAPI api = new YoutrackAPI(getServiceLocation()); + api.login(username, password); + } + + @Test + public void searchIssuesByProject() throws IOException, AuthenticationException, JAXBException + { + YoutrackAPI api = new YoutrackAPI(getServiceLocation(), getUsername(), getPassword()); + List issues = api.searchIssuesByProject("TST", null); + Assert.assertTrue(!issues.isEmpty()); + for (IssueWrapper issue : issues) { + String summary = issue.getFieldValue(Fields.summary); + 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() + { + return System.getProperty("youtrackPassword"); + } + + private String getServiceLocation() + { + return System.getProperty("youtrackLocation"); + } + + private String getUsername() + { + return System.getProperty("youtrackUsername"); + } +} -- libgit2 0.24.0