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);
}
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);
}
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());
}
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));
}
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]);
}
Aggregations