use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class ManageEnvironmentVariablesWizard method findReplicationController.
/**
* If a replication controller is selected, method returns it.
* If a deployment config is selected, method returns it.
* If a deployment is selected, method finds a deployment config and returns it.
* @param event
* @return
*/
IReplicationController findReplicationController(ExecutionEvent event) {
ISelection selection = UIUtils.getCurrentSelection(event);
IDeploymentConfig dc = UIUtils.getFirstElement(selection, IDeploymentConfig.class);
if (dc != null) {
return dc;
}
IReplicationController rc = UIUtils.getFirstElement(selection, IReplicationController.class);
if (rc != null) {
return rc;
}
IServiceWrapper deployment = UIUtils.getFirstElement(selection, IServiceWrapper.class);
Collection<IResourceWrapper<?, ?>> dcs = deployment.getResourcesOfKind(ResourceKind.DEPLOYMENT_CONFIG);
if (!dcs.isEmpty()) {
dc = (IDeploymentConfig) dcs.iterator().next().getWrapped();
if (dc != null) {
return dc;
}
}
return null;
}
use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class OpenShiftServiceRequirement method waitForResources.
private void waitForResources(final String serviceName, final String projectName, final IService service) {
new WaitUntil(new ServicePodsExist(serviceName, projectName, connection), TimePeriod.VERY_LONG);
new WaitUntil(new ResourceExists(ResourceKind.REPLICATION_CONTROLLER, new BaseMatcher<List<IResource>>() {
@Override
public boolean matches(Object item) {
if (!(item instanceof List)) {
return false;
}
@SuppressWarnings("unchecked") List<IReplicationController> resources = (List<IReplicationController>) item;
if (resources.isEmpty()) {
return false;
}
return ResourceUtils.getReplicationControllerFor(service, resources) != null;
}
@Override
public void describeTo(Description description) {
}
}, projectName, connection), TIMEPERIOD_WAIT_FOR_BUILD);
}
use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class OpenShiftServiceRequirement method getReplicationController.
public IReplicationController getReplicationController() {
if (service == null || connection == null) {
return null;
}
List<IReplicationController> rcs = connection.getResources(ResourceKind.REPLICATION_CONTROLLER, service.getNamespaceName());
IReplicationController rc = ResourceUtils.getReplicationControllerFor(service, rcs);
return rc;
}
use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithReplicationControllerTest 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));
IReplicationController replicationController = ResourceMocks.createResource(IReplicationController.class, ResourceKind.REPLICATION_CONTROLLER);
when(project.getResources(ResourceKind.REPLICATION_CONTROLLER)).thenReturn(Collections.singletonList(replicationController));
// when
model.loadResources(connection);
// then
IResource newSelectedDeploymentConfig = model.getResource();
assertThat(selectedDeploymentConfig).isNotEqualTo(newSelectedDeploymentConfig);
} finally {
ConnectionsRegistrySingleton.getInstance().remove(connection);
}
}
use of com.openshift.restclient.model.IReplicationController 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]);
}
Aggregations