KubernetesSize { public static float toCores(String cpuString) { final Matcher matcher; if ((matcher = HUMAN_SIZE_CPU_PATTERN.matcher(cpuString)).matches()) { final float size = Float.parseFloat(matcher.group(1)); final String suffix = matcher.group(2); if (suffix == null) { return size; } if (suffix.toLowerCase().equals("m")) { return size / K; } } throw new IllegalArgumentException("Invalid Kubernetes CPU size format provided: " + cpuString); }  static long toBytes(String sizeString); static String toKubeSize(long bytes, boolean si); static float toCores(String cpuString);  }
@Test(dataProvider = "validCpuLimits") public void testParseKubernetesCpuFormatsToCores(String kubeSize, float expectedCores) throws Exception { assertEquals(KubernetesSize.toCores(kubeSize), expectedCores); }