### Question:
ServiceUpdater extends CloudServiceOperator { public MethodExecution<String> updateServicePlan(CloudControllerClient client, String serviceName, String servicePlan) { return new CustomControllerClientErrorHandler().handleErrorsOrReturnResult(() -> attemptToUpdateServicePlan(client, serviceName, servicePlan)); } @Inject  ServiceUpdater(WebClientFactory webClientFactory); MethodExecution<String> updateServicePlanQuietly(CloudControllerClient client, String serviceName, String servicePlan); MethodExecution<String> updateServicePlan(CloudControllerClient client, String serviceName, String servicePlan); MethodExecution<String> updateServiceTagsQuietly(CloudControllerClient client, String serviceName, List<String> serviceTags); MethodExecution<String> updateServiceTags(CloudControllerClient client, String serviceName, List<String> serviceTags); MethodExecution<String> updateServiceParametersQuietly(CloudControllerClient client, String serviceName,
                                                                  Map<String, Object> parameters); MethodExecution<String> updateServiceParameters(CloudControllerClient client, String serviceName,
                                                           Map<String, Object> parameters);  }### Answer:
@Test void testUpdateServicePlan1() { CloudControllerClient client = getMockedClient(); Mockito.when(client.getServiceInstance(EXISTING_SERVICE_INSTANCE_NAME)) .thenReturn(EXISTING_SERVICE_INSTANCE); serviceUpdater.updateServicePlan(client, EXISTING_SERVICE_INSTANCE_NAME, "v3.0-small"); validatePlanUpdate("8e886beb-85cb-4455-9474-b6dfda36ffeb"); }
@Test void testUpdateServicePlan2() { CloudControllerClient client = getMockedClient(); Mockito.when(client.getServiceInstance(EXISTING_SERVICE_INSTANCE_NAME)) .thenReturn(EXISTING_SERVICE_INSTANCE); try { serviceUpdater.updateServicePlan(client, EXISTING_SERVICE_INSTANCE_NAME, "v3.0-large"); } catch (CloudOperationException e) { assertEquals("404 Not Found: Could not create service instance \"foo\". Service plan \"v3.0-large\" from service offering \"mongodb\" was not found.", e.getMessage()); } }
@Test void testUpdateServicePlan3() { CloudControllerClient client = getMockedClient(); Mockito.when(client.getServiceInstance(EXISTING_SERVICE_INSTANCE_NAME)) .thenThrow(new CloudOperationException(HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND.getReasonPhrase(), "Service \"foo\" was not found!")); try { serviceUpdater.updateServicePlan(client, EXISTING_SERVICE_INSTANCE_NAME, "v3.0-small"); } catch (CloudOperationException e) { assertEquals("404 Not Found: Service \"foo\" was not found!", e.getMessage()); } }