use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class CloneTest method testLineConsumerOutputWhenCloning.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testLineConsumerOutputWhenCloning(GitConnectionFactory connectionFactory) throws ServerException, IOException, UnauthorizedException, URISyntaxException {
//given
GitConnection remoteConnection = connectToGitRepositoryWithContent(connectionFactory, remoteRepo);
GitConnection localConnection = connectionFactory.getConnection(localRepo.getAbsolutePath());
LineConsumerFactory lineConsumerFactory = mock(LineConsumerFactory.class);
LineConsumer lineConsumer = mock(LineConsumer.class);
when(lineConsumerFactory.newLineConsumer()).thenReturn(lineConsumer);
localConnection.setOutputLineConsumerFactory(lineConsumerFactory);
//when
localConnection.clone(CloneParams.create(remoteConnection.getWorkingDir().getAbsolutePath()));
//then
verify(lineConsumer, atLeastOnce()).writeLine(anyString());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class CommitTest method testChangeMessageOfLastCommitWithSpecifiedPath.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testChangeMessageOfLastCommitWithSpecifiedPath(GitConnectionFactory connectionFactory) throws GitException, IOException {
//given
GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
addFile(connection, "NewFile.txt", CONTENT);
connection.add(AddParams.create(ImmutableList.of("NewFile.txt")));
connection.commit(CommitParams.create("First commit"));
int beforeCommitsCount = connection.log(LogParams.create()).getCommits().size();
//when
CommitParams commitParams = CommitParams.create("Changed message").withFiles(singletonList("NewFile.txt")).withAmend(true);
connection.commit(commitParams);
//then
int afterCommitsCount = connection.log(LogParams.create()).getCommits().size();
assertEquals(beforeCommitsCount, afterCommitsCount);
assertEquals(connection.log(LogParams.create()).getCommits().get(0).getMessage(), commitParams.getMessage());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class CommitTest method testSimpleCommit.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testSimpleCommit(GitConnectionFactory connectionFactory) throws GitException, IOException {
//given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
//add new File
addFile(connection, "DONTREADME", "secret");
//add changes
connection.add(AddParams.create(AddRequest.DEFAULT_PATTERN));
//when
CommitParams commitParams = CommitParams.create("Commit message").withAmend(false).withAll(false);
Revision revision = connection.commit(commitParams);
//then
assertEquals(revision.getMessage(), commitParams.getMessage());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class CommitTest method testCommitWithNotStagedChanges.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class, expectedExceptions = GitException.class, expectedExceptionsMessageRegExp = "No changes added to commit")
public void testCommitWithNotStagedChanges(GitConnectionFactory connectionFactory) throws GitException, IOException {
//given
GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
//Prepare unstaged deletion
addFile(connection, "FileToDelete.txt", "content");
connection.add(AddParams.create(ImmutableList.of("FileToDelete.txt")));
connection.commit(CommitParams.create("File to delete"));
new File(connection.getWorkingDir().getAbsolutePath(), "FileToDelete.txt").delete();
//Prepare unstaged new file
addFile(connection, "newFile", "content");
//Prepare unstaged editing
write(new File(connection.getWorkingDir(), "README.txt").toPath(), "new content".getBytes());
//when
connection.commit(CommitParams.create("test commit"));
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class CommitTest method testChangeMessageOfLastCommit.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testChangeMessageOfLastCommit(GitConnectionFactory connectionFactory) throws GitException, IOException {
//given
GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
addFile(connection, "NewFile.txt", CONTENT);
connection.add(AddParams.create(ImmutableList.of("NewFile.txt")));
connection.commit(CommitParams.create("First commit"));
int beforeCommitsCount = connection.log(LogParams.create()).getCommits().size();
//when
CommitParams commitParams = CommitParams.create("Changed message").withAmend(true);
connection.commit(commitParams);
//then
int afterCommitsCount = connection.log(LogParams.create()).getCommits().size();
assertEquals(beforeCommitsCount, afterCommitsCount);
assertEquals(connection.log(LogParams.create()).getCommits().get(0).getMessage(), commitParams.getMessage());
}
Aggregations