#2 - Provide command to list all issue branches alongside their state in the issue tracker

This commit is contained in:
Mark Paluch
2016-02-11 08:34:02 +01:00
committed by Oliver Gierke
parent 6f62556ed3
commit a94f109ae7
23 changed files with 765 additions and 35 deletions

View File

@@ -54,4 +54,9 @@ public class GitOperationsIntegrationTests extends AbstractIntegrationTests {
public void obtainsVersionTagsForRepoThatAlsoHasOtherTags() {
gitOperations.getTags(MONGO_DB);
}
@Test
public void getResolvedBranches() {
gitOperations.listTicketBranches(REDIS);
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.jira;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.model.Projects;
/**
* @author Mark Paluch
*/
public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests {
@Autowired GitHubConnector gitHubIssueTracker;
@Test
public void getTickets() throws Exception {
Collection<Ticket> tickets = gitHubIssueTracker.findTickets(Projects.BUILD, Arrays.asList("1", "2", "-1"));
assertThat(tickets, hasSize(2));
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.jira;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.model.Projects;
/**
* @author Mark Paluch
*/
public class JiraIntegrationTests extends AbstractIntegrationTests {
@Autowired JiraConnector jira;
@Test
public void findResolvedTicketsByTicketIds() throws Exception {
Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList("DATAREDIS-1", "DATAJPA-1"));
assertThat(tickets, hasSize(2));
}
@Test
public void ignoresUnknownTicketsByTicketId() throws Exception {
Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList("XYZ-1", "UNKOWN-1"));
assertThat(tickets, hasSize(0));
}
@Test
public void emptyResultWithEmptyTicketIds() throws Exception {
Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList());
assertThat(tickets, hasSize(0));
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.model;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Test;
/**
* @author Mark Paluch
*/
public class TrackerTest {
@Test
public void testMatchesTicketNumber() throws Exception {
Pattern pattern = Pattern.compile(Tracker.JIRA.getTicketPattern());
Matcher matcher = pattern.matcher("DATAREDIS-1");
matcher.find();
assertThat(matcher.group(1), is(equalTo("DATAREDIS-1")));
}
@Test
public void testMatchesBranchNamedLikeTicket() throws Exception {
Pattern pattern = Pattern.compile(Tracker.JIRA.getTicketPattern());
Matcher matcher = pattern.matcher("issues/DATAREDIS-1-dummy");
matcher.find();
assertThat(matcher.group(1), is(equalTo("DATAREDIS-1")));
}
@Test
public void testVersionBranch() throws Exception {
Pattern pattern = Pattern.compile(Tracker.GITHUB.getTicketPattern());
Matcher matcher = pattern.matcher("1.2.x");
matcher.find();
assertThat(matcher.group(1), is(equalTo("1")));
}
}