@Test void testExecute() { Metadata v3Metadata = Metadata.builder() .annotation("a", "b") .annotation("c", "d") .build(); CloudServiceInstanceExtended serviceInstanceToCreate = ImmutableCloudServiceInstanceExtended.builder() .name(SERVICE_INSTANCE_NAME) .plan(SERVICE_INSTANCE_PLAN) .label(SERVICE_INSTANCE_LABEL) .v3Metadata(v3Metadata) .build(); Mockito.when(procesContext.getVariable(Variables.SERVICE_TO_PROCESS)) .thenReturn(serviceInstanceToCreate); CloudMetadata metadata = ImmutableCloudMetadata.builder() .guid(UUID.randomUUID()) .createdAt(new Date()) .updatedAt(new Date()) .build(); CloudServiceInstance serviceInstance = ImmutableCloudServiceInstance.builder() .name(SERVICE_INSTANCE_NAME) .plan(SERVICE_INSTANCE_PLAN) .label(SERVICE_INSTANCE_LABEL) .metadata(metadata) .build(); Mockito.when(controllerClient.getServiceInstance(serviceInstance.getName())) .thenReturn(serviceInstance); AsyncExecution asyncExecution = new UpdateServiceMetadataExecution(); asyncExecution.execute(procesContext); Mockito.verify(controllerClient) .updateServiceInstanceMetadata(metadata.getGuid(), v3Metadata); }
@Override public AsyncExecutionState execute(ProcessContext context) { CloudServiceInstanceExtended serviceInstance = context.getVariable(Variables.SERVICE_TO_PROCESS); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0, serviceInstance.getName()); updateMetadata(context.getControllerClient(), serviceInstance); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0_DONE, serviceInstance.getName()); return AsyncExecutionState.FINISHED; }
UpdateServiceMetadataExecution implements AsyncExecution { @Override public AsyncExecutionState execute(ProcessContext context) { CloudServiceInstanceExtended serviceInstance = context.getVariable(Variables.SERVICE_TO_PROCESS); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0, serviceInstance.getName()); updateMetadata(context.getControllerClient(), serviceInstance); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0_DONE, serviceInstance.getName()); return AsyncExecutionState.FINISHED; } }
UpdateServiceMetadataExecution implements AsyncExecution { @Override public AsyncExecutionState execute(ProcessContext context) { CloudServiceInstanceExtended serviceInstance = context.getVariable(Variables.SERVICE_TO_PROCESS); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0, serviceInstance.getName()); updateMetadata(context.getControllerClient(), serviceInstance); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0_DONE, serviceInstance.getName()); return AsyncExecutionState.FINISHED; }  }
UpdateServiceMetadataExecution implements AsyncExecution { @Override public AsyncExecutionState execute(ProcessContext context) { CloudServiceInstanceExtended serviceInstance = context.getVariable(Variables.SERVICE_TO_PROCESS); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0, serviceInstance.getName()); updateMetadata(context.getControllerClient(), serviceInstance); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0_DONE, serviceInstance.getName()); return AsyncExecutionState.FINISHED; }  @Override AsyncExecutionState execute(ProcessContext context); @Override String getPollingErrorMessage(ProcessContext context); }
UpdateServiceMetadataExecution implements AsyncExecution { @Override public AsyncExecutionState execute(ProcessContext context) { CloudServiceInstanceExtended serviceInstance = context.getVariable(Variables.SERVICE_TO_PROCESS); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0, serviceInstance.getName()); updateMetadata(context.getControllerClient(), serviceInstance); context.getStepLogger() .debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0_DONE, serviceInstance.getName()); return AsyncExecutionState.FINISHED; }  @Override AsyncExecutionState execute(ProcessContext context); @Override String getPollingErrorMessage(ProcessContext context);  }