@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void createFlow() throws Exception { MvcResult mvcResult = mockMvc.perform(put("/v1/flows") .header(CORRELATION_ID, testCorrelationId()) .contentType(APPLICATION_JSON_VALUE) .content(MAPPER.writeValueAsString(TestMessageMock.flow))) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); System.out.println("RESPONSE: " + result.getResponse().getContentAsString()); FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class); assertEquals(TestMessageMock.flow, response); }
@ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); }
FlowController extends BaseController { @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); } }
FlowController extends BaseController { @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); }  }
FlowController extends BaseController { @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); }  @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
                                                             @RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
                                                            @RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
            @RequestBody PingInput payload,
            @PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
            @PathVariable("flow_id") String flowId,
            @ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
            @RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
            @ApiParam(value = "default: now.")
            @RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
            @ApiParam(value = "Return at most N latest records. "
                    + "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
                    + "`maxCount` is infinite (all records in time interval will be returned). "
                    + "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
                    + "header 'Content-Range'.")
            @RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
            @PathVariable("flow_id") String flowId,
            @ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
                    + "Example of `since` value: `2019-09-30T16:14:12.538Z`",
                    required = false)
            @RequestParam(value = "since", required = false) Optional<String> since); }
FlowController extends BaseController { @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); }  @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
                                                             @RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
                                                            @RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
            @RequestBody PingInput payload,
            @PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
            @PathVariable("flow_id") String flowId,
            @ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
            @RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
            @ApiParam(value = "default: now.")
            @RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
            @ApiParam(value = "Return at most N latest records. "
                    + "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
                    + "`maxCount` is infinite (all records in time interval will be returned). "
                    + "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
                    + "header 'Content-Range'.")
            @RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
            @PathVariable("flow_id") String flowId,
            @ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
                    + "Example of `since` value: `2019-09-30T16:14:12.538Z`",
                    required = false)
            @RequestParam(value = "since", required = false) Optional<String> since);  }