use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class ImportApplicationHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = UIUtils.getCurrentSelection(event);
IBuildConfig buildConfig = UIUtils.getFirstElement(currentSelection, IBuildConfig.class);
Map<IProject, Collection<IBuildConfig>> projectsAndBuildConfigs = null;
IProject project = null;
Collection<IBuildConfig> buildConfigs = null;
if (buildConfig == null) {
IResource resource = UIUtils.getFirstElement(currentSelection, IResource.class);
if (resource != null) {
project = resource.getProject();
}
if (project != null) {
buildConfigs = project.getResources(ResourceKind.BUILD_CONFIG);
}
} else {
project = buildConfig.getProject();
buildConfigs = Collections.singleton(buildConfig);
}
if (project != null) {
if (buildConfigs == null || buildConfigs.isEmpty()) {
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), NO_BUILD_CONFIG_MSG, NO_BUILD_CONFIG_MSG);
return OpenShiftUIActivator.statusFactory().cancelStatus(NO_BUILD_CONFIG_MSG);
}
projectsAndBuildConfigs = Collections.singletonMap(project, buildConfigs);
}
if (projectsAndBuildConfigs == null) {
ImportApplicationWizard wizard = new ImportApplicationWizard();
Connection connection = UIUtils.getFirstElement(currentSelection, Connection.class);
wizard.setConnection(connection);
WizardUtils.openWizardDialog(wizard, HandlerUtil.getActiveShell(event));
} else {
WizardUtils.openWizardDialog(new ImportApplicationWizard(projectsAndBuildConfigs), HandlerUtil.getActiveShell(event));
}
return Status.OK_STATUS;
}
use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class ShowWebHooksHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection selection = UIUtils.getCurrentSelection(event);
IBuildConfig buildConfig = UIUtils.getFirstElement(selection, IBuildConfig.class);
if (buildConfig == null) {
return Status.OK_STATUS;
}
WebHooksDialog dialog = new WebHooksDialog(HandlerUtil.getActiveShell(event), buildConfig);
dialog.open();
return Status.OK_STATUS;
}
use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class OpenshiftEapProfileDetectorTest method createBuildConfig.
@SuppressWarnings("deprecation")
private IBuildConfig createBuildConfig(Class<? extends IBuildStrategy> clazz, String name) {
IBuildConfig bc = mock(IBuildConfig.class);
DockerImageURI image = mock(DockerImageURI.class);
when(image.getName()).thenReturn(name);
IBuildStrategy strategy = null;
if (clazz == null) {
strategy = mock(ISourceBuildStrategy.class);
} else if (IDockerBuildStrategy.class.isAssignableFrom(clazz)) {
IDockerBuildStrategy dbs = mock(IDockerBuildStrategy.class);
when(dbs.getBaseImage()).thenReturn(image);
strategy = dbs;
} else if (ICustomBuildStrategy.class.isAssignableFrom(clazz)) {
ICustomBuildStrategy cbs = mock(ICustomBuildStrategy.class);
when(cbs.getImage()).thenReturn(image);
strategy = cbs;
} else if (ISTIBuildStrategy.class.isAssignableFrom(clazz)) {
ISTIBuildStrategy sts = mock(ISTIBuildStrategy.class);
when(sts.getImage()).thenReturn(image);
strategy = sts;
} else if (ISourceBuildStrategy.class.isAssignableFrom(clazz)) {
ISourceBuildStrategy sbs = mock(ISourceBuildStrategy.class);
when(sbs.getImage()).thenReturn(image);
strategy = sbs;
}
when(bc.getBuildStrategy()).thenReturn(strategy);
Map<String, String> labels = Collections.singletonMap("template", name);
when(bc.getLabels()).thenReturn(labels);
return bc;
}
use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class ResourceMocks method createBuildConfig.
public static IBuildConfig createBuildConfig(String name, IProject project, String buildOutputReferenceKind, String buildOutputReferenceName, String buildSourceURI, String contextDir, String ref, IBuildStrategy strategy) {
IBuildConfig bc = mock(IBuildConfig.class);
doReturn(ResourceKind.BUILD_CONFIG).when(bc).getKind();
createBuildOutputReference(buildOutputReferenceKind, buildOutputReferenceName, bc);
createGitBuildSource(contextDir, ref, bc);
mockGetResourceProperties(name, project, bc);
doReturn(buildSourceURI).when(bc).getSourceURI();
doReturn(strategy).when(bc).getBuildStrategy();
return bc;
}
use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class ResourceDetailsContentProviderTest method shouldReturnResourcePropertyGivenBuildConfigBuildStrategyExists.
@Test
public void shouldReturnResourcePropertyGivenBuildConfigBuildStrategyExists() {
// given
IBuildConfig bc = createBuildConfig("42", null, null, null, null, null, null, createSourceBuildStrategy("42"));
// when
Object[] children = contentProvider.getChildren(bc);
// then
ResourceProperty property = getResourceProperty(ResourceDetailsContentProvider.LABEL_STRATEGY, children);
assertThat(property).isNotNull();
assertThat(property.isUnknownValue()).isFalse();
}
Aggregations