@Test public void testGetScalingPolicy() throws Exception { when(serviceMock.getScalingPolicy(SCALING_POLICY_ID, JUNIT_REST_CALL_METADATA)).thenReturn(Observable.just(GET_POLICY_RESULT)); GetPolicyResult entity = SpringMockMvcUtil.doGet(mockMvc, String.format("/api/v3/autoscaling/scalingPolicy/%s", SCALING_POLICY_ID.getId()), GetPolicyResult.class); assertThat(entity).isEqualTo(GET_POLICY_RESULT); verify(serviceMock, times(1)).getScalingPolicy(SCALING_POLICY_ID, JUNIT_REST_CALL_METADATA); }
@ApiOperation("Find scaling policy for a policy Id") @GetMapping(path = "scalingPolicy/{policyId}") public GetPolicyResult getScalingPolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication) { ScalingPolicyID scalingPolicyId = ScalingPolicyID.newBuilder().setId(policyId).build(); return Responses.fromSingleValueObservable(autoScalingService.getScalingPolicy(scalingPolicyId, authentication.getCallMetadata())); }
AutoScalingSpringResource { @ApiOperation("Find scaling policy for a policy Id") @GetMapping(path = "scalingPolicy/{policyId}") public GetPolicyResult getScalingPolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication) { ScalingPolicyID scalingPolicyId = ScalingPolicyID.newBuilder().setId(policyId).build(); return Responses.fromSingleValueObservable(autoScalingService.getScalingPolicy(scalingPolicyId, authentication.getCallMetadata())); } }
AutoScalingSpringResource { @ApiOperation("Find scaling policy for a policy Id") @GetMapping(path = "scalingPolicy/{policyId}") public GetPolicyResult getScalingPolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication) { ScalingPolicyID scalingPolicyId = ScalingPolicyID.newBuilder().setId(policyId).build(); return Responses.fromSingleValueObservable(autoScalingService.getScalingPolicy(scalingPolicyId, authentication.getCallMetadata())); } @Inject  AutoScalingSpringResource(AutoScalingService autoScalingService); }
AutoScalingSpringResource { @ApiOperation("Find scaling policy for a policy Id") @GetMapping(path = "scalingPolicy/{policyId}") public GetPolicyResult getScalingPolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication) { ScalingPolicyID scalingPolicyId = ScalingPolicyID.newBuilder().setId(policyId).build(); return Responses.fromSingleValueObservable(autoScalingService.getScalingPolicy(scalingPolicyId, authentication.getCallMetadata())); } @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("Find scaling policy for a policy Id") @GetMapping(path = "scalingPolicy/{policyId}") public GetPolicyResult getScalingPolicy(@PathVariable("policyId") String policyId, CallMetadataAuthentication authentication) { ScalingPolicyID scalingPolicyId = ScalingPolicyID.newBuilder().setId(policyId).build(); return Responses.fromSingleValueObservable(autoScalingService.getScalingPolicy(scalingPolicyId, authentication.getCallMetadata())); } @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);  }