Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#239 #240

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

#239 #240

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto eol=lf


# Add readily-visible signature (in SHA format) to all files (tagged by $Id$) with extension below.
# Read more https://gist.github.com/treyharris/f98b708c9f5b753d60a2 .
*.java ident
*.yml ident
*.xml ident


# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.txt text
*.java text
*.groovy text
*.xml text
*.md text
*.pom text
*.properties text
*.tex text
*.vm text
*.xsl text
*.yml text


# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,19 @@
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
17 changes: 10 additions & 7 deletions src/main/java/net/rcarz/jiraclient/Filter.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package net.rcarz.jiraclient;

import net.sf.json.JSON;
import net.sf.json.JSONObject;

import java.net.URI;
import java.util.Map;
import net.sf.json.JSON;
import net.sf.json.JSONObject;

/**
* Represens a Jira filter.
Expand All @@ -14,28 +13,32 @@ public class Filter extends Resource {
private String name;
private String jql;
private boolean favourite;
private User owner;

public Filter(RestClient restclient, JSONObject json) {
super(restclient);

if (json != null)
deserialise(json);
deserialise(restclient, json);
}

private void deserialise(JSONObject json) {
private void deserialise(final RestClient rst, final JSONObject json) {
Map map = json;

id = Field.getString(map.get("id"));
self = Field.getString(map.get("self"));
name = Field.getString(map.get("name"));
jql = Field.getString(map.get("jql"));
favourite = Field.getBoolean(map.get("favourite"));
this.owner = new User(rst, (JSONObject) json.get("owner"));
}

public boolean isFavourite() {
return favourite;
}

public User getOwner() {
return this.owner;
}

public String getJql() {
return jql;
}
Expand Down
22 changes: 15 additions & 7 deletions src/main/java/net/rcarz/jiraclient/JiraClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;

import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;

/**
* A simple JIRA REST client.
Expand Down Expand Up @@ -384,6 +382,16 @@ public Filter getFilter(final String id) throws JiraException {
return Filter.get(restclient, id);
}

/**
* Retrieve the jira filter with the supplied id.
* @param id id of the filter to retreive.
* @return The Jira filter with the supplied id
* @throws JiraException
*/
public Filter getFilter(final Integer id) throws JiraException {
return this.getFilter(id.toString());
}

/**
*
* @return a list of all priorities available in the Jira installation
Expand Down Expand Up @@ -419,7 +427,7 @@ public List<Priority> getPriorities() throws JiraException {
* @throws JiraException when the search fails
*/
public List<CustomFieldOption> getCustomFieldAllowedValues(String field, String project, String issueType) throws JiraException {
JSONObject createMetadata = (JSONObject) Issue.getCreateMetadata(restclient, project, issueType);
JSONObject createMetadata = Issue.getCreateMetadata(restclient, project, issueType);
JSONObject fieldMetadata = (JSONObject) createMetadata.get(field);
List<CustomFieldOption> customFieldOptions = Field.getResourceArray(
CustomFieldOption.class,
Expand All @@ -440,7 +448,7 @@ public List<CustomFieldOption> getCustomFieldAllowedValues(String field, String
* @throws JiraException when the search fails
*/
public List<Component> getComponentsAllowedValues(String project, String issueType) throws JiraException {
JSONObject createMetadata = (JSONObject) Issue.getCreateMetadata(restclient, project, issueType);
JSONObject createMetadata = Issue.getCreateMetadata(restclient, project, issueType);
JSONObject fieldMetadata = (JSONObject) createMetadata.get(Field.COMPONENTS);
List<Component> componentOptions = Field.getResourceArray(
Component.class,
Expand Down
9 changes: 8 additions & 1 deletion src/test/java/net/rcarz/jiraclient/FilterTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package net.rcarz.jiraclient;

import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

Expand All @@ -24,6 +25,12 @@ public void testGetFilter() throws JiraException {
final String expectedJql = "project = 10240 AND issuetype = 1 ORDER BY key DESC";
assertEquals("with jql: " + expectedJql, expectedJql, filter.getJql());
assertEquals("None favourite", false, filter.isFavourite());

MatcherAssert.assertThat(
"The filter owner is Scott Farquhar.",
filter.getOwner().getDisplayName(),
new IsEqual("Scott Farquhar")
);
}

}