Search in sources :

Example 1 with PullParams

use of org.eclipse.che.api.git.params.PullParams in project che by eclipse.

the class PullTest method testPullRemote.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testPullRemote(GitConnectionFactory connectionFactory) throws GitException, IOException, URISyntaxException, UnauthorizedException {
    //given
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    String branchName = "remoteBranch";
    connection.checkout(CheckoutParams.create(branchName).withCreateNew(true));
    addFile(connection, "remoteFile", "");
    connection.add(AddParams.create(singletonList(".")));
    connection.commit(CommitParams.create("remote test"));
    GitConnection connection2 = connectToGitRepositoryWithContent(connectionFactory, remoteRepo);
    //when
    PullParams params = PullParams.create(connection.getWorkingDir().getAbsolutePath()).withRefSpec("refs/heads/remoteBranch:refs/heads/remoteBranch");
    connection2.pull(params);
    //then
    assertTrue(new File(remoteRepo.getAbsolutePath(), "remoteFile").exists());
}
Also used : PullParams(org.eclipse.che.api.git.params.PullParams) GitConnection(org.eclipse.che.api.git.GitConnection) File(java.io.File) GitTestUtil.addFile(org.eclipse.che.git.impl.GitTestUtil.addFile) Test(org.testng.annotations.Test)

Aggregations

File (java.io.File)1 GitConnection (org.eclipse.che.api.git.GitConnection)1 PullParams (org.eclipse.che.api.git.params.PullParams)1 GitTestUtil.addFile (org.eclipse.che.git.impl.GitTestUtil.addFile)1 Test (org.testng.annotations.Test)1