### Question:
KafkaConfigProviderUtils { @VisibleForTesting static Optional<Integer> getCdhPatchVersion(TemplatePreparationObject source) { if (null != source.getProductDetailsView() && null != source.getProductDetailsView().getProducts()) { Optional<ClouderaManagerProduct> cdh = source.getProductDetailsView().getProducts() .stream() .filter(p -> "CDH".equals(p.getName())) .findAny(); return cdh.flatMap(p -> getPatchFromVersionString(p.getVersion())); } else { return Optional.empty(); } } private  KafkaConfigProviderUtils(); static CdhVersionForStreaming getCdhVersionForStreaming(TemplatePreparationObject source);  }### Answer:
@Test void getCdhPatchVersionMissingProductDetails() { TemplatePreparationObject source = new TemplatePreparationObject.Builder().build(); assertThat(KafkaConfigProviderUtils.getCdhPatchVersion(source)).isEmpty(); }
@Test void getCdhPatchVersionMissingCdhProduct() { TemplatePreparationObject source = new TemplatePreparationObject.Builder() .withProductDetails(cmRepo(), products("SCHEMAREGISTRY=0.8.0.3.0.0.0-97")) .build(); assertThat(KafkaConfigProviderUtils.getCdhPatchVersion(source)).isEmpty(); }
@Test void getCdhPatchVersionIrregularVersionNumberFormat() { TemplatePreparationObject source = new TemplatePreparationObject.Builder() .withProductDetails(cmRepo(), products("SCHEMAREGISTRY=0.8.0.3.0.0.0-97,CDH=123456")) .build(); assertThat(KafkaConfigProviderUtils.getCdhPatchVersion(source)).isEmpty(); }
@Test void getCdhPatchVersion() { TemplatePreparationObject source = new TemplatePreparationObject.Builder() .withProductDetails(cmRepo(), products("SCHEMAREGISTRY=0.8.0.3.0.0.0-97,CDH=7.0.2-1.cdh7.0.2.p99.1672317")) .build(); assertThat(KafkaConfigProviderUtils.getCdhPatchVersion(source)).isEqualTo(Optional.of(99)); }