StormMetadataService { public StormTopologies getTopologies() throws IOException, PrivilegedActionException { return executeSecure(() -> { final Map<String, ?> jsonAsMap = JsonClientUtil.getEntity(httpClient.target(tplgySumUrl), Map.class); List<String> topologies = Collections.emptyList(); if (jsonAsMap != null) { final List<Map<String, String>> topologiesSummary = (List<Map<String, String>>) jsonAsMap.get(STORM_REST_API_TOPOLOGIES_KEY); if (topologiesSummary != null) { topologies = new ArrayList<>(topologiesSummary.size()); for (Map<String, String> tpSum : topologiesSummary) { topologies.add(tpSum.get(STORM_REST_API_TOPOLOGY_ID_KEY)); } } } return new StormTopologies(topologies, getSecurity()); } ); } StormMetadataService(Client httpClient, String tplgySumUrl, String mainPageUrl,
            SecurityContext securityContext, ServiceConfiguration stormEnvConfig, Subject subject,
                                Component nimbus, Collection<ComponentProcess> nimbusProcesses,
                                Component stormUi, Collection<ComponentProcess> stormUiProcesses); StormTopologies getTopologies(); String getMainPageUrl(); String getTopologySummaryUrl(); Keytabs getKeytabs(); Principals getPrincipals(); Security getSecurity(); static final String STORM_REST_API_DO_AS_USER_QUERY_PARAM; static final String SERVICE_STORM_VIEW; static final String STORM_VIEW_CONFIGURATION_KEY_STORM_VIEW_URL; }
@Test public void getTopologies() throws Exception { new Expectations() {{ builder.get(String.class); result = getTopologiesSummary(); securityContext.getAuthenticationScheme(); result = AUTHENTICATION_SCHEME_NOT_KERBEROS; }}; Deencapsulation.setField(stormService, "nimbusProcesses", buildNimbusComponentProcesses()); Deencapsulation.setField(stormService, "stormUiProcesses", buildUiComponentProcesses()); final List<String> actualTopologies = stormService.getTopologies().list(); Collections.sort(actualTopologies); final List<String> expectedTopologies = Lists.newArrayList("kafka-topology-2-1474413185", "kafka-topology-2-3-1474413375"); Assert.assertEquals(expectedTopologies, actualTopologies); }