BrokerEnvironmentFactory { @VisibleForTesting protected String generateContainerNameFromImageRef(String image) { String containerName; if (image.contains("@")) { String[] parts = image.split("@"); String imagePart = parts[0]; String digest = parts[1]; if (digest.contains(":")) { digest = digest.split(":")[1]; } if (digest.length() > 10) { digest = digest.substring(0, 10); } image = String.format("%s-%s", imagePart, digest); } containerName = image.toLowerCase().replaceAll("[^/]*/", "").replaceAll("[^\\d\\w-]", "-"); if (containerName.length() > 63) { containerName = containerName.substring(0, 63); } return containerName; } BrokerEnvironmentFactory(
      String cheWebsocketEndpoint,
      String brokerPullPolicy,
      AgentAuthEnableEnvVarProvider authEnableEnvVarProvider,
      MachineTokenEnvVarProvider machineTokenEnvVarProvider,
      String artifactsBrokerImage,
      String metadataBrokerImage,
      String pluginRegistryUrl,
      CertificateProvisioner certProvisioner); E createForMetadataBroker(
      Collection<PluginFQN> pluginFQNs, RuntimeIdentity runtimeID, boolean mergePlugins); E createForArtifactsBroker(
      Collection<PluginFQN> pluginFQNs, RuntimeIdentity runtimeID, boolean mergePlugins);  }
@Test(dataProvider = "imageRefs") public void testImageToContainerNameConversion(Object image, Object expected) { String actual = factory.generateContainerNameFromImageRef((String) image); assertEquals( actual, expected, String.format("Should generate name '%s' from image '%s'.", expected, image)); }