Skip to content

Commit

Permalink
chore: add test to show type inference issue
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm authored and manusa committed Oct 21, 2023
1 parent c549d39 commit d36b4bf
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.fabric8.kubernetes.client;

import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Optional;

class TypeInferenceTest {

@Test
void test() {
final ConfigMapDependentResource cdr = new ConfigMapDependentResource();
final DeploymentDependentResource ddr = new DeploymentDependentResource();
Arrays.asList(cdr, ddr).forEach(dr -> dr.reconcile());
}

static abstract class KubernetesDependentResource<R extends HasMetadata, P extends HasMetadata>
implements DependentResourceConfigurator<KubernetesDependentConfig<R>> {
void reconcile() {
// NOOP
}

@Override
public void configureWith(KubernetesDependentConfig<R> config) {

}

@Override
public Optional<KubernetesDependentConfig<R>> configuration() {
return Optional.empty();
}
}

static class KubernetesDependentConfig<R extends HasMetadata> {

}

interface DependentResourceConfigurator<C> {
void configureWith(C config);

Optional<C> configuration();
}

static final class ConfigMapDependentResource extends KubernetesDependentResource<ConfigMap, Service> {

}

static final class DeploymentDependentResource extends KubernetesDependentResource<Deployment, Service> {

}

}

0 comments on commit d36b4bf

Please sign in to comment.