2018-08-15 11:44:20 +02:00
|
|
|
package sonia.scm.it;
|
|
|
|
|
|
|
|
|
|
import org.apache.http.HttpStatus;
|
|
|
|
|
import org.junit.Before;
|
|
|
|
|
import org.junit.Rule;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.junit.rules.TemporaryFolder;
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
import org.junit.runners.Parameterized;
|
2018-08-22 09:18:17 +02:00
|
|
|
import sonia.scm.repository.client.api.RepositoryClient;
|
2018-08-15 11:44:20 +02:00
|
|
|
|
2018-08-22 09:18:17 +02:00
|
|
|
import java.io.File;
|
2018-08-15 11:44:20 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
|
import static org.junit.Assume.assumeFalse;
|
|
|
|
|
import static sonia.scm.it.RestUtil.given;
|
|
|
|
|
import static sonia.scm.it.ScmTypes.availableScmTypes;
|
|
|
|
|
|
|
|
|
|
@RunWith(Parameterized.class)
|
|
|
|
|
public class RepositoryAccessITCase {
|
|
|
|
|
|
|
|
|
|
@Rule
|
|
|
|
|
public TemporaryFolder tempFolder = new TemporaryFolder();
|
|
|
|
|
|
|
|
|
|
private final String repositoryType;
|
2018-08-22 09:18:17 +02:00
|
|
|
private File folder;
|
2018-08-15 11:44:20 +02:00
|
|
|
|
|
|
|
|
public RepositoryAccessITCase(String repositoryType) {
|
|
|
|
|
this.repositoryType = repositoryType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Parameterized.Parameters(name = "{0}")
|
|
|
|
|
public static Collection<String> createParameters() {
|
|
|
|
|
return availableScmTypes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Before
|
2018-08-22 09:18:17 +02:00
|
|
|
public void initClient() {
|
2018-08-15 11:44:20 +02:00
|
|
|
TestData.createDefault();
|
2018-08-22 09:18:17 +02:00
|
|
|
folder = tempFolder.getRoot();
|
2018-08-15 11:44:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void shouldFindBranches() throws IOException {
|
|
|
|
|
assumeFalse("There are no branches for SVN", repositoryType.equals("svn"));
|
|
|
|
|
|
2018-08-22 10:59:46 +02:00
|
|
|
RepositoryClient repositoryClient = RepositoryUtil.createRepositoryClient(repositoryType, folder);
|
|
|
|
|
RepositoryUtil.createAndCommitFile(repositoryClient, "scmadmin", "a.txt", "a");
|
2018-08-15 11:44:20 +02:00
|
|
|
|
|
|
|
|
String branchesUrl = given()
|
|
|
|
|
.when()
|
|
|
|
|
.get(TestData.getDefaultRepositoryUrl(repositoryType))
|
|
|
|
|
.then()
|
|
|
|
|
.statusCode(HttpStatus.SC_OK)
|
|
|
|
|
.extract()
|
|
|
|
|
.path("_links.branches.href");
|
|
|
|
|
|
|
|
|
|
Object branchName = given()
|
|
|
|
|
.when()
|
|
|
|
|
.get(branchesUrl)
|
|
|
|
|
.then()
|
|
|
|
|
.statusCode(HttpStatus.SC_OK)
|
|
|
|
|
.extract()
|
|
|
|
|
.path("_embedded.branches[0].name");
|
|
|
|
|
|
|
|
|
|
assertNotNull(branchName);
|
|
|
|
|
}
|
|
|
|
|
}
|