Search in sources :

Example 6 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class ImportApplicationWizardModelTest method shouldReturnNullWhenCallingGetSelectedBuildConfigIfNoBuildConfigIsSelected.

@Test
public void shouldReturnNullWhenCallingGetSelectedBuildConfigIfNoBuildConfigIsSelected() {
    // given
    model.setSelectedItem(p2);
    // when
    IBuildConfig bc = model.getSelectedBuildConfig();
    // then
    assertThat(bc).isNull();
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) Test(org.junit.Test)

Example 7 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class ServiceResourceMapper method getRelatedBuilds.

private static Collection<IBuild> getRelatedBuilds(Collection<IResource> resources, Collection<String> dcImageRefs, Collection<IBuildConfig> buildConfigs) {
    Collection<IBuild> result = new HashSet<>();
    Collection<String> bcNames = buildConfigs.stream().map(bc -> bc.getName()).collect(Collectors.toSet());
    resources.forEach(r -> {
        if (r instanceof IBuild) {
            IBuild build = (IBuild) r;
            if (bcNames.contains(r.getLabels().get(OpenShiftAPIAnnotations.BUILD_CONFIG_NAME)) || dcImageRefs.contains(imageRef(build))) {
                result.add((IBuild) r);
            }
        }
    });
    return result;
}
Also used : IResource(com.openshift.restclient.model.IResource) ResourceKind(com.openshift.restclient.ResourceKind) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Collection(java.util.Collection) IBuild(com.openshift.restclient.model.IBuild) ResourceUtils(org.jboss.tools.openshift.internal.core.util.ResourceUtils) ResourceUtils.imageRef(org.jboss.tools.openshift.internal.core.util.ResourceUtils.imageRef) IDeploymentImageChangeTrigger(com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) HashSet(java.util.HashSet) IPod(com.openshift.restclient.model.IPod) OpenShiftAPIAnnotations(org.jboss.tools.openshift.core.OpenShiftAPIAnnotations) IRoute(com.openshift.restclient.model.route.IRoute) DeploymentTriggerType(com.openshift.restclient.model.deploy.DeploymentTriggerType) Collections(java.util.Collections) IReplicationController(com.openshift.restclient.model.IReplicationController) IService(com.openshift.restclient.model.IService) IBuild(com.openshift.restclient.model.IBuild) HashSet(java.util.HashSet)

Example 8 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class ImportApplicationWizardModelTest method shouldReturnSelectedBuildConfig.

@Test
public void shouldReturnSelectedBuildConfig() {
    // given
    model.setSelectedItem(p2_bc1);
    // when
    IBuildConfig bc = model.getSelectedBuildConfig();
    // then
    assertThat(bc).isEqualTo(p2_bc1);
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) Test(org.junit.Test)

Example 9 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class ImportApplicationWizardModel method update.

private void update(Connection connection, Object selectedItem, String cloneDestination, boolean useDefaultCloneDestination, IProject project, boolean reuseGitRepo, boolean checkoutBranchReusedRepo, String gitContextDir) {
    this.connectionItem = updateConnection(connection);
    this.project = project;
    Object oldSelectedItem = this.selectedItem;
    updateSelectedItem(selectedItem);
    updateUseDefaultCloneDestination(useDefaultCloneDestination);
    updateCloneDestination(cloneDestination);
    IBuildConfig buildConfig = getBuildConfig(selectedItem);
    String repoName = updateRepoName(buildConfig);
    String oldRepoPath = this.repoPath;
    String newRepoPath = updateRepoPath(cloneDestination, repoName);
    reuseGitRepo = updateReuseGitRepo(reuseGitRepo, newRepoPath, oldRepoPath);
    String gitRef = updateGitRef(getGitRef(buildConfig));
    Repository repository = updateRepository(newRepoPath, oldRepoPath);
    boolean isRepositoryAtGitRef = updateIsRepositoryAtGitRef(gitRef, repository);
    updateCheckoutBranchReusedRepo(checkoutBranchReusedRepo, isRepositoryAtGitRef);
    updateGitContextDir(gitContextDir, buildConfig, getBuildConfig(oldSelectedItem));
}
Also used : Repository(org.eclipse.jgit.lib.Repository) IBuildConfig(com.openshift.restclient.model.IBuildConfig)

Example 10 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class ResourceDetailsLabelProviderTest method getStyledTextForResourceWithoutParams.

@Test
public void getStyledTextForResourceWithoutParams() {
    IBuildConfig buildConfig = mock(IBuildConfig.class);
    when(buildConfig.getKind()).thenReturn(ResourceKind.BUILD_CONFIG);
    when(buildConfig.getName()).thenReturn("build-config-name");
    assertEquals(ResourceKind.BUILD_CONFIG + " build-config-name", labelsProvider.getStyledText(buildConfig).toString());
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) Test(org.junit.Test)

Aggregations

IBuildConfig (com.openshift.restclient.model.IBuildConfig)29 Test (org.junit.Test)12 IService (com.openshift.restclient.model.IService)5 IResource (com.openshift.restclient.model.IResource)4 Collection (java.util.Collection)4 DockerImageURI (com.openshift.restclient.images.DockerImageURI)3 IProject (com.openshift.restclient.model.IProject)3 ISourceBuildStrategy (com.openshift.restclient.model.build.ISourceBuildStrategy)3 IRoute (com.openshift.restclient.model.route.IRoute)3 ResourceKind (com.openshift.restclient.ResourceKind)2 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)2 IBuildStrategy (com.openshift.restclient.model.build.IBuildStrategy)2 ICustomBuildStrategy (com.openshift.restclient.model.build.ICustomBuildStrategy)2 IDockerBuildStrategy (com.openshift.restclient.model.build.IDockerBuildStrategy)2 IWebhookTrigger (com.openshift.restclient.model.build.IWebhookTrigger)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 IStatus (org.eclipse.core.runtime.IStatus)2