Search in sources :

Example 6 with ServerResourceViewModel

use of org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModelWithReplicationControllerTest method shouldReturnNullResourceIfResourcesNotLoaded.

@Test
public void shouldReturnNullResourceIfResourcesNotLoaded() {
    // given
    ServerResourceViewModel model = new ServerResourceViewModel(null);
    // when
    IResource resource = model.getResource();
    // then
    assertThat(resource).isNull();
}
Also used : ServerResourceViewModel(org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel) IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 7 with ServerResourceViewModel

use of org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModelWithReplicationControllerTest method shouldReturn1stServiceInListIfInitializedServiceIsNotInListOfAllReplicationControllers.

@Test
public void shouldReturn1stServiceInListIfInitializedServiceIsNotInListOfAllReplicationControllers() {
    // given
    IReplicationController otherReplicationController = ResourceMocks.createResource(IReplicationController.class, ResourceKind.REPLICATION_CONTROLLER);
    ServerResourceViewModel model = new ServerResourceViewModel(otherReplicationController, connection);
    model.loadResources();
    // when
    IResource service = model.getResource();
    // then
    assertThat(service).isEqualTo(ResourceMocks.PROJECT2_SERVICES[0]);
}
Also used : ServerResourceViewModel(org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel) IReplicationController(com.openshift.restclient.model.IReplicationController) IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 8 with ServerResourceViewModel

use of org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModelWithDeploymentConfigTest method shouldSetNewConnectionIfLoadingWithConnection.

@Test
public void shouldSetNewConnectionIfLoadingWithConnection() {
    // given
    ServerResourceViewModel model = new ServerResourceViewModel(null);
    model.loadResources();
    assertThat(model.getConnection()).isNull();
    // when
    model.loadResources(connection);
    // then
    assertThat(model.getConnection()).isEqualTo(connection);
}
Also used : ServerResourceViewModel(org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel) Test(org.junit.Test)

Example 9 with ServerResourceViewModel

use of org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModelWithDeploymentConfigTest method shouldReturn1stServiceInListIfInitializedServiceIsNotInListOfAllDeploymentConfigs.

@Test
public void shouldReturn1stServiceInListIfInitializedServiceIsNotInListOfAllDeploymentConfigs() {
    // given
    IDeploymentConfig otherDeploymentConfig = ResourceMocks.createResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG);
    ServerResourceViewModel model = new ServerResourceViewModel(otherDeploymentConfig, connection);
    model.loadResources();
    // when
    IResource service = model.getResource();
    // then
    assertThat(service).isEqualTo(ResourceMocks.PROJECT2_SERVICES[0]);
}
Also used : ServerResourceViewModel(org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 10 with ServerResourceViewModel

use of org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModelWithReplicationControllerTest method shouldSetNewConnectionIfLoadResourcesWithConnection.

@Test
public void shouldSetNewConnectionIfLoadResourcesWithConnection() {
    // given
    ServerResourceViewModel model = new ServerResourceViewModel(null);
    model.loadResources();
    assertThat(model.getConnection()).isNull();
    // when
    model.loadResources(connection);
    // then
    assertThat(model.getConnection()).isEqualTo(connection);
}
Also used : ServerResourceViewModel(org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel) Test(org.junit.Test)

Aggregations

ServerResourceViewModel (org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel)24 Test (org.junit.Test)21 IResource (com.openshift.restclient.model.IResource)9 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)6 Connection (org.jboss.tools.openshift.core.connection.Connection)6 Before (org.junit.Before)3 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)1 IReplicationController (com.openshift.restclient.model.IReplicationController)1 IService (com.openshift.restclient.model.IService)1