Search in sources :

Example 1 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModelWithServiceTest method shouldReturnNewServiceItemsIfLoadResourcesWithConnection.

@Test
public void shouldReturnNewServiceItemsIfLoadResourcesWithConnection() {
    // given
    List<ObservableTreeItem> serviceItems = new ArrayList<>(model.getResourceItems());
    Connection connection = ResourceMocks.createConnection("http://localhost:8080", "dev@42.org");
    IProject project = ResourceMocks.createResource(IProject.class, ResourceKind.PROJECT);
    when(connection.getResources(ResourceKind.PROJECT)).thenReturn(Collections.singletonList(project));
    IService service = ResourceMocks.createResource(IService.class, ResourceKind.SERVICE);
    when(project.getResources(ResourceKind.SERVICE)).thenReturn(Collections.singletonList(service));
    // when
    model.loadResources(connection);
    // then
    List<ObservableTreeItem> newServiceItems = model.getResourceItems();
    assertThat(newServiceItems).isNotEqualTo(serviceItems);
}
Also used : ArrayList(java.util.ArrayList) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IProject(com.openshift.restclient.model.IProject) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 2 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class NewApplicationWizardModelTest method setProjectItemsShouldPreserveSelectedProjectIfContained.

@Test
public void setProjectItemsShouldPreserveSelectedProjectIfContained() {
    // pre-conditions
    this.projectItems.add(new ObservableTreeItem(project));
    model.setProject(project);
    IProject selectedProject = model.getProject();
    assertThat(selectedProject).isNotNull();
    // operations
    model.setProjectItems(projectItems);
    // verification
    assertThat(model.getProject()).isEqualTo(selectedProject);
}
Also used : ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IProject(com.openshift.restclient.model.IProject) Test(org.junit.Test)

Example 3 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class NewApplicationWizardModelTest method setProjectItemsShouldSelect1stProjectIfCurrentNotContained.

@Test
public void setProjectItemsShouldSelect1stProjectIfCurrentNotContained() {
    // pre-conditions
    model.setProject(project);
    // operations
    model.setProjectItems(projectItems);
    // verification
    ObservableTreeItem projectItem = projectItems.get(0);
    assertThat(projectItem).isNotNull();
    assertThat(model.getProject()).isEqualTo(projectItem.getModel());
}
Also used : ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) Test(org.junit.Test)

Example 4 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class NewApplicationWizardModelTest method setProjectToProject2ShouldHaveGetTemplatesReturnTemplatesForProject2.

@Test
public void setProjectToProject2ShouldHaveGetTemplatesReturnTemplatesForProject2() {
    // pre-conditions
    IProject project2 = getProject(1);
    // operations
    model.setProject(project2);
    List<ObservableTreeItem> templates = model.getAppSources();
    // verification
    assertThat(templates).containsAll(getTemplateItemsForProject(1));
}
Also used : ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IProject(com.openshift.restclient.model.IProject) Test(org.junit.Test)

Example 5 with ObservableTreeItem

use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem in project jbosstools-openshift by jbosstools.

the class ProjectTreeSorterTest method testProjectItemsWithLabelProvider.

@Test
public void testProjectItemsWithLabelProvider() {
    final Comparator<ObservableTreeItem> comparator = new ProjectViewerComparator(new OpenShiftExplorerLabelProvider()).asItemComparator();
    ObservableTreeItem p1 = new ObservableTreeItem(mockProject("default", "z"));
    ObservableTreeItem p2 = new ObservableTreeItem(mockProject("openshift", "y"));
    ObservableTreeItem p3 = new ObservableTreeItem(mockProject("a", "c"));
    ObservableTreeItem p4 = new ObservableTreeItem(mockProject("b2", null));
    ObservableTreeItem p5 = new ObservableTreeItem(mockProject("d", "b"));
    ObservableTreeItem[] projects = new ObservableTreeItem[] { p3, p5, p2, p1, p4 };
    Arrays.sort(projects, comparator);
    assertEquals(p1, projects[0]);
    assertEquals(p2, projects[1]);
    assertEquals(p5, projects[2]);
    assertEquals(p4, projects[3]);
    assertEquals(p3, projects[4]);
}
Also used : OpenShiftExplorerLabelProvider(org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) ProjectViewerComparator(org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator) Test(org.junit.Test)

Aggregations

ObservableTreeItem (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem)16 Test (org.junit.Test)10 IProject (com.openshift.restclient.model.IProject)5 Connection (org.jboss.tools.openshift.core.connection.Connection)4 ProjectViewerComparator (org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator)4 ArrayList (java.util.ArrayList)3 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)3 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)3 IReplicationController (com.openshift.restclient.model.IReplicationController)2 IResource (com.openshift.restclient.model.IResource)2 IService (com.openshift.restclient.model.IService)2 MultiListProperty (org.eclipse.core.databinding.property.list.MultiListProperty)2 ObservableListTreeContentProvider (org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 OpenShiftExplorerLabelProvider (org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider)2 IBuildConfig (com.openshift.restclient.model.IBuildConfig)1 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)1 IRoute (com.openshift.restclient.model.route.IRoute)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1