Search in sources :

Example 6 with Status

use of org.eclipse.che.api.git.shared.Status in project che by eclipse.

the class JGitConnectionTest method testCommitNotChangedSpecifiedPathsWithAmendAndWithAllWhenOtherUnstagedChangesArePresent.

/** Test for workaround related to  https://bugs.eclipse.org/bugs/show_bug.cgi?id=510685.*/
@Test(expectedExceptions = GitException.class, expectedExceptionsMessageRegExp = "Changes are present but not changed path was specified for commit.")
public void testCommitNotChangedSpecifiedPathsWithAmendAndWithAllWhenOtherUnstagedChangesArePresent() throws Exception {
    //given
    Status status = mock(Status.class);
    when(status.getModified()).thenReturn(singletonList("ChangedNotSpecified"));
    doReturn(status).when(jGitConnection).status(anyObject());
    //when
    jGitConnection.commit(CommitParams.create("message").withFiles(singletonList("NotChangedSpecified")).withAmend(true).withAll(true));
}
Also used : Status(org.eclipse.che.api.git.shared.Status) Test(org.testng.annotations.Test)

Example 7 with Status

use of org.eclipse.che.api.git.shared.Status in project che by eclipse.

the class JGitConnectionTest method testCommitNotChangedSpecifiedPathsWithAmendWhenOtherStagedChangesArePresent.

/** Test for workaround related to  https://bugs.eclipse.org/bugs/show_bug.cgi?id=510685.*/
@Test(expectedExceptions = GitException.class, expectedExceptionsMessageRegExp = "Changes are present but not changed path was specified for commit.")
public void testCommitNotChangedSpecifiedPathsWithAmendWhenOtherStagedChangesArePresent() throws Exception {
    //given
    Status status = mock(Status.class);
    when(status.getChanged()).thenReturn(singletonList("ChangedNotSpecified"));
    doReturn(status).when(jGitConnection).status(anyObject());
    //when
    jGitConnection.commit(CommitParams.create("message").withFiles(singletonList("NotChangedSpecified")).withAmend(true));
}
Also used : Status(org.eclipse.che.api.git.shared.Status) Test(org.testng.annotations.Test)

Example 8 with Status

use of org.eclipse.che.api.git.shared.Status in project che by eclipse.

the class ResetFilesPresenterTest method testOnResetClickedWhenResetRequestIsSuccessful.

@Test
public void testOnResetClickedWhenResetRequestIsSuccessful() throws Exception {
    final Status status = mock(Status.class);
    List<String> changes = new ArrayList<String>();
    changes.add("Change");
    when(status.getAdded()).thenReturn(changes);
    when(status.getChanged()).thenReturn(changes);
    when(status.getRemoved()).thenReturn(changes);
    when(service.reset(anyObject(), any(Path.class), anyString(), any(ResetRequest.ResetType.class), anyObject())).thenReturn(voidPromise);
    when(voidPromise.then(any(Operation.class))).thenReturn(voidPromise);
    when(voidPromise.catchError(any(Operation.class))).thenReturn(voidPromise);
    presenter.showDialog(project);
    verify(statusPromise).then(statusPromiseCaptor.capture());
    statusPromiseCaptor.getValue().apply(status);
    presenter.onResetClicked();
    verify(voidPromise).then(voidPromiseCaptor.capture());
    voidPromiseCaptor.getValue().apply(null);
    verify(view).close();
    verify(notificationManager).notify(anyString());
    verify(console).print(anyString());
    verify(constant, times(2)).resetFilesSuccessfully();
}
Also used : Status(org.eclipse.che.api.git.shared.Status) Path(org.eclipse.che.ide.resource.Path) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Operation(org.eclipse.che.api.promises.client.Operation) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 9 with Status

use of org.eclipse.che.api.git.shared.Status in project che by eclipse.

the class ResetFilesPresenterTest method testShowDialogWhenStatusRequestIsSuccessfulButIndexIsEmpty.

@Test
public void testShowDialogWhenStatusRequestIsSuccessfulButIndexIsEmpty() throws Exception {
    MessageDialog messageDialog = mock(MessageDialog.class);
    when(constant.messagesWarningTitle()).thenReturn("Warning");
    when(constant.indexIsEmpty()).thenReturn("Index is Empty");
    when(dialogFactory.createMessageDialog(anyString(), anyString(), anyObject())).thenReturn(messageDialog);
    final Status status = mock(Status.class);
    List<String> changes = new ArrayList<>();
    when(status.getAdded()).thenReturn(changes);
    when(status.getChanged()).thenReturn(changes);
    when(status.getRemoved()).thenReturn(changes);
    presenter.showDialog(project);
    verify(statusPromise).then(statusPromiseCaptor.capture());
    statusPromiseCaptor.getValue().apply(status);
    verify(dialogFactory).createMessageDialog(eq("Warning"), eq("Index is Empty"), anyObject());
    verify(view, never()).setIndexedFiles(anyObject());
    verify(view, never()).showDialog();
}
Also used : Status(org.eclipse.che.api.git.shared.Status) ArrayList(java.util.ArrayList) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) Matchers.anyString(org.mockito.Matchers.anyString) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Aggregations

Status (org.eclipse.che.api.git.shared.Status)9 ArrayList (java.util.ArrayList)6 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)5 Test (org.junit.Test)5 Matchers.anyString (org.mockito.Matchers.anyString)5 Operation (org.eclipse.che.api.promises.client.Operation)3 IndexFile (org.eclipse.che.api.git.shared.IndexFile)2 Test (org.testng.annotations.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Files (com.google.common.io.Files)1 JSch (com.jcraft.jsch.JSch)1 JSchException (com.jcraft.jsch.JSchException)1 Session (com.jcraft.jsch.Session)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1