Search in sources :

Example 86 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class RemoteListTest method testRemoteList.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testRemoteList(GitConnectionFactory connectionFactory) throws ServerException, URISyntaxException, UnauthorizedException, IOException {
    //given
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    GitConnection connection2 = connectionFactory.getConnection(remoteRepo.getAbsolutePath());
    connection2.clone(CloneParams.create(connection.getWorkingDir().getAbsolutePath()).withWorkingDir(connection2.getWorkingDir().getAbsolutePath()));
    assertEquals(connection2.remoteList(null, false).size(), 1);
    //create new remote
    connection2.remoteAdd(RemoteAddParams.create("newremote", "newremote.url"));
    assertEquals(connection2.remoteList(null, false).size(), 2);
    //when
    List<Remote> one = connection2.remoteList("newremote", false);
    //then
    assertEquals(one.get(0).getUrl(), "newremote.url");
    assertEquals(one.size(), 1);
}
Also used : Remote(org.eclipse.che.api.git.shared.Remote) GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 87 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class RemoteUpdateTest method testDeleteUrl.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testDeleteUrl(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    //add url
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    addInitialRemote(connection);
    connection.remoteUpdate(RemoteUpdateParams.create("newRemote").withAddUrl(singletonList("newUrl")));
    //when
    connection.remoteUpdate(RemoteUpdateParams.create("newRemote").withRemoveUrl(singletonList("newUrl")));
    //then
    assertFalse(parseAllConfig(connection).containsKey("remote.newRemote.newUrl"));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 88 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class RemoteUpdateTest method testDeletePushUrl.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testDeletePushUrl(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    addInitialRemote(connection);
    //add push url
    connection.remoteUpdate(RemoteUpdateParams.create("newRemote").withAddPushUrl(singletonList("pushurl")));
    //when
    connection.remoteUpdate(RemoteUpdateParams.create("newRemote").withRemovePushUrl(singletonList("pushurl")));
    //then
    assertNull(parseAllConfig(connection).get("remote.newRemote.pushurl"));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 89 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class RemoteUpdateTest method testAddPushUrl.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testAddPushUrl(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    addInitialRemote(connection);
    //when
    connection.remoteUpdate(RemoteUpdateParams.create("newRemote").withAddPushUrl(singletonList("pushurl1")));
    //then
    assertTrue(parseAllConfig(connection).get("remote.newRemote.pushurl").contains("pushurl1"));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 90 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class RemoveTest method testNotCachedRemove.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testNotCachedRemove(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    //when
    connection.rm(RmParams.create(singletonList("README.txt")).withCached(false));
    //then
    assertFalse(new File(connection.getWorkingDir(), "README.txt").exists());
    assertEquals(connection.status(StatusFormat.SHORT).getRemoved().get(0), "README.txt");
    assertTrue(connection.status(StatusFormat.SHORT).getUntracked().isEmpty());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

GitConnection (org.eclipse.che.api.git.GitConnection)102 Test (org.testng.annotations.Test)100 File (java.io.File)19 GitTestUtil.addFile (org.eclipse.che.git.impl.GitTestUtil.addFile)16 Revision (org.eclipse.che.api.git.shared.Revision)9 ArrayList (java.util.ArrayList)6 CommitParams (org.eclipse.che.api.git.params.CommitParams)5 FileOutputStream (java.io.FileOutputStream)3 MergeResult (org.eclipse.che.api.git.shared.MergeResult)3 DiffPage (org.eclipse.che.api.git.DiffPage)2 GitException (org.eclipse.che.api.git.exception.GitException)2 DiffParams (org.eclipse.che.api.git.params.DiffParams)2 ShowFileContentResponse (org.eclipse.che.api.git.shared.ShowFileContentResponse)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)1 LineConsumerFactory (org.eclipse.che.api.core.util.LineConsumerFactory)1 PullParams (org.eclipse.che.api.git.params.PullParams)1 RemoteAddParams (org.eclipse.che.api.git.params.RemoteAddParams)1 RemoteUpdateParams (org.eclipse.che.api.git.params.RemoteUpdateParams)1