use of com.datatorrent.stram.plan.logical.requests.SetOperatorPropertyRequest in project apex-core by apache.
the class StramWebServicesTest method testSubmitLogicalPlanChange.
@Test
public void testSubmitLogicalPlanChange() throws JSONException, Exception {
List<LogicalPlanRequest> requests = new ArrayList<>();
WebResource r = resource();
CreateOperatorRequest request1 = new CreateOperatorRequest();
request1.setOperatorName("operatorName");
request1.setOperatorFQCN("className");
requests.add(request1);
SetOperatorPropertyRequest request2 = new SetOperatorPropertyRequest();
request2.setOperatorName("operatorName");
request2.setPropertyName("propertyName");
request2.setPropertyValue("propertyValue");
requests.add(request2);
ObjectMapper mapper = new ObjectMapper();
final Map<String, Object> m = new HashMap<>();
m.put("requests", requests);
final JSONObject jsonRequest = new JSONObject(mapper.writeValueAsString(m));
ClientResponse response = r.path(StramWebServices.PATH).path(StramWebServices.PATH_LOGICAL_PLAN).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, jsonRequest);
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
assertEquals(DummyStreamingContainerManager.lastRequests.size(), 2);
LogicalPlanRequest request = DummyStreamingContainerManager.lastRequests.get(0);
assertTrue(request instanceof CreateOperatorRequest);
request1 = (CreateOperatorRequest) request;
assertEquals(request1.getOperatorName(), "operatorName");
assertEquals(request1.getOperatorFQCN(), "className");
request = DummyStreamingContainerManager.lastRequests.get(1);
assertTrue(request instanceof SetOperatorPropertyRequest);
request2 = (SetOperatorPropertyRequest) request;
assertEquals(request2.getOperatorName(), "operatorName");
assertEquals(request2.getPropertyName(), "propertyName");
assertEquals(request2.getPropertyValue(), "propertyValue");
}
Aggregations