@Test public void testAddLoadBalancer() throws Exception { AddLoadBalancerRequest forwardedRequest = AddLoadBalancerRequest.newBuilder() .setJobId(JOB_ID) .setLoadBalancerId(LoadBalancerId.newBuilder().setId(LOAD_BALANCER_ID).build()) .build(); when(serviceMock.addLoadBalancer(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Completable.complete()); SpringMockMvcUtil.doPost( mockMvc, "/api/v3/loadBalancers", Optional.empty(), Optional.empty(), Optional.of(new String[]{"jobId", JOB_ID, "loadBalancerId", LOAD_BALANCER_ID}) ); verify(serviceMock, times(1)).addLoadBalancer(forwardedRequest, JUNIT_REST_CALL_METADATA); }
@ApiOperation("Add a load balancer") @PostMapping public ResponseEntity<Void> addLoadBalancer( @RequestParam("jobId") String jobId, @RequestParam("loadBalancerId") String loadBalancerId, CallMetadataAuthentication authentication) { return Responses.fromCompletable( loadBalancerService.addLoadBalancer( AddLoadBalancerRequest.newBuilder() .setJobId(jobId) .setLoadBalancerId(LoadBalancerId.newBuilder().setId(loadBalancerId).build()) .build(), authentication.getCallMetadata() ), HttpStatus.NO_CONTENT ); }
LoadBalancerSpringResource { @ApiOperation("Add a load balancer") @PostMapping public ResponseEntity<Void> addLoadBalancer( @RequestParam("jobId") String jobId, @RequestParam("loadBalancerId") String loadBalancerId, CallMetadataAuthentication authentication) { return Responses.fromCompletable( loadBalancerService.addLoadBalancer( AddLoadBalancerRequest.newBuilder() .setJobId(jobId) .setLoadBalancerId(LoadBalancerId.newBuilder().setId(loadBalancerId).build()) .build(), authentication.getCallMetadata() ), HttpStatus.NO_CONTENT ); } }
LoadBalancerSpringResource { @ApiOperation("Add a load balancer") @PostMapping public ResponseEntity<Void> addLoadBalancer( @RequestParam("jobId") String jobId, @RequestParam("loadBalancerId") String loadBalancerId, CallMetadataAuthentication authentication) { return Responses.fromCompletable( loadBalancerService.addLoadBalancer( AddLoadBalancerRequest.newBuilder() .setJobId(jobId) .setLoadBalancerId(LoadBalancerId.newBuilder().setId(loadBalancerId).build()) .build(), authentication.getCallMetadata() ), HttpStatus.NO_CONTENT ); } @Inject  LoadBalancerSpringResource(LoadBalancerService loadBalancerService, SystemLogService systemLog); }
LoadBalancerSpringResource { @ApiOperation("Add a load balancer") @PostMapping public ResponseEntity<Void> addLoadBalancer( @RequestParam("jobId") String jobId, @RequestParam("loadBalancerId") String loadBalancerId, CallMetadataAuthentication authentication) { return Responses.fromCompletable( loadBalancerService.addLoadBalancer( AddLoadBalancerRequest.newBuilder() .setJobId(jobId) .setLoadBalancerId(LoadBalancerId.newBuilder().setId(loadBalancerId).build()) .build(), authentication.getCallMetadata() ), HttpStatus.NO_CONTENT ); } @Inject  LoadBalancerSpringResource(LoadBalancerService loadBalancerService, SystemLogService systemLog); @ApiOperation("Find the load balancer(s) with the specified ID") @GetMapping(path = "/{jobId}") GetJobLoadBalancersResult getJobLoadBalancers(@PathVariable("jobId") String jobId, CallMetadataAuthentication authentication); @ApiOperation("Get all load balancers") @GetMapping GetAllLoadBalancersResult getAllLoadBalancers(@RequestParam MultiValueMap<String, String> queryParameters,
                                                         CallMetadataAuthentication authentication); @ApiOperation("Add a load balancer") @PostMapping ResponseEntity<Void> addLoadBalancer(
            @RequestParam("jobId") String jobId,
            @RequestParam("loadBalancerId") String loadBalancerId,
            CallMetadataAuthentication authentication); @ApiOperation("Remove a load balancer") @DeleteMapping ResponseEntity<Void> removeLoadBalancer(
            @RequestParam("jobId") String jobId,
            @RequestParam("loadBalancerId") String loadBalancerId,
            CallMetadataAuthentication authentication); }
LoadBalancerSpringResource { @ApiOperation("Add a load balancer") @PostMapping public ResponseEntity<Void> addLoadBalancer( @RequestParam("jobId") String jobId, @RequestParam("loadBalancerId") String loadBalancerId, CallMetadataAuthentication authentication) { return Responses.fromCompletable( loadBalancerService.addLoadBalancer( AddLoadBalancerRequest.newBuilder() .setJobId(jobId) .setLoadBalancerId(LoadBalancerId.newBuilder().setId(loadBalancerId).build()) .build(), authentication.getCallMetadata() ), HttpStatus.NO_CONTENT ); } @Inject  LoadBalancerSpringResource(LoadBalancerService loadBalancerService, SystemLogService systemLog); @ApiOperation("Find the load balancer(s) with the specified ID") @GetMapping(path = "/{jobId}") GetJobLoadBalancersResult getJobLoadBalancers(@PathVariable("jobId") String jobId, CallMetadataAuthentication authentication); @ApiOperation("Get all load balancers") @GetMapping GetAllLoadBalancersResult getAllLoadBalancers(@RequestParam MultiValueMap<String, String> queryParameters,
                                                         CallMetadataAuthentication authentication); @ApiOperation("Add a load balancer") @PostMapping ResponseEntity<Void> addLoadBalancer(
            @RequestParam("jobId") String jobId,
            @RequestParam("loadBalancerId") String loadBalancerId,
            CallMetadataAuthentication authentication); @ApiOperation("Remove a load balancer") @DeleteMapping ResponseEntity<Void> removeLoadBalancer(
            @RequestParam("jobId") String jobId,
            @RequestParam("loadBalancerId") String loadBalancerId,
            CallMetadataAuthentication authentication);  }