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));
}
Aggregations