K8sVersion { public boolean olderThan(int major, int minor) { return !newerOrEqualThan(major, minor); } @Inject  K8sVersion(KubernetesClientFactory clientFactory); boolean newerOrEqualThan(int major, int minor); boolean olderThan(int major, int minor);  }
@Test(dataProvider = "olderThanData") public void testOlderThan(VersionInfo versionInfo, int major, int minor, boolean expected) { when(kubernetesClient.getVersion()).thenReturn(versionInfo); assertEquals(k8sVersion.olderThan(major, minor), expected); }
@Test public void testOlderThanWhenInfrastructureFails() throws InfrastructureException { when(kubernetesClientFactory.create()).thenThrow(new InfrastructureException("eh")); assertFalse(k8sVersion.olderThan(1, 1)); assertFalse(k8sVersion.olderThan(-1, -1)); assertFalse(k8sVersion.olderThan(0, 1)); assertFalse(k8sVersion.olderThan(0, 0)); assertFalse(k8sVersion.olderThan(1337, 1337)); assertFalse(k8sVersion.olderThan(6655321, 6655321)); }
@Test public void testOlderThanWhenParseFailure() throws ParseException { when(kubernetesClient.getVersion()).thenReturn(createDummyVersionInfo("abc", "cde")); assertFalse(k8sVersion.olderThan(1, 1)); assertFalse(k8sVersion.olderThan(-1, -1)); assertFalse(k8sVersion.olderThan(0, 1)); assertFalse(k8sVersion.olderThan(0, 0)); assertFalse(k8sVersion.olderThan(1337, 1337)); assertFalse(k8sVersion.olderThan(6655321, 6655321)); }