### Question:
ServiceEndpointCollector { public String getManagerServerUrl(Cluster cluster, String managerIp) { if (managerIp != null) { String orchestrator = cluster.getStack().getOrchestrator().getType(); if (YARN.equals(orchestrator)) { return String.format("http: } else { Gateway gateway = cluster.getGateway(); if (gateway != null) { ExposedService exposedService = exposedServiceCollector.getClouderaManagerUIService(); Optional<GatewayTopology> gatewayTopology = getGatewayTopologyForService(gateway, exposedService); Optional<String> managerUrl = gatewayTopology .map(t -> getExposedServiceUrl(managerIp, gateway, t.getTopologyName(), exposedService, false)); return managerUrl.orElse(String.format("https: } return String.format("https: } } return null; }  Collection<ExposedServiceV4Response> getKnoxServices(Long workspaceId, String blueprintName); String getManagerServerUrl(Cluster cluster, String managerIp); Map<String, Collection<ClusterExposedServiceV4Response>> prepareClusterExposedServices(Cluster cluster, String managerIp); Map<String, Collection<ClusterExposedServiceView>> prepareClusterExposedServicesViews(Cluster cluster, String managerIp); List<GatewayTopologyV4Response> filterByStackType(StackType stackType, List<GatewayTopologyV4Response> topologies);  }### Answer:
@Test public void testGetCmServerUrlWithYarnOrchestrator() { Cluster cluster = clusterkWithOrchestrator("YARN"); String ambariIp = CLOUDERA_MANAGER_IP; String result = underTest.getManagerServerUrl(cluster, ambariIp); assertEquals("http: }
@Test public void testGetCmServerUrlWithNullGateway() { Cluster cluster = clusterkWithOrchestrator("ANY"); cluster.setGateway(null); String result = underTest.getManagerServerUrl(cluster, CLOUDERA_MANAGER_IP); assertEquals("https: }
@Test public void testGetCmServerUrlWithNoAmbariInTopologies() { Cluster cluster = createClusterWithComponents(new ExposedService[]{exposedService("ATLAS"), exposedService("ATLAS")}, new ExposedService[]{exposedService("HIVE_SERVER")}, GatewayType.INDIVIDUAL); String result = underTest.getManagerServerUrl(cluster, CLOUDERA_MANAGER_IP); assertEquals("https: }
@Test public void testGetCmServerUrlWithAmbariPresentInTopologiesWithCentralGateway() { Cluster cluster = createClusterWithComponents(new ExposedService[]{exposedService("CLOUDERA_MANAGER_UI"), exposedService("ATLAS")}, new ExposedService[]{exposedService("HIVE_SERVER")}, GatewayType.CENTRAL); String result = underTest.getManagerServerUrl(cluster, CLOUDERA_MANAGER_IP); assertEquals("/gateway-path/topology1/cmf/home/", result); }
@Test public void testGetCmServerUrlWithAmbariPresentInTopologiesWithIndividualGateway() { Cluster cluster = createClusterWithComponents(new ExposedService[]{exposedService("CLOUDERA_MANAGER_UI"), exposedService("ATLAS")}, new ExposedService[]{exposedService("HIVE_SERVER")}, GatewayType.INDIVIDUAL); cluster.getGateway().setGatewayPort(443); String result = underTest.getManagerServerUrl(cluster, CLOUDERA_MANAGER_IP); assertEquals("https: }
@Test public void testGetCmServerUrlInTopologiesWithIndividualGatewayOnPort8443() { ExposedService clouderaManagerUIService = getClouderaManagerUIService(); Cluster cluster = createClusterWithComponents(new ExposedService[]{clouderaManagerUIService, exposedService("ATLAS")}, new ExposedService[]{exposedService("HIVE_SERVER")}, GatewayType.INDIVIDUAL); cluster.getGateway().setGatewayPort(8443); String result = underTest.getManagerServerUrl(cluster, CLOUDERA_MANAGER_IP); assertEquals("https: }