[ https://jira.codehaus.org/browse/JBEHAVE-653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=286114#comment-286114 ]
Olmo Rigolo commented on JBEHAVE-653: ------------------------------------- Thanks Cristiano. Your ideas helped me to implement a basic LoadFromJIRA. I use the atlassian.jira.rest.client. import java.net.URI; import java.net.URISyntaxException; import org.jbehave.core.io.ResourceLoader; import org.jbehave.core.io.StoryLoader; import com.atlassian.jira.rest.client.JiraRestClient; import com.atlassian.jira.rest.client.NullProgressMonitor; import com.atlassian.jira.rest.client.domain.Issue; import com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory; /** * Loads data from JIRA fields "Narrative" and "Acceptance Criteria" * * @author olmo.rigolo * */ public class LoadFromJIRA implements ResourceLoader, StoryLoader { private final String narrativeFieldName = "Narrative"; private final String scenariosFieldName = "Acceptance Criteria"; private String storyId; private String location; private String username; private String password; private JiraRestClient restClient = null; final NullProgressMonitor pm = new NullProgressMonitor(); /** * * Configures the JIRA loader. * * @param location The jira url * @param username The jira account username * @param password The jira account password * @param storyId The jira story id */ public LoadFromJIRA(String location, String username, String password, String storyId) { this.location = location; this.password = password; this.username = username; this.storyId = storyId; } @Override public String loadStoryAsText(String storyPath) { return loadFromJira(this.storyId); } @Override public String loadResourceAsText(String resourcePath) { return loadFromJira(this.storyId); } private JiraRestClient connect(String location, String username, String password) { JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory(); restClient = null; try { restClient = factory.createWithBasicHttpAuthentication(new URI(location), username, password); } catch (URISyntaxException e) { e.printStackTrace(); } return restClient; } private String loadFromJira(String storyId) { if(this.restClient == null){ this.restClient = connect(location, username, password); } final Issue issue = restClient.getIssueClient().getIssue(storyId, pm); final String narrative = issue.getFieldByName(narrativeFieldName).getValue().toString(); final String scenarios = issue.getFieldByName(scenariosFieldName).getValue().toString(); StringBuilder sb = new StringBuilder(); sb.append("Narrative:"); sb.append(narrative); sb.append(scenarios); return sb.toString(); } } ----------------- Usage: Configuration configuration = new MostUsefulConfiguration() .useStoryLoader(new LoadFromJIRA("http://localhost/jira", "yourJiraUserName","yourJiraPassword", "JIRA-STORYID-112")) .useStoryReporterBuilder(new StoryReporterBuilder().withFormats(HTML)); ----------------- Ressources: jira rest client library http://confluence.atlassian.com/display/DOCSPRINT/The+Simplest+Possible+JIRA+REST+Examples https://studio.atlassian.com/wiki/display/JRJC/Tutorial > Integrate JIRA > -------------- > > Key: JBEHAVE-653 > URL: https://jira.codehaus.org/browse/JBEHAVE-653 > Project: JBehave > Issue Type: Improvement > Components: Core > Affects Versions: 3.5.4 > Environment: JIRA v4.2 > Reporter: Olmo Rigolo > Priority: Minor > Labels: configuration, jira, reports, wish > Original Estimate: 3 minutes > Remaining Estimate: 3 minutes > > We are using JIRA to organise our stories. It would be nice to integrate the > story files directly from JIRA, so you don't have to write them twice. At > this moment we write the acceptance criteria for a story in JIRA and we copy > them into our projects. > My idea is to > -extend the LoadFromUrl class to add the functionality to log into a page > (like for google docs). Something like LoadFromSecuredUrl, LoadFromJira > -then write a parser that extracts the fields from a story in JIRA as plain > text like you propose it here > http://jbehave.org/reference/stable/locating-stories.html -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email