metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject metron git commit: METRON-906 Rest service storm configuration does not allow for proper URLs (justinleet via ottobackwards) closes apache/metron#602
Date Fri, 16 Jun 2017 14:54:34 GMT
Repository: metron
Updated Branches:
  refs/heads/master 30d0e2a6f -> f523c1795


METRON-906 Rest service storm configuration does not allow for proper URLs (justinleet via
ottobackwards) closes apache/metron#602


Project: http://git-wip-us.apache.org/repos/asf/metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/f523c179
Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/f523c179
Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/f523c179

Branch: refs/heads/master
Commit: f523c179585bea3a61f99c694d2752fc6ceb7a3b
Parents: 30d0e2a
Author: justinleet <justinjleet@gmail.com>
Authored: Fri Jun 16 10:16:27 2017 -0400
Committer: otto <otto@apache.org>
Committed: Fri Jun 16 10:16:27 2017 -0400

----------------------------------------------------------------------
 .../METRON/CURRENT/configuration/metron-env.xml |  2 +-
 .../METRON/CURRENT/service_advisor.py           |  6 +-
 .../roles/ambari_config/vars/single_node_vm.yml |  2 +-
 .../roles/ambari_config/vars/small_cluster.yml  |  2 +-
 .../service/impl/StormStatusServiceImpl.java    | 19 +++--
 .../src/main/resources/application-vagrant.yml  |  2 +-
 .../metron/rest/mock/MockStormRestTemplate.java | 13 +++-
 .../impl/StormStatusServiceImplTest.java        | 73 +++++++++++++-------
 8 files changed, 83 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metron/blob/f523c179/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-env.xml
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-env.xml
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-env.xml
index 3e5a405..00c48a6 100644
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-env.xml
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-env.xml
@@ -224,7 +224,7 @@
     <property require-input = "true">
         <name>storm_rest_addr</name>
         <display-name>Storm Rest Server Address</display-name>
-        <description>URL of Storm UI (storm.ui.hostname:8744)</description>
+        <description>URL of Storm UI (http://storm.ui.hostname:8744). If no protocol
is provided, http is assumed.</description>
         <value></value>
     </property>
     <property require-input = "true">

http://git-wip-us.apache.org/repos/asf/metron/blob/f523c179/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/service_advisor.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/service_advisor.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/service_advisor.py
index 7da06f5..4a95e63 100644
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/service_advisor.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/service_advisor.py
@@ -108,7 +108,11 @@ class METRON${metron.short.version}ServiceAdvisor(service_advisor.ServiceAdvisor
         if "storm-site" in services["configurations"]:
             stormUIServerHost = self.getComponentHostNames(services, "STORM", "STORM_UI_SERVER")[0]
             stormUIServerPort = services["configurations"]["storm-site"]["properties"]["ui.port"]
-            stormUIServerURL = stormUIServerHost + ":" + stormUIServerPort
+            stormUIProtocol = "http://"
+            if "ui.https.port" in services["configurations"]["storm-site"]["properties"]:
+                stormUIServerPort = services["configurations"]["storm-site"]["properties"]["ui.https.port"]
+                stormUIProtocol = "https://"
+            stormUIServerURL = stormUIProtocol + stormUIServerHost + ":" + stormUIServerPort
             putMetronEnvProperty = self.putProperty(configurations, "metron-env", services)
             putMetronEnvProperty("storm_rest_addr",stormUIServerURL)
 

http://git-wip-us.apache.org/repos/asf/metron/blob/f523c179/metron-deployment/roles/ambari_config/vars/single_node_vm.yml
----------------------------------------------------------------------
diff --git a/metron-deployment/roles/ambari_config/vars/single_node_vm.yml b/metron-deployment/roles/ambari_config/vars/single_node_vm.yml
index 7e54db3..6a36fac 100644
--- a/metron-deployment/roles/ambari_config/vars/single_node_vm.yml
+++ b/metron-deployment/roles/ambari_config/vars/single_node_vm.yml
@@ -103,7 +103,7 @@ configurations:
 
 required_configurations:
   - metron-env:
-      storm_rest_addr: "{{ groups.ambari_slave[0] }}:8744"
+      storm_rest_addr: "http://{{ groups.ambari_slave[0] }}:8744"
       es_hosts: "{{ groups.search | join(',') }}"
       zeppelin_server_url: "{{ groups.zeppelin[0] }}:9995"
       metron_jdbc_driver: "org.h2.Driver"

http://git-wip-us.apache.org/repos/asf/metron/blob/f523c179/metron-deployment/roles/ambari_config/vars/small_cluster.yml
----------------------------------------------------------------------
diff --git a/metron-deployment/roles/ambari_config/vars/small_cluster.yml b/metron-deployment/roles/ambari_config/vars/small_cluster.yml
index dbcfb60..af22cb6 100644
--- a/metron-deployment/roles/ambari_config/vars/small_cluster.yml
+++ b/metron-deployment/roles/ambari_config/vars/small_cluster.yml
@@ -96,7 +96,7 @@ configurations:
 
 required_configurations:
   - metron-env:
-      storm_rest_addr: "{{ groups.ambari_slave[1] }}:8744"
+      storm_rest_addr: "http://{{ groups.ambari_slave[1] }}:8744"
       es_hosts: "{{ groups.web[0] }},{{ groups.search | join(',') }}"
       zeppelin_server_url: "{{ groups.zeppelin[0] }}"
       metron_jdbc_driver: "org.h2.Driver"

http://git-wip-us.apache.org/repos/asf/metron/blob/f523c179/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java
----------------------------------------------------------------------
diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java
b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java
index a02ee75..9f89a3c 100644
--- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java
+++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java
@@ -50,7 +50,7 @@ public class StormStatusServiceImpl implements StormStatusService {
 
   @Override
   public TopologySummary getTopologySummary() {
-    return restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY)
+ TOPOLOGY_SUMMARY_URL, TopologySummary.class);
+    return restTemplate.getForObject(getStormUiProperty() + TOPOLOGY_SUMMARY_URL, TopologySummary.class);
   }
 
   @Override
@@ -64,7 +64,7 @@ public class StormStatusServiceImpl implements StormStatusService {
       }
     }
     if (id != null) {
-      topologyResponse = restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY)
+ TOPOLOGY_URL + "/" + id, TopologyStatus.class);
+      topologyResponse = restTemplate.getForObject(getStormUiProperty() + TOPOLOGY_URL +
"/" + id, TopologyStatus.class);
     }
     return topologyResponse;
   }
@@ -73,7 +73,7 @@ public class StormStatusServiceImpl implements StormStatusService {
   public List<TopologyStatus> getAllTopologyStatus() {
     List<TopologyStatus> topologyStatus = new ArrayList<>();
     for (TopologyStatus topology : getTopologySummary().getTopologies()) {
-      topologyStatus.add(restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY)
+ TOPOLOGY_URL + "/" + topology.getId(), TopologyStatus.class));
+      topologyStatus.add(restTemplate.getForObject(getStormUiProperty() + TOPOLOGY_URL +
"/" + topology.getId(), TopologyStatus.class));
     }
     return topologyStatus;
   }
@@ -89,7 +89,7 @@ public class StormStatusServiceImpl implements StormStatusService {
       }
     }
     if (id != null) {
-      Map result = restTemplate.postForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY)
+ TOPOLOGY_URL + "/" + id + "/activate", null, Map.class);
+      Map result = restTemplate.postForObject(getStormUiProperty() + TOPOLOGY_URL + "/" +
id + "/activate", null, Map.class);
       if("success".equals(result.get("status"))) {
         topologyResponse.setSuccessMessage(TopologyStatusCode.ACTIVE.toString());
       } else {
@@ -112,7 +112,7 @@ public class StormStatusServiceImpl implements StormStatusService {
       }
     }
     if (id != null) {
-      Map result = restTemplate.postForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY)
+ TOPOLOGY_URL + "/" + id + "/deactivate", null, Map.class);
+      Map result = restTemplate.postForObject(getStormUiProperty() + TOPOLOGY_URL + "/" +
id + "/deactivate", null, Map.class);
       if("success".equals(result.get("status"))) {
         topologyResponse.setSuccessMessage(TopologyStatusCode.INACTIVE.toString());
       } else {
@@ -123,4 +123,13 @@ public class StormStatusServiceImpl implements StormStatusService {
     }
     return topologyResponse;
   }
+
+  // If we don't have a protocol, choose http
+  protected String getStormUiProperty() {
+    String baseValue = environment.getProperty(STORM_UI_SPRING_PROPERTY);
+    if(!(baseValue.contains("://"))) {
+      return "http://" + baseValue;
+    }
+    return baseValue;
+  }
 }

http://git-wip-us.apache.org/repos/asf/metron/blob/f523c179/metron-interface/metron-rest/src/main/resources/application-vagrant.yml
----------------------------------------------------------------------
diff --git a/metron-interface/metron-rest/src/main/resources/application-vagrant.yml b/metron-interface/metron-rest/src/main/resources/application-vagrant.yml
index c4964c0..1884ca3 100644
--- a/metron-interface/metron-rest/src/main/resources/application-vagrant.yml
+++ b/metron-interface/metron-rest/src/main/resources/application-vagrant.yml
@@ -42,7 +42,7 @@ grok:
 
 storm:
   ui:
-    url:   node1:8744
+    url:   http://node1:8744
   parser:
     script.path: /usr/metron/${metron.version}/bin/start_parser_topology.sh
   enrichment:

http://git-wip-us.apache.org/repos/asf/metron/blob/f523c179/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java
----------------------------------------------------------------------
diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java
b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java
index ca5c1c9..ebdefcd 100644
--- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java
+++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java
@@ -45,7 +45,7 @@ public class MockStormRestTemplate extends RestTemplate {
   @Override
   public Object getForObject(String url, Class responseType, Object... urlVariables) throws
RestClientException {
     Object response = null;
-    if (url.equals("http://" + environment.getProperty(MetronRestConstants.STORM_UI_SPRING_PROPERTY)
+ MetronRestConstants.TOPOLOGY_SUMMARY_URL)) {
+    if (url.equals(getStormUiProperty() + MetronRestConstants.TOPOLOGY_SUMMARY_URL)) {
       TopologySummary topologySummary = new TopologySummary();
       List<TopologyStatus> topologyStatusList = new ArrayList<>();
       for(String name: mockStormCLIClientWrapper.getParserTopologyNames()) {
@@ -61,7 +61,7 @@ public class MockStormRestTemplate extends RestTemplate {
       }
       topologySummary.setTopologies(topologyStatusList.toArray(new TopologyStatus[topologyStatusList.size()]));
       response =  topologySummary;
-    } else if (url.startsWith("http://" + environment.getProperty(MetronRestConstants.STORM_UI_SPRING_PROPERTY)
+ MetronRestConstants.TOPOLOGY_URL + "/")){
+    } else if (url.startsWith(getStormUiProperty() + MetronRestConstants.TOPOLOGY_URL + "/")){
       String name = url.substring(url.lastIndexOf('/') + 1, url.length()).replaceFirst("-id",
"");
       response = getTopologyStatus(name);
     }
@@ -113,4 +113,13 @@ public class MockStormRestTemplate extends RestTemplate {
     }
     return result;
   }
+
+  // If we don't have a protocol, prepend one
+  protected String getStormUiProperty() {
+    String baseValue = environment.getProperty(MetronRestConstants.STORM_UI_SPRING_PROPERTY);
+    if(!(baseValue.contains("://"))) {
+      return "http://" + baseValue;
+    }
+    return baseValue;
+  }
 }

http://git-wip-us.apache.org/repos/asf/metron/blob/f523c179/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java
----------------------------------------------------------------------
diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java
b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java
index db2cb7f..606fed4 100644
--- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java
+++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java
@@ -42,6 +42,10 @@ import static org.mockito.Mockito.when;
 
 @SuppressWarnings("ALL")
 public class StormStatusServiceImplTest {
+
+  private static final String HTTP_STORM_UI = "http://storm_ui";
+  private static final String HTTPS_STORM_UI = "https://storm_ui";
+  private static final String NO_PROTOCOL_STORM_UI = "storm_ui";
   @Rule
   public final ExpectedException exception = ExpectedException.none();
 
@@ -57,6 +61,27 @@ public class StormStatusServiceImplTest {
   }
 
   @Test
+  public void testgetStormUiPropertyHttp() {
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    StormStatusServiceImpl serviceImpl = (StormStatusServiceImpl) stormStatusService;
+    assertEquals(HTTP_STORM_UI, serviceImpl.getStormUiProperty());
+  }
+
+  @Test
+  public void testgetStormUiPropertyHttps() {
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTPS_STORM_UI);
+    StormStatusServiceImpl serviceImpl = (StormStatusServiceImpl) stormStatusService;
+    assertEquals(HTTPS_STORM_UI, serviceImpl.getStormUiProperty());
+  }
+
+  @Test
+  public void testgetStormUiPropertyNoProtocol() {
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(NO_PROTOCOL_STORM_UI);
+    StormStatusServiceImpl serviceImpl = (StormStatusServiceImpl) stormStatusService;
+    assertEquals(HTTP_STORM_UI, serviceImpl.getStormUiProperty());
+  }
+
+  @Test
   public void getTopologySummaryShouldReturnTopologySummary() throws Exception {
     final TopologyStatus topologyStatus = new TopologyStatus();
     topologyStatus.setStatus(TopologyStatusCode.STARTED);
@@ -65,8 +90,8 @@ public class StormStatusServiceImplTest {
     final TopologySummary topologySummary = new TopologySummary();
     topologySummary.setTopologies(new TopologyStatus[]{topologyStatus});
 
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
 
     TopologyStatus expectedStatus = new TopologyStatus();
     expectedStatus.setStatus(TopologyStatusCode.STARTED);
@@ -89,9 +114,9 @@ public class StormStatusServiceImplTest {
     final TopologySummary topologySummary = new TopologySummary();
     topologySummary.setTopologies(new TopologyStatus[]{topologyStatus});
 
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id", TopologyStatus.class)).thenReturn(topologyStatus);
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id", TopologyStatus.class)).thenReturn(topologyStatus);
 
     TopologyStatus expected = new TopologyStatus();
     expected.setStatus(TopologyStatusCode.STARTED);
@@ -112,9 +137,9 @@ public class StormStatusServiceImplTest {
     final TopologySummary topologySummary = new TopologySummary();
     topologySummary.setTopologies(new TopologyStatus[]{topologyStatus});
 
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id", TopologyStatus.class)).thenReturn(topologyStatus);
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id", TopologyStatus.class)).thenReturn(topologyStatus);
 
     TopologyStatus expected = new TopologyStatus();
     expected.setStatus(TopologyStatusCode.STARTED);
@@ -133,9 +158,9 @@ public class StormStatusServiceImplTest {
     final TopologySummary topologySummary = new TopologySummary();
     topologySummary.setTopologies(new TopologyStatus[]{topologyStatus});
 
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
-    when(restTemplate.postForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id/activate",
null, Map.class))
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
+    when(restTemplate.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/activate", null,
Map.class))
             .thenReturn(new HashMap() {{ put("status", "success"); }});
 
     TopologyResponse expected = new TopologyResponse();
@@ -151,9 +176,9 @@ public class StormStatusServiceImplTest {
     final TopologySummary topologySummary = new TopologySummary();
     topologySummary.setTopologies(new TopologyStatus[]{topologyStatus});
 
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
-    when(restTemplate.postForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id/activate",
null, Map.class))
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
+    when(restTemplate.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/activate", null,
Map.class))
             .thenReturn(new HashMap() {{ put("status", "error message"); }});
 
     TopologyResponse expected = new TopologyResponse();
@@ -163,8 +188,8 @@ public class StormStatusServiceImplTest {
 
   @Test
   public void activateTopologyShouldReturnTopologyNotFoundTopologyResponse() {
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(new
TopologySummary());
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(new
TopologySummary());
 
     TopologyResponse expected = new TopologyResponse();
     expected.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString());
@@ -179,9 +204,9 @@ public class StormStatusServiceImplTest {
     final TopologySummary topologySummary = new TopologySummary();
     topologySummary.setTopologies(new TopologyStatus[]{topologyStatus});
 
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
-    when(restTemplate.postForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id/deactivate",
null, Map.class))
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
+    when(restTemplate.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/deactivate",
null, Map.class))
             .thenReturn(new HashMap() {{ put("status", "success"); }});
 
     TopologyResponse expected = new TopologyResponse();
@@ -197,9 +222,9 @@ public class StormStatusServiceImplTest {
     final TopologySummary topologySummary = new TopologySummary();
     topologySummary.setTopologies(new TopologyStatus[]{topologyStatus});
 
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
-    when(restTemplate.postForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id/deactivate",
null, Map.class))
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
+    when(restTemplate.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/deactivate",
null, Map.class))
             .thenReturn(new HashMap() {{ put("status", "error message"); }});
 
     TopologyResponse expected = new TopologyResponse();
@@ -209,8 +234,8 @@ public class StormStatusServiceImplTest {
 
   @Test
   public void deactivateTopologyShouldReturnTopologyNotFoundTopologyResponse() {
-    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui");
-    when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(new
TopologySummary());
+    when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
+    when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(new
TopologySummary());
 
     TopologyResponse expected = new TopologyResponse();
     expected.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString());


Mime
View raw message