use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProviderTest method getStyledTextForAProject.
@Test
public void getStyledTextForAProject() {
String displayName = "The Display Name";
String namespace = "anamespace";
IProject project = givenAResource(IProject.class, ResourceKind.PROJECT);
when(project.getDisplayName()).thenReturn(displayName);
when(project.getNamespaceName()).thenReturn(namespace);
assertEquals(project.getDisplayName() + " " + project.getName(), provider.getStyledText(project).getString());
}
use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProviderTest method getStyledTextForAProjectWithoutDisplayName.
@Test
public void getStyledTextForAProjectWithoutDisplayName() {
String displayName = "The Display Name";
String namespace = "anamespace";
IProject project = givenAResource(IProject.class, ResourceKind.PROJECT);
when(project.getName()).thenReturn(displayName);
when(project.getNamespaceName()).thenReturn(namespace);
assertEquals(project.getName(), provider.getStyledText(project).getString());
}
use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModelTest method loadResources_should_reset_project_if_not_contained_in_loaded_project.
@Test
public void loadResources_should_reset_project_if_not_contained_in_loaded_project() {
// given
IProject selectedProject = mock(IProject.class);
model.setProject(selectedProject);
IProject project1 = mock(IProject.class);
IProject project2 = mock(IProject.class);
createModelProjects(this.connection, project1, project2);
model.setResourcesLoaded(false);
// when
model.loadResources();
// then
assertThat(model.getProject()).isNotEqualTo(selectedProject);
assertThat(model.getProject()).isEqualTo(project1);
}
use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModelTest method addProject_should_not_reset_project.
@Test
public void addProject_should_not_reset_project() {
// given
IProject project1 = mock(IProject.class);
// when
model.addProject(project1);
assertThat(model.getProject()).isEqualTo(project);
}
use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class DeployImageHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Connection connection = null;
IProject project = null;
ISelection selection = HandlerUtil.getCurrentSelection(event);
final IDockerImage image = UIUtils.getFirstElement(selection, IDockerImage.class);
if (image == null || OpenShiftUIUtils.hasOpenShiftExplorerSelection()) {
selection = OpenShiftUIUtils.getOpenShiftExplorerSelection();
project = ResourceUtils.getProject(UIUtils.getFirstElement(selection, IResource.class));
if (project != null) {
connection = ConnectionsRegistryUtil.getConnectionFor(project);
} else {
connection = UIUtils.getFirstElement(selection, Connection.class);
}
}
if (connection == null) {
connection = OpenShiftUIUtils.getExplorerDefaultConnection(Connection.class);
}
IDockerConnection dockerConnection = null;
if (image != null) {
dockerConnection = image.getConnection();
} else if (OpenShiftUIUtils.hasDockerExplorerSelection()) {
ISelection dockerSelection = OpenShiftUIUtils.getDockerExplorerSelection();
dockerConnection = UIUtils.getFirstElement(dockerSelection, IDockerConnection.class);
if (dockerConnection == null) {
// Action is originated from OpenShift Explorer, do the best to pick up Docker connection from the current selection in Docker Explorer.
IDockerImage selectedImage = UIUtils.getFirstElement(dockerSelection, IDockerImage.class);
if (selectedImage != null) {
dockerConnection = selectedImage.getConnection();
}
}
}
runWizard(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), dockerConnection, image, project, connection);
return null;
}
Aggregations