use of com.openshift.restclient.model.IPod in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerContentProvider method getProjectChildren.
protected Object[] getProjectChildren(IProjectWrapper project) {
switch(project.getState()) {
case LOADED:
removeStub(project);
Collection<IResourceWrapper<?, ?>> services = project.getResourcesOfKind(ResourceKind.SERVICE);
Collection<IReplicationControllerWrapper> dcs = project.getResourcesOfType(IReplicationControllerWrapper.class);
services.addAll(dcs);
Collection<IResourceWrapper<?, ?>> pods = project.getResourcesOfKind(ResourceKind.POD).stream().filter(wrapper -> ResourceUtils.isRuntimePod((IPod) wrapper.getWrapped()) && !((IPod) wrapper.getWrapped()).isAnnotatedWith(OpenShiftAPIAnnotations.DEPLOYMENT_NAME)).collect(Collectors.toList());
services.addAll(pods);
return services.toArray();
case LOAD_STOPPED:
LoadingStub stub = removeStub(project);
if (stub != null) {
return stub.getChildren();
}
default:
project.load(e -> {
handleLoadingException(project, e);
});
return new Object[] { makeStub(project) };
}
}
use of com.openshift.restclient.model.IPod in project jbosstools-openshift by jbosstools.
the class ServicePodsExist method test.
@Override
public boolean test() {
IService service = connection.getResource(ResourceKind.SERVICE, projectName, serviceName);
if (service == null) {
return true;
}
if (!hasDesiredReplicas(service)) {
return true;
}
List<IPod> pods = connection.getResources(ResourceKind.POD, projectName);
return !ResourceUtils.getPodsFor(service, pods).isEmpty();
}
use of com.openshift.restclient.model.IPod in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProviderTest method getStyledTextForAPodWithLongNames.
@Test
public void getStyledTextForAPodWithLongNames() {
provider.setLabelLimit(10);
IPod pod = givenAResource(IPod.class, ResourceKind.POD);
String status = "Chilling";
when(pod.getStatus()).thenReturn(status);
String exp = "s...e P...g";
assertEquals(exp, provider.getStyledText(pod).getString());
// test description
assertEquals("someName Pod Chilling", provider.getDescription(pod));
}
use of com.openshift.restclient.model.IPod in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProviderTest method getStyledTextForAPod.
@Test
public void getStyledTextForAPod() {
IPod pod = givenAResource(IPod.class, ResourceKind.POD);
assertEquals(String.format("%s Pod", pod.getName()), provider.getStyledText(pod).getString());
String status = "Chilling";
when(pod.getStatus()).thenReturn(status);
String exp = String.format("%s Pod %s", pod.getName(), status);
assertEquals(exp, provider.getStyledText(pod).getString());
}
use of com.openshift.restclient.model.IPod in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProviderTest method getStyledTextForAPodWithoutLabels.
@Test
public void getStyledTextForAPodWithoutLabels() {
IPod pod = givenAResource(IPod.class, ResourceKind.POD);
when(pod.getIP()).thenReturn("172.17.2.226");
Map<String, String> labels = new HashMap<>();
when(pod.getLabels()).thenReturn(labels);
assertEquals(String.format("%s Pod", pod.getName()), provider.getStyledText(pod).getString());
}
Aggregations