@Test public void testSetScalingPolicy() throws Exception { PutPolicyRequest request = PutPolicyRequest.newBuilder().build(); when(serviceMock.setAutoScalingPolicy(request, JUNIT_REST_CALL_METADATA)).thenReturn(Observable.just(SCALING_POLICY_ID)); ScalingPolicyID entity = SpringMockMvcUtil.doPost(mockMvc, "/api/v3/autoscaling/scalingPolicy", request, ScalingPolicyID.class); assertThat(entity).isEqualTo(SCALING_POLICY_ID); verify(serviceMock, times(1)).setAutoScalingPolicy(request, JUNIT_REST_CALL_METADATA); }
@ApiOperation("Create or Update scaling policy") @PostMapping(path = "/scalingPolicy") public ScalingPolicyID setScalingPolicy(@RequestBody PutPolicyRequest putPolicyRequest, CallMetadataAuthentication authentication) { Observable<ScalingPolicyID> putPolicyResult = autoScalingService.setAutoScalingPolicy(putPolicyRequest, authentication.getCallMetadata()); ScalingPolicyID policyId = Responses.fromSingleValueObservable(putPolicyResult); log.info("New policy created {}", policyId); return policyId; }
AutoScalingSpringResource { @ApiOperation("Create or Update scaling policy") @PostMapping(path = "/scalingPolicy") public ScalingPolicyID setScalingPolicy(@RequestBody PutPolicyRequest putPolicyRequest, CallMetadataAuthentication authentication) { Observable<ScalingPolicyID> putPolicyResult = autoScalingService.setAutoScalingPolicy(putPolicyRequest, authentication.getCallMetadata()); ScalingPolicyID policyId = Responses.fromSingleValueObservable(putPolicyResult); log.info("New policy created {}", policyId); return policyId; } }
AutoScalingSpringResource { @ApiOperation("Create or Update scaling policy") @PostMapping(path = "/scalingPolicy") public ScalingPolicyID setScalingPolicy(@RequestBody PutPolicyRequest putPolicyRequest, CallMetadataAuthentication authentication) { Observable<ScalingPolicyID> putPolicyResult = autoScalingService.setAutoScalingPolicy(putPolicyRequest, authentication.getCallMetadata()); ScalingPolicyID policyId = Responses.fromSingleValueObservable(putPolicyResult); log.info("New policy created {}", policyId); return policyId; } @Inject  AutoScalingSpringResource(AutoScalingService autoScalingService); }
AutoScalingSpringResource { @ApiOperation("Create or Update scaling policy") @PostMapping(path = "/scalingPolicy") public ScalingPolicyID setScalingPolicy(@RequestBody PutPolicyRequest putPolicyRequest, CallMetadataAuthentication authentication) { Observable<ScalingPolicyID> putPolicyResult = autoScalingService.setAutoScalingPolicy(putPolicyRequest, authentication.getCallMetadata()); ScalingPolicyID policyId = Responses.fromSingleValueObservable(putPolicyResult); log.info("New policy created {}", policyId); return policyId; } @Inject  AutoScalingSpringResource(AutoScalingService autoScalingService); @ApiOperation("Find scaling policies for a job") @GetMapping(path = "/scalingPolicies") GetPolicyResult getAllScalingPolicies(CallMetadataAuthentication authentication); @ApiOperation("Find scaling policies for a job") @GetMapping(path = "/scalingPolicies/{jobId}") GetPolicyResult getScalingPolicyForJob(@PathVariable("jobId") String jobId, CallMetadataAuthentication authentication); @ApiOperation("Create or Update scaling policy") @PostMapping(path = "/scalingPolicy") ScalingPolicyID setScalingPolicy(@RequestBody PutPolicyRequest putPolicyRequest, CallMetadataAuthentication authentication); @ApiOperation("Find scaling policy for a policy Id") @GetMapping(path = "scalingPolicy/{policyId}") GetPolicyResult getScalingPolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication); @ApiOperation("Delete scaling policy") @DeleteMapping(path = "scalingPolicy/{policyId}") ResponseEntity<Void> removePolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication); @ApiOperation("Update scaling policy") @PutMapping("scalingPolicy") ResponseEntity<Void> updateScalingPolicy(@RequestBody UpdatePolicyRequest updatePolicyRequest, CallMetadataAuthentication authentication); }
AutoScalingSpringResource { @ApiOperation("Create or Update scaling policy") @PostMapping(path = "/scalingPolicy") public ScalingPolicyID setScalingPolicy(@RequestBody PutPolicyRequest putPolicyRequest, CallMetadataAuthentication authentication) { Observable<ScalingPolicyID> putPolicyResult = autoScalingService.setAutoScalingPolicy(putPolicyRequest, authentication.getCallMetadata()); ScalingPolicyID policyId = Responses.fromSingleValueObservable(putPolicyResult); log.info("New policy created {}", policyId); return policyId; } @Inject  AutoScalingSpringResource(AutoScalingService autoScalingService); @ApiOperation("Find scaling policies for a job") @GetMapping(path = "/scalingPolicies") GetPolicyResult getAllScalingPolicies(CallMetadataAuthentication authentication); @ApiOperation("Find scaling policies for a job") @GetMapping(path = "/scalingPolicies/{jobId}") GetPolicyResult getScalingPolicyForJob(@PathVariable("jobId") String jobId, CallMetadataAuthentication authentication); @ApiOperation("Create or Update scaling policy") @PostMapping(path = "/scalingPolicy") ScalingPolicyID setScalingPolicy(@RequestBody PutPolicyRequest putPolicyRequest, CallMetadataAuthentication authentication); @ApiOperation("Find scaling policy for a policy Id") @GetMapping(path = "scalingPolicy/{policyId}") GetPolicyResult getScalingPolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication); @ApiOperation("Delete scaling policy") @DeleteMapping(path = "scalingPolicy/{policyId}") ResponseEntity<Void> removePolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication); @ApiOperation("Update scaling policy") @PutMapping("scalingPolicy") ResponseEntity<Void> updateScalingPolicy(@RequestBody UpdatePolicyRequest updatePolicyRequest, CallMetadataAuthentication authentication);  }