Skip to content

Commit

Permalink
fixing the mock test and preserving the previous check
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and manusa committed Jul 9, 2021
1 parent 3f221e1 commit b9c5419
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import io.fabric8.kubernetes.api.builder.Visitor;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.KubernetesList;
import io.fabric8.kubernetes.api.model.KubernetesResource;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.Handlers;
Expand All @@ -52,7 +51,6 @@
import io.fabric8.kubernetes.client.dsl.VisitFromServerGetWatchDeleteRecreateWaitApplicable;
import io.fabric8.kubernetes.client.dsl.Waitable;
import io.fabric8.kubernetes.client.dsl.base.OperationSupport;
import io.fabric8.kubernetes.client.handlers.KubernetesListHandler;
import io.fabric8.kubernetes.client.internal.readiness.Readiness;
import okhttp3.OkHttpClient;

Expand Down Expand Up @@ -304,12 +302,12 @@ private static <T> HasMetadata asHasMetadata(T item) {
throw new IllegalArgumentException("Item needs to be an instance of HasMetadata or String.");
}

static <T> ResourceHandler<? extends KubernetesResource, ?> checkForHandlerOf(T item) {
static <T> void checkForHandlerOf(T item) {
if (item instanceof HasMetadata) {
return handlerOf((HasMetadata)item);
} else if (item instanceof KubernetesList) {
return new KubernetesListHandler();
} else {
if (handlerOf((HasMetadata)item) == null) {
throw new KubernetesClientException("No handler found for object:" + item);
}
} else if (!(item instanceof KubernetesList)) {
throw new IllegalArgumentException("Could not find a registered handler for item: [" + item + "].");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ void testCrud() {
assertNotNull(pod);
assertEquals(2, pod.getMetadata().getLabels().size());

pod2 = client.pods().inNamespace("ns1").withName("pod2").edit(new Visitor<PodBuilder>() {
pod2 = client.pods().inNamespace("ns1").withName("pod2").edit(new Visitor<Object>() {

@Override
public void visit(PodBuilder buidler) {
buidler.editMetadata().addToLabels("another", "one").endMetadata();
public void visit(Object builder) {
if (builder instanceof PodBuilder) {
((PodBuilder)builder).editMetadata().addToLabels("another", "one").endMetadata();
}
}

});
Expand Down

0 comments on commit b9c5419

Please sign in to comment.