Search in sources :

Example 46 with IResource

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

the class OpenShiftResourceUniqueIdTest method should_return_correct_resource_by_uniqueId.

@Test
public void should_return_correct_resource_by_uniqueId() {
    // given
    IResource toBeFound = ResourceMocks.PROJECT2;
    List<IResource> resources = Arrays.asList(ResourceMocks.PROJECT1, toBeFound, ResourceMocks.PROJECT3);
    String uniqueId = OpenShiftResourceUniqueId.get(toBeFound);
    // when
    IResource found = OpenShiftResourceUniqueId.getByUniqueId(uniqueId, resources);
    // then
    assertThat(found).isSameAs(toBeFound);
}
Also used : IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 47 with IResource

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

the class OpenShiftResourceUniqueIdTest method should_return_unique_uniqueId.

@Test
public void should_return_unique_uniqueId() {
    // given
    IResource resource1 = ResourceMocks.PROJECT1;
    IResource resource2 = ResourceMocks.PROJECT2;
    // when
    String uniqueId1 = OpenShiftResourceUniqueId.get(resource1);
    String uniqueId2 = OpenShiftResourceUniqueId.get(resource2);
    // then
    assertThat(uniqueId1).isNotEmpty();
    assertThat(uniqueId2).isNotEmpty();
    assertThat(uniqueId1).isNotEqualTo(uniqueId2);
}
Also used : IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 48 with IResource

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

the class OpenShiftResourceUniqueIdTest method should_return_correct_correct_resourcename.

@Test
public void should_return_correct_correct_resourcename() {
    // given
    IResource resource = ResourceMocks.PROJECT2_SERVICES[0];
    String uniqueId = OpenShiftResourceUniqueId.get(resource);
    // when
    String resourceName = OpenShiftResourceUniqueId.getResourceName(uniqueId);
    // then
    assertThat(resourceName).isEqualTo(resource.getName());
}
Also used : IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 49 with IResource

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

the class ServerResourceViewModelWithDeploymentConfigTest method shouldReturnResourceIfResourcesAreLoaded.

@Test
public void shouldReturnResourceIfResourcesAreLoaded() {
    // given
    model.loadResources();
    // when
    IResource resource = model.getResource();
    // then
    assertThat(resource).isEqualTo(selectedDeploymentConfig);
}
Also used : IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 50 with IResource

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

the class DeployImageJobTest method shouldUpdateImageTagIfItDifferesFromExisting.

@Test
public void shouldUpdateImageTagIfItDifferesFromExisting() {
    givenAConnection();
    givenTheImageStreamExistsTo("myimagename");
    givenTheDeploymentConfigExistFor("myimagename", "v0", NAMESPACE, ResourceKind.IMAGE_STREAM_TAG);
    doReturn(DOCKER_NEW_TAG).when(job).getSourceImage();
    IResource resource = connection.getResource(ResourceKind.DEPLOYMENT_CONFIG, project.getName(), parameters.getResourceName());
    IDeploymentImageChangeTrigger trigger = (IDeploymentImageChangeTrigger) ((IDeploymentConfig) resource).getTriggers().toArray()[0];
    assertThat(job.doRun(monitor)).isEqualTo(Status.OK_STATUS);
    verify(trigger, times(1)).setFrom(new DockerImageURI(null, null, "myimagename", "v1"));
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) IDeploymentImageChangeTrigger(com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger) IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Aggregations

IResource (com.openshift.restclient.model.IResource)101 Test (org.junit.Test)32 Connection (org.jboss.tools.openshift.core.connection.Connection)27 IProject (com.openshift.restclient.model.IProject)14 IStatus (org.eclipse.core.runtime.IStatus)12 Collection (java.util.Collection)10 ServerResourceViewModel (org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel)9 IReplicationController (com.openshift.restclient.model.IReplicationController)8 IService (com.openshift.restclient.model.IService)8 ArrayList (java.util.ArrayList)8 CoreException (org.eclipse.core.runtime.CoreException)8 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)7 Status (org.eclipse.core.runtime.Status)7 ISelection (org.eclipse.jface.viewers.ISelection)7 OpenShiftException (com.openshift.restclient.OpenShiftException)6 ResourceKind (com.openshift.restclient.ResourceKind)6 IPod (com.openshift.restclient.model.IPod)6 List (java.util.List)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IBuildConfig (com.openshift.restclient.model.IBuildConfig)5