Search in sources :

Example 6 with TopologyStatus

use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.

the class StormStatusServiceImplTest method deactivateTopologyShouldReturnErrorTopologyResponse.

@Test
public void deactivateTopologyShouldReturnErrorTopologyResponse() {
    final TopologyStatus topologyStatus = new TopologyStatus();
    topologyStatus.setName("bro");
    topologyStatus.setId("bro_id");
    final TopologySummary topologySummary = new TopologySummary();
    topologySummary.setTopologies(new TopologyStatus[] { 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.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/deactivate", null, Map.class)).thenReturn(new HashMap() {

        {
            put("status", "error message");
        }
    });
    TopologyResponse expected = new TopologyResponse();
    expected.setErrorMessage("error message");
    assertEquals(expected, stormStatusService.deactivateTopology("bro"));
}
Also used : HashMap(java.util.HashMap) TopologyResponse(org.apache.metron.rest.model.TopologyResponse) TopologySummary(org.apache.metron.rest.model.TopologySummary) TopologyStatus(org.apache.metron.rest.model.TopologyStatus) Test(org.junit.Test)

Example 7 with TopologyStatus

use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.

the class StormStatusServiceImpl method getTopologyStatus.

@Override
public TopologyStatus getTopologyStatus(String name) {
    TopologyStatus topologyResponse = null;
    String id = null;
    for (TopologyStatus topology : getTopologySummary().getTopologies()) {
        if (name.equals(topology.getName())) {
            id = topology.getId();
            break;
        }
    }
    if (id != null) {
        topologyResponse = restTemplate.getForObject(getStormUiProperty() + TOPOLOGY_URL + "/" + id, TopologyStatus.class);
    }
    return topologyResponse;
}
Also used : TopologyStatus(org.apache.metron.rest.model.TopologyStatus)

Example 8 with TopologyStatus

use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.

the class StormStatusServiceImplTest method getTopologyStatusShouldReturnTopologyStatus.

@Test
public void getTopologyStatusShouldReturnTopologyStatus() throws Exception {
    final TopologyStatus topologyStatus = new TopologyStatus();
    topologyStatus.setStatus(TopologyStatusCode.STARTED);
    topologyStatus.setName("bro");
    topologyStatus.setId("bro_id");
    final TopologySummary topologySummary = new TopologySummary();
    topologySummary.setTopologies(new TopologyStatus[] { 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);
    expected.setName("bro");
    expected.setId("bro_id");
    TopologyStatus actual = stormStatusService.getTopologyStatus("bro");
    assertEquals(expected, actual);
    assertEquals(expected.hashCode(), actual.hashCode());
}
Also used : TopologySummary(org.apache.metron.rest.model.TopologySummary) TopologyStatus(org.apache.metron.rest.model.TopologyStatus) Test(org.junit.Test)

Example 9 with TopologyStatus

use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.

the class StormStatusServiceImplTest method getTopologySummaryShouldReturnTopologySummary.

@Test
public void getTopologySummaryShouldReturnTopologySummary() throws Exception {
    final TopologyStatus topologyStatus = new TopologyStatus();
    topologyStatus.setStatus(TopologyStatusCode.STARTED);
    topologyStatus.setName("bro");
    topologyStatus.setId("bro_id");
    final TopologySummary topologySummary = new TopologySummary();
    topologySummary.setTopologies(new TopologyStatus[] { 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);
    TopologyStatus expectedStatus = new TopologyStatus();
    expectedStatus.setStatus(TopologyStatusCode.STARTED);
    expectedStatus.setName("bro");
    expectedStatus.setId("bro_id");
    TopologySummary expected = new TopologySummary();
    expected.setTopologies(new TopologyStatus[] { expectedStatus });
    TopologySummary actual = stormStatusService.getTopologySummary();
    assertEquals(expected, actual);
    assertEquals(expected.hashCode(), actual.hashCode());
}
Also used : TopologySummary(org.apache.metron.rest.model.TopologySummary) TopologyStatus(org.apache.metron.rest.model.TopologyStatus) Test(org.junit.Test)

Example 10 with TopologyStatus

use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.

the class StormStatusServiceImplTest method getAllTopologyStatusShouldReturnAllTopologyStatus.

@Test
public void getAllTopologyStatusShouldReturnAllTopologyStatus() {
    final TopologyStatus topologyStatus = new TopologyStatus();
    topologyStatus.setStatus(TopologyStatusCode.STARTED);
    topologyStatus.setName("bro");
    topologyStatus.setId("bro_id");
    final TopologySummary topologySummary = new TopologySummary();
    topologySummary.setTopologies(new TopologyStatus[] { 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);
    expected.setName("bro");
    expected.setId("bro_id");
    assertEquals(new ArrayList() {

        {
            add(expected);
        }
    }, stormStatusService.getAllTopologyStatus());
}
Also used : ArrayList(java.util.ArrayList) TopologySummary(org.apache.metron.rest.model.TopologySummary) TopologyStatus(org.apache.metron.rest.model.TopologyStatus) Test(org.junit.Test)

Aggregations

TopologyStatus (org.apache.metron.rest.model.TopologyStatus)10 TopologySummary (org.apache.metron.rest.model.TopologySummary)7 Test (org.junit.Test)7 TopologyResponse (org.apache.metron.rest.model.TopologyResponse)6 HashMap (java.util.HashMap)4 Map (java.util.Map)2 ArrayList (java.util.ArrayList)1