Search in sources :

Example 11 with IDeploymentConfig

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

the class ResourceUtilsTest method shouldReturnNullGivenNoDCNameSelectorNorRCisFoundForService.

@Test
public void shouldReturnNullGivenNoDCNameSelectorNorRCisFoundForService() throws CoreException {
    // given
    Connection connection = ResourceMocks.create3ProjectsConnection();
    IService service = ResourceMocks.PROJECT2_SERVICES[0];
    // when
    IDeploymentConfig dc = ResourceUtils.getDeploymentConfigFor(service, connection);
    // then
    assertThat(dc).isNull();
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 12 with IDeploymentConfig

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

the class ResourceUtilsTest method shouldReturnDeploymentConfigForServiceByNameGivenServiceHasDCNameSelector.

@Test
public void shouldReturnDeploymentConfigForServiceByNameGivenServiceHasDCNameSelector() throws CoreException {
    // given
    Connection connection = ResourceMocks.create3ProjectsConnection();
    IService service = ResourceMocks.PROJECT2_SERVICES[1];
    // when
    IDeploymentConfig dc = ResourceUtils.getDeploymentConfigFor(service, connection);
    // then
    assertThat(dc).isEqualTo(ResourceMocks.PROJECT2_DEPLOYMENTCONFIGS[2]);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 13 with IDeploymentConfig

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

the class DeployImageJobTest method shouldNotUpdateIfNoImageChangeTrigger.

@Test
public void shouldNotUpdateIfNoImageChangeTrigger() {
    givenAConnection();
    givenTheImageStreamExistsTo("myimagename");
    IDeploymentConfig dc = createResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG);
    when(dc.getTriggers()).thenReturn(Collections.EMPTY_LIST);
    when(connection.getResource(ResourceKind.DEPLOYMENT_CONFIG, project.getName(), parameters.getResourceName())).thenReturn(dc);
    assertFalse(job.updateTriggerIfUpdate(connection, project.getName(), parameters.getResourceName()));
}
Also used : IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) Test(org.junit.Test)

Example 14 with IDeploymentConfig

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

the class OpenShiftExplorerLabelProviderTest method getStyledTextForADeploymentConfig.

@Test
public void getStyledTextForADeploymentConfig() {
    IDeploymentConfig config = givenAResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG);
    Map<String, String> selector = new HashMap<>();
    selector.put("name", "foo");
    selector.put("deployment", "bar");
    when(config.getReplicaSelector()).thenReturn(selector);
    assertEquals(config.getName() + " selector: deployment=bar,name=foo", provider.getStyledText(config).getString());
}
Also used : HashMap(java.util.HashMap) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) StyledString(org.eclipse.jface.viewers.StyledString) Test(org.junit.Test)

Example 15 with IDeploymentConfig

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

the class ServerResourceViewModelWithDeploymentConfigTest method shouldReturnNewSelectedDeploymentConfigIfLoadResourcesWithConnection.

@Test
public void shouldReturnNewSelectedDeploymentConfigIfLoadResourcesWithConnection() {
    // given
    IResource selectedDeploymentConfig = model.getResource();
    Connection connection = ResourceMocks.createConnection("https://localhost:8181", "ops@42.org");
    ConnectionsRegistrySingleton.getInstance().add(connection);
    try {
        IProject project = ResourceMocks.createResource(IProject.class, ResourceKind.PROJECT);
        when(connection.getResources(ResourceKind.PROJECT)).thenReturn(Collections.singletonList(project));
        IDeploymentConfig deploymentConfig = ResourceMocks.createResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG);
        when(project.getResources(ResourceKind.DEPLOYMENT_CONFIG)).thenReturn(Collections.singletonList(deploymentConfig));
        // when
        model.loadResources(connection);
        // then
        IResource newSelectedDeploymentConfig = model.getResource();
        assertThat(selectedDeploymentConfig).isNotEqualTo(newSelectedDeploymentConfig);
    } finally {
        ConnectionsRegistrySingleton.getInstance().remove(connection);
    }
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IResource(com.openshift.restclient.model.IResource) IProject(com.openshift.restclient.model.IProject) Test(org.junit.Test)

Aggregations

IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)24 Test (org.junit.Test)11 Connection (org.jboss.tools.openshift.core.connection.Connection)9 IResource (com.openshift.restclient.model.IResource)8 IService (com.openshift.restclient.model.IService)7 IDeploymentImageChangeTrigger (com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)7 DockerImageURI (com.openshift.restclient.images.DockerImageURI)6 IProject (com.openshift.restclient.model.IProject)5 Collection (java.util.Collection)4 ResourceKind (com.openshift.restclient.ResourceKind)3 IImageStream (com.openshift.restclient.model.IImageStream)3 IReplicationController (com.openshift.restclient.model.IReplicationController)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 List (java.util.List)3 IServiceWrapper (org.jboss.tools.openshift.internal.ui.models.IServiceWrapper)3 IClient (com.openshift.restclient.IClient)2 IResourceFactory (com.openshift.restclient.IResourceFactory)2 IPod (com.openshift.restclient.model.IPod)2