Search in sources :

Example 1 with Start

use of com.google.api.services.compute.Compute.Instances.Start in project cloudbreak by hortonworks.

the class GcpInstanceResourceBuilderTest method doTestDefaultEncryption.

public void doTestDefaultEncryption(CloudInstance cloudInstance) throws IOException {
    when(compute.instances()).thenReturn(instances);
    Get get = Mockito.mock(Get.class);
    when(instances.get(anyString(), anyString(), anyString())).thenReturn(get);
    Start start = Mockito.mock(Start.class);
    when(instances.start(anyString(), anyString(), anyString())).thenReturn(start);
    String expectedSource = "google.disk";
    AttachedDisk disk = new AttachedDisk();
    disk.setSource(expectedSource);
    Instance instance = new Instance();
    instance.setDisks(List.of(disk));
    instance.setStatus("TERMINATED");
    when(get.execute()).thenReturn(instance);
    when(start.setPrettyPrint(true)).thenReturn(start);
    when(start.execute()).thenReturn(operation);
    CloudVmInstanceStatus vmInstanceStatus = builder.start(context, authenticatedContext, cloudInstance);
    assertEquals(InstanceStatus.IN_PROGRESS, vmInstanceStatus.getStatus());
    verify(customGcpDiskEncryptionService, times(0)).addEncryptionKeyToDisk(any(InstanceTemplate.class), any(Disk.class));
    verify(instances, times(0)).startWithEncryptionKey(anyString(), anyString(), anyString(), any(InstancesStartWithEncryptionKeyRequest.class));
}
Also used : Start(com.google.api.services.compute.Compute.Instances.Start) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Instance(com.google.api.services.compute.model.Instance) Get(com.google.api.services.compute.Compute.Instances.Get) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) AttachedDisk(com.google.api.services.compute.model.AttachedDisk) InstancesStartWithEncryptionKeyRequest(com.google.api.services.compute.model.InstancesStartWithEncryptionKeyRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CustomerEncryptionKeyProtectedDisk(com.google.api.services.compute.model.CustomerEncryptionKeyProtectedDisk) AttachedDisk(com.google.api.services.compute.model.AttachedDisk) Disk(com.google.api.services.compute.model.Disk) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)

Aggregations

Get (com.google.api.services.compute.Compute.Instances.Get)1 Start (com.google.api.services.compute.Compute.Instances.Start)1 AttachedDisk (com.google.api.services.compute.model.AttachedDisk)1 CustomerEncryptionKeyProtectedDisk (com.google.api.services.compute.model.CustomerEncryptionKeyProtectedDisk)1 Disk (com.google.api.services.compute.model.Disk)1 Instance (com.google.api.services.compute.model.Instance)1 InstancesStartWithEncryptionKeyRequest (com.google.api.services.compute.model.InstancesStartWithEncryptionKeyRequest)1 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)1 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)1 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1