use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class LogTest method testLogSkip.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testLogSkip(GitConnectionFactory connectionFactory) throws GitException, IOException {
//given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "1.txt", "someChanges");
connection.add(AddParams.create());
connection.commit(CommitParams.create("add 1.txt file"));
addFile(connection, "2.txt", "newChanges");
connection.add(AddParams.create());
connection.commit(CommitParams.create("add 2.txt file"));
addFile(connection, "3.txt", "otherChanges");
connection.add(AddParams.create());
connection.commit(CommitParams.create("add 3.txt file"));
addFile(connection, "4.txt", "someChanges");
connection.add(AddParams.create());
connection.commit(CommitParams.create("add 4.txt file"));
//when
List<Revision> allCommits = connection.log(LogParams.create()).getCommits();
List<Revision> firstBucketOfCommits = connection.log(LogParams.create().withSkip(1)).getCommits();
List<Revision> secondBucketOfCommits = connection.log(LogParams.create().withSkip(3)).getCommits();
//then
assertEquals(4, allCommits.size());
assertEquals(3, firstBucketOfCommits.size());
assertEquals(firstBucketOfCommits.get(0).getMessage(), "add 3.txt file");
assertEquals(firstBucketOfCommits.get(0).getBranches().get(0).getName(), "refs/heads/master");
assertEquals(firstBucketOfCommits.get(0).getDiffCommitFile().get(0).getOldPath(), "/dev/null");
assertEquals(firstBucketOfCommits.get(0).getDiffCommitFile().get(0).getNewPath(), "3.txt");
assertEquals(firstBucketOfCommits.get(0).getDiffCommitFile().get(0).getChangeType(), "ADD");
assertEquals(firstBucketOfCommits.get(1).getMessage(), "add 2.txt file");
assertEquals(firstBucketOfCommits.get(1).getBranches().get(0).getName(), "refs/heads/master");
assertEquals(firstBucketOfCommits.get(1).getDiffCommitFile().get(0).getOldPath(), "/dev/null");
assertEquals(firstBucketOfCommits.get(1).getDiffCommitFile().get(0).getNewPath(), "2.txt");
assertEquals(firstBucketOfCommits.get(1).getDiffCommitFile().get(0).getChangeType(), "ADD");
assertEquals(firstBucketOfCommits.get(2).getMessage(), "add 1.txt file");
assertEquals(firstBucketOfCommits.get(2).getBranches().get(0).getName(), "refs/heads/master");
assertEquals(firstBucketOfCommits.get(2).getDiffCommitFile().get(0).getOldPath(), "/dev/null");
assertEquals(firstBucketOfCommits.get(2).getDiffCommitFile().get(0).getNewPath(), "1.txt");
assertEquals(firstBucketOfCommits.get(2).getDiffCommitFile().get(0).getChangeType(), "ADD");
assertEquals(1, secondBucketOfCommits.size());
assertEquals(secondBucketOfCommits.get(0).getMessage(), "add 1.txt file");
assertEquals(secondBucketOfCommits.get(0).getBranches().get(0).getName(), "refs/heads/master");
assertEquals(secondBucketOfCommits.get(0).getDiffCommitFile().get(0).getOldPath(), "/dev/null");
assertEquals(secondBucketOfCommits.get(0).getDiffCommitFile().get(0).getNewPath(), "1.txt");
assertEquals(secondBucketOfCommits.get(0).getDiffCommitFile().get(0).getChangeType(), "ADD");
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class LogTest method testSimpleLog.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testSimpleLog(GitConnectionFactory connectionFactory) throws GitException, IOException {
//given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "README.txt", "someChanges");
connection.add(AddParams.create(ImmutableList.of("README.txt")));
connection.commit(CommitParams.create("Initial add"));
addFile(connection, "README.txt", "newChanges");
connection.add(AddParams.create(ImmutableList.of("README.txt")));
connection.commit(CommitParams.create("Second commit"));
addFile(connection, "README.txt", "otherChanges");
connection.add(AddParams.create(ImmutableList.of("README.txt")));
connection.commit(CommitParams.create("Third commit"));
//when
List<Revision> commits = connection.log(LogParams.create()).getCommits();
//then
assertEquals("Third commit", commits.get(0).getMessage());
assertEquals("Second commit", commits.get(1).getMessage());
assertEquals("Initial add", commits.get(2).getMessage());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class LsRemoteTest method testShouldThrowUnauthorizedExceptionIfUserTryGetInfoAboutPrivateRepoAndUserIsUnauthorized.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class, expectedExceptions = UnauthorizedException.class, expectedExceptionsMessageRegExp = "fatal: Authentication failed for 'https://bitbucket.org/exoinvitemain/privater.git/'\n")
public void testShouldThrowUnauthorizedExceptionIfUserTryGetInfoAboutPrivateRepoAndUserIsUnauthorized(GitConnectionFactory connectionFactory) throws GitException, UnauthorizedException, IOException {
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
connection.lsRemote("https://bitbucket.org/exoinvitemain/privater.git");
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class LsRemoteTest method testShouldBeAbleToGetResultFromPublicRepo.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testShouldBeAbleToGetResultFromPublicRepo(GitConnectionFactory connectionFactory) throws GitException, IOException, UnauthorizedException {
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
//when
Set<RemoteReference> remoteReferenceSet = new HashSet<>(connection.lsRemote("https://github.com/codenvy/everrest.git"));
//then
assertTrue(remoteReferenceSet.contains(newDto(RemoteReference.class).withCommitId("259e24c83c8a122af858c8306c3286586404ef3f").withReferenceName("refs/tags/1.1.9")));
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class MergeTest method testMergeNoChanges.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testMergeNoChanges(GitConnectionFactory connectionFactory) throws Exception {
//given
GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
connection.branchCreate(branchName, null);
//when
MergeResult mergeResult = connection.merge(branchName);
//then
assertEquals(mergeResult.getMergeStatus(), MergeResult.MergeStatus.ALREADY_UP_TO_DATE);
}
Aggregations