use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorterTest method blobShouldBeGreaterThanWorkingTree.
/*
* Tests for GitModelBlob
*/
@Test
public void blobShouldBeGreaterThanWorkingTree() {
// given
Viewer viewer = mock(Viewer.class);
GitChangeSetSorter sorter = new GitChangeSetSorter();
GitModelBlob blob = mock(GitModelBlob.class);
GitModelWorkingTree workingTree = mock(GitModelWorkingTree.class);
// when
int actual = sorter.compare(viewer, blob, workingTree);
// then
assertTrue(actual > 0);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitAdapterFactory method getAdapter.
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType.isAssignableFrom(IHistoryPageSource.class)) {
return GitHistoryPageSource.INSTANCE;
}
if (IWorkbenchAdapter.class == adapterType) {
// property page names for git repository tree nodes
if (adaptableObject instanceof RepositoryTreeNode) {
return getRepositoryTreeNodeWorkbenchAdapter((RepositoryTreeNode) adaptableObject);
}
if (gitModelWorkbenchAdapter == null) {
gitModelWorkbenchAdapter = new GitModelWorkbenchAdapter();
}
return gitModelWorkbenchAdapter;
}
if (adaptableObject instanceof IHistoryView && IShowInSource.class == adapterType) {
IHistoryView historyView = (IHistoryView) adaptableObject;
IHistoryPage historyPage = historyView.getHistoryPage();
if (historyPage instanceof GitHistoryPage) {
return historyPage;
}
}
if (adaptableObject instanceof IURIEditorInput && adapterType == Repository.class) {
return getRepository((IURIEditorInput) adaptableObject);
}
if (adaptableObject instanceof IURIEditorInput && adapterType == File.class) {
return getFile((IURIEditorInput) adaptableObject);
}
if (adaptableObject instanceof GitModelObject && adapterType == ResourceMapping.class) {
return GitObjectMapping.create((GitModelObject) adaptableObject);
}
if (adaptableObject instanceof GitModelObject && adapterType == IResource.class) {
GitModelObject obj = (GitModelObject) adaptableObject;
if (obj instanceof GitModelBlob) {
IResource res = ResourceUtil.getFileForLocation(obj.getLocation(), false);
if (res == null) {
// Deleted resource?
res = getWorkspaceResourceFromGitPath(obj.getLocation());
}
return res;
}
if (obj instanceof GitModelTree) {
IResource res = root.getContainerForLocation(obj.getLocation());
if (res == null) {
res = root.getFolder(obj.getLocation());
}
return res;
}
}
if (adapterType == Repository.class) {
ResourceMapping m = AdapterUtils.adapt(adaptableObject, ResourceMapping.class);
if (m != null) {
return SelectionUtils.getRepository(new StructuredSelection(m));
}
}
return null;
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorterTest method blobShouldBeGreaterThanCommit.
@Test
public void blobShouldBeGreaterThanCommit() {
// given
Viewer viewer = mock(Viewer.class);
GitChangeSetSorter sorter = new GitChangeSetSorter();
GitModelBlob blob = mock(GitModelBlob.class);
GitModelCommit commit = mock(GitModelCommit.class);
// when
int actual = sorter.compare(viewer, blob, commit);
// then
assertTrue(actual > 0);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorterTest method cacheTreeShouldBeLessThanBlob.
@Test
public void cacheTreeShouldBeLessThanBlob() {
// given
Viewer viewer = mock(Viewer.class);
GitChangeSetSorter sorter = new GitChangeSetSorter();
GitModelCache cache = mock(GitModelCache.class);
GitModelBlob blob = mock(GitModelBlob.class);
// when
int actual = sorter.compare(viewer, cache, blob);
// then
assertTrue(actual < 0);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorterTest method treeShouldBeLessThanBlob.
@Test
public void treeShouldBeLessThanBlob() {
// given
Viewer viewer = mock(Viewer.class);
GitChangeSetSorter sorter = new GitChangeSetSorter();
GitModelTree tree = mock(GitModelTree.class);
GitModelBlob blob = mock(GitModelBlob.class);
// when
int actual = sorter.compare(viewer, tree, blob);
// then
assertTrue(actual < 0);
}
Aggregations