### Question:
DefaultClouderaManagerRepoService { public ClouderaManagerRepo getDefault(String osType, String clusterType, String clusterVersion, String platform) throws CloudbreakImageCatalogException { if (StackType.CDH.name().equals(clusterType)) { StackMatrixV4Response stackMatrixV4Response = stackMatrixService.getStackMatrix(platform); Map<String, ClouderaManagerStackDescriptorV4Response> stackDescriptorMap = stackMatrixV4Response.getCdh(); if (stackDescriptorMap != null) { Optional<Entry<String, ClouderaManagerStackDescriptorV4Response>> descriptorEntry = stackDescriptorMap.entrySet().stream() .filter(stackDescriptorEntry -> clusterVersion == null || clusterVersion.equals(stackDescriptorEntry.getKey())) .max(Comparator.comparing(Entry::getKey)); if (descriptorEntry.isPresent()) { Entry<String, ClouderaManagerStackDescriptorV4Response> stackDescriptorEntry = descriptorEntry.get(); ClouderaManagerInfoV4Response clouderaManagerInfoJson = stackDescriptorEntry.getValue().getClouderaManager(); if (clouderaManagerInfoJson.getRepository().get(osType) != null) { ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo(); clouderaManagerRepo.setPredefined(false); clouderaManagerRepo.setVersion(clouderaManagerInfoJson.getVersion()); clouderaManagerRepo.setBaseUrl(clouderaManagerInfoJson.getRepository().get(osType).getBaseUrl()); clouderaManagerRepo.setGpgKeyUrl(clouderaManagerInfoJson.getRepository().get(osType).getGpgKeyUrl()); return clouderaManagerRepo; } } } } LOGGER.info("Missing Cloudera Manager Repo information for os: {} clusterType: {} clusterVersion: {}", osType, clusterType, clusterVersion); return null; }  ClouderaManagerRepo getDefault(String osType, String clusterType, String clusterVersion, String platform);  }### Answer:
@Test public void testDefaultRepoWithCDHWhichDoesNotExists() throws Exception { ClouderaManagerRepo repo = defaultClouderaManagerRepoService.getDefault("redhat7", CDH, "2.6", null); assertNull(repo); }
@Test public void testDefaultRepoWithOSWhichDoesNotExists() throws Exception { ClouderaManagerRepo repo = defaultClouderaManagerRepoService.getDefault("ubuntu", CDH, "6.1.0", null); assertNull(repo); }
@Test public void testDefaultRepoWithStackTypeWhichDoesNotExists() throws Exception { ClouderaManagerRepo repo = defaultClouderaManagerRepoService.getDefault("redhat7", "NA", "6.1.0", null); assertNull(repo); }
@Test public void testDefaultRepoWithCDHWhichExists() throws Exception { ClouderaManagerRepo repo = defaultClouderaManagerRepoService.getDefault("redhat7", CDH, "6.1.0", null); assertEquals("6.1.0", repo.getVersion()); assertEquals("http: assertEquals("http: }