Search in sources :

Example 6 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceAdapterTest method testDecorationNewFile.

@Test
public void testDecorationNewFile() throws Exception {
    // Create new file
    write(new File(project.getLocation().toFile(), TEST_FILE), "Something");
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    IResource file = project.findMember(TEST_FILE);
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked().dirty(), new TestDecoratableResource(file) };
    waitForIndexDiffUpdate(true);
    IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
    IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, file) };
    assertArrayEquals(expectedDRs, actualDRs);
}
Also used : File(java.io.File) IResource(org.eclipse.core.resources.IResource) IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) Test(org.junit.Test)

Example 7 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceAdapterTest method testDecorationNewEmptyFolder.

@Test
public void testDecorationNewEmptyFolder() throws Exception {
    // Create new folder with sub folder
    IFolder folder = project.getFolder(TEST_FOLDER);
    folder.create(true, true, null);
    IFolder subFolder = folder.getFolder(SUB_FOLDER);
    subFolder.create(true, true, null);
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked(), new TestDecoratableResource(folder).ignored(), new TestDecoratableResource(subFolder).ignored() };
    waitForIndexDiffUpdate(true);
    IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
    IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, folder), new DecoratableResourceAdapter(indexDiffData, subFolder) };
    assertArrayEquals(expectedDRs, actualDRs);
}
Also used : IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 8 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceAdapterTest method testDecorationFolderPrefixOfOtherFolder.

@Test
public void testDecorationFolderPrefixOfOtherFolder() throws Exception {
    project.getFolder(TEST_FOLDER).create(true, true, null);
    IFolder testFolder2 = project.getFolder(TEST_FOLDER2);
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(testFolder2).tracked() };
    waitForIndexDiffUpdate(true);
    IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
    IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, testFolder2) };
    assertArrayEquals(expectedDRs, actualDRs);
}
Also used : IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 9 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceAdapterTest method testDecorationNewFileInSubfolder.

@Test
public void testDecorationNewFileInSubfolder() throws Exception {
    // Create new folder with sub folder
    IFolder folder = project.getFolder(TEST_FOLDER);
    folder.create(true, true, null);
    IFolder subFolder = folder.getFolder(SUB_FOLDER);
    subFolder.create(true, true, null);
    // Create new file
    write(new File(subFolder.getLocation().toFile().getAbsolutePath(), TEST_FILE), "Something");
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    IResource file = subFolder.findMember(TEST_FILE);
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked().dirty(), new TestDecoratableResource(folder).dirty(), new TestDecoratableResource(subFolder).dirty(), new TestDecoratableResource(file) };
    waitForIndexDiffUpdate(true);
    IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
    IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, folder), new DecoratableResourceAdapter(indexDiffData, subFolder), new DecoratableResourceAdapter(indexDiffData, file) };
    for (int i = 0; i < expectedDRs.length; i++) assert (expectedDRs[i].equals(actualDRs[i]));
}
Also used : File(java.io.File) IResource(org.eclipse.core.resources.IResource) IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 10 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceMappingTest method testMixedStagingStateIsModified_RemovedAdded.

@Test
public void testMixedStagingStateIsModified_RemovedAdded() throws Exception {
    gitAdd(git, rmContentA);
    gitCommit(git);
    gitRemove(git, rmContentA);
    gitAdd(git, rmContentB);
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { newExpectedDecoratableResource(rmContentA).tracked().removed(), newExpectedDecoratableResource(rmContentB).tracked().added(), newExpectedDecoratableResourceMapping().tracked().modified() };
    IndexDiffData indexDiffData = waitForIndexDiff(true);
    IDecoratableResource[] actualDRs = { newDecoratableResource(indexDiffData, rmContentA), newDecoratableResource(indexDiffData, rmContentB), newDecoratableResourceMapping(resourceMapping) };
    assertArrayEquals(expectedDRs, actualDRs);
    assertDecorationStaged(resourceMapping);
}
Also used : IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) Test(org.junit.Test)

Aggregations

IndexDiffData (org.eclipse.egit.core.internal.indexdiff.IndexDiffData)47 Test (org.junit.Test)34 IResource (org.eclipse.core.resources.IResource)14 File (java.io.File)11 IFile (org.eclipse.core.resources.IFile)10 IndexDiffCacheEntry (org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry)9 RevCommit (org.eclipse.jgit.revwalk.RevCommit)6 IFolder (org.eclipse.core.resources.IFolder)4 MergeResult (org.eclipse.jgit.api.MergeResult)4 Repository (org.eclipse.jgit.lib.Repository)4 IOException (java.io.IOException)3 CoreException (org.eclipse.core.runtime.CoreException)3 IndexDiffCache (org.eclipse.egit.core.internal.indexdiff.IndexDiffCache)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IndexDiffChangedListener (org.eclipse.egit.core.internal.indexdiff.IndexDiffChangedListener)2