use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class ShowFileContentTest method testShowContentOfNotExistFile.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class, expectedExceptions = GitException.class, expectedExceptionsMessageRegExp = "fatal: Path 'dummyFile' does not exist in 'HEAD'\n")
public void testShowContentOfNotExistFile(GitConnectionFactory connectionFactory) throws Exception {
//given
//create new repository
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "newfile", "new file content");
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("Test commit"));
//when
connection.showFileContent("dummyFile", "HEAD");
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class ShowFileContentTest method testShowFileContentFromBranch.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testShowFileContentFromBranch(GitConnectionFactory connectionFactory) throws IOException, ServerException, URISyntaxException, UnauthorizedException {
//given
//create new repository
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "newFile", "new file content");
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("Test commit"));
connection.branchCreate("new-branch", null);
//when
final ShowFileContentResponse response = connection.showFileContent("newFile", "new-branch");
//then
assertEquals("new file content", response.getContent());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class ShowFileContentTest method testShowFileContentFromHead.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testShowFileContentFromHead(GitConnectionFactory connectionFactory) throws IOException, ServerException, URISyntaxException, UnauthorizedException {
//given
//create new repository
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "newFile", "new file content");
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("Test commit"));
//when
final ShowFileContentResponse response = connection.showFileContent("newFile", "HEAD");
//then
assertEquals("new file content", response.getContent());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class StatusTest method testModified.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testModified(GitConnectionFactory connectionFactory) throws Exception {
//given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "a", "a content");
addFile(connection, "b", "b content");
//add "a" and "b"
connection.add(AddParams.create(ImmutableList.of("a", "b")));
//modify "a"
addFile(connection, "a", "new content of a");
//when
final Status status = connection.status(StatusFormat.SHORT);
//then
assertEquals(status.getModified(), ImmutableList.of("a"));
assertTrue(status.getUntracked().isEmpty());
assertTrue(status.getChanged().isEmpty());
assertTrue(status.getConflicting().isEmpty());
assertTrue(status.getMissing().isEmpty());
assertTrue(status.getRemoved().isEmpty());
assertTrue(status.getUntrackedFolders().isEmpty());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class StatusTest method testRemovedFromFilesSystem.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testRemovedFromFilesSystem(GitConnectionFactory connectionFactory) throws Exception {
//given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "a", "a content");
addFile(connection, "b", "b content");
//add "a" and "b"
connection.add(AddParams.create(ImmutableList.of("a", "b")));
//commit "a" and "b"
connection.commit(CommitParams.create("add 2 test files"));
//delete "a"
deleteFile(connection, "a");
//when
final Status status = connection.status(StatusFormat.SHORT);
//then
assertTrue(status.getRemoved().isEmpty());
assertTrue(status.getAdded().isEmpty());
assertTrue(status.getChanged().isEmpty());
assertTrue(status.getConflicting().isEmpty());
assertEquals(status.getMissing(), ImmutableList.of("a"));
assertTrue(status.getUntracked().isEmpty());
assertTrue(status.getUntrackedFolders().isEmpty());
}
Aggregations