use of com.openshift.restclient.model.IProject 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 com.openshift.restclient.model.IProject 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 com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class NewApplicationWizardModelTest method setProjectShouldReturnSameProject.
@Test
public void setProjectShouldReturnSameProject() {
// pre-conditions
assertThat(model.getProjectItems().size()).isGreaterThan(2);
IProject project2 = (IProject) model.getProjectItems().get(1).getModel();
// operations
model.setProject(project2);
// verification
assertThat(model.getProject()).isEqualTo(project2);
}
use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class DeployImageJob method generateResources.
private Map<String, IResource> generateResources(final Connection connection, final String name) {
final IResourceFactory factory = connection.getResourceFactory();
final IProject project = parameters.getProject();
DockerImageURI sourceImage = getSourceImage();
Map<String, IResource> resources = new HashMap<>(4);
IImageStream is = stubImageStream(factory, name, project, sourceImage);
if (is != null && StringUtils.isBlank(is.getResourceVersion())) {
resources.put(ResourceKind.IMAGE_STREAM, is);
}
resources.put(ResourceKind.SERVICE, stubService(factory, name, SELECTOR_KEY, name));
if (parameters.isAddRoute()) {
resources.put(ResourceKind.ROUTE, stubRoute(factory, name, resources.get(ResourceKind.SERVICE).getName()));
}
resources.put(ResourceKind.DEPLOYMENT_CONFIG, stubDeploymentConfig(factory, name, sourceImage, is));
addToGeneratedResources(resources, connection, name, project);
for (IResource resource : resources.values()) {
addLabelsToResource(resource);
resource.setAnnotation(OpenShiftAPIAnnotations.GENERATED_BY, JBOSSTOOLS_OPENSHIFT);
}
return resources;
}
use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class ConnectionWrapper method startLoadJob.
void startLoadJob(ProjectWrapper projectWrapper, IExceptionHandler handler) {
new Job(NLS.bind("Loading OpenShift project {0}...", projectWrapper.getWrapped().getName())) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
IProject project = projectWrapper.getWrapped();
IOpenShiftConnection connection = projectWrapper.getParent().getWrapped();
WatchManager.getInstance().startWatch(project, connection);
Collection<IResource> resources = new HashSet<>();
for (String kind : RESOURCE_KINDS) {
resources.addAll(getWrapped().getResources(kind, project.getNamespaceName()));
}
resources.forEach(r -> resourceCache.add(r));
projectWrapper.initWithResources(resources);
projectWrapper.fireChanged();
} catch (OperationCanceledException e) {
projectWrapper.setLoadingState(LoadingState.LOAD_STOPPED);
} catch (Throwable e) {
projectWrapper.setLoadingState(LoadingState.LOAD_STOPPED);
handler.handleException(e);
}
return Status.OK_STATUS;
}
}.schedule();
}
Aggregations