### Question:
GcpDiskResourceBuilder extends AbstractGcpComputeBuilder { @Override public List<CloudResource> build(GcpContext context, long privateId, AuthenticatedContext auth, Group group, List<CloudResource> buildableResources, CloudStack cloudStack) throws Exception { String projectId = context.getProjectId(); Location location = context.getLocation(); Disk disk = new Disk(); disk.setSizeGb((long) group.getRootVolumeSize()); disk.setName(buildableResources.get(0).getName()); disk.setKind(GcpDiskType.HDD.getUrl(projectId, location.getAvailabilityZone())); InstanceTemplate template = group.getReferenceInstanceTemplate(); gcpDiskEncryptionService.addEncryptionKeyToDisk(template, disk); Map<String, String> customTags = new HashMap<>(); customTags.putAll(cloudStack.getTags()); disk.setLabels(customTags); Insert insDisk = context.getCompute().disks().insert(projectId, location.getAvailabilityZone().value(), disk); insDisk.setSourceImage(GcpStackUtil.getAmbariImage(projectId, cloudStack.getImage().getImageName())); try { Operation operation = insDisk.execute(); if (operation.getHttpErrorStatusCode() != null) { throw new GcpResourceException(operation.getHttpErrorMessage(), resourceType(), buildableResources.get(0).getName()); } return Collections.singletonList(createOperationAwareCloudResource(buildableResources.get(0), operation)); } catch (GoogleJsonResponseException e) { throw new GcpResourceException(checkException(e), resourceType(), buildableResources.get(0).getName()); } }  @Override List<CloudResource> create(GcpContext context, long privateId, AuthenticatedContext auth, Group group, Image image); @Override List<CloudResource> build(GcpContext context, long privateId, AuthenticatedContext auth, Group group,
            List<CloudResource> buildableResources, CloudStack cloudStack); @Override CloudResource delete(GcpContext context, AuthenticatedContext auth, CloudResource resource); @Override ResourceType resourceType(); @Override int order();  }### Answer:
@Test void testBuildWithDiskEncryption() throws Exception { CustomerEncryptionKey encryptionKey = new CustomerEncryptionKey(); encryptionKey.setRawKey("rawKey=="); ArgumentCaptor<Disk> diskCaptor = ArgumentCaptor.forClass(Disk.class); doAnswer(invocation -> { Disk disk = invocation.getArgument(1); disk.setDiskEncryptionKey(encryptionKey); return invocation; }).when(gcpDiskEncryptionService).addEncryptionKeyToDisk(any(InstanceTemplate.class), diskCaptor.capture()); List<CloudResource> build = underTest.build(context, privateId, auth, group, buildableResource, cloudStack); assertNotNull(build); assertEquals(1, build.size()); CloudResource resource = build.iterator().next(); assertEquals(ResourceType.GCP_DISK, resource.getType()); assertEquals(CommonStatus.REQUESTED, resource.getStatus()); assertEquals("disk", resource.getName()); assertNotNull(diskCaptor.getValue()); assertEquals(encryptionKey, diskCaptor.getValue().getDiskEncryptionKey()); }
@Test void testBuildWithVeryLargeRootVolumeSize() throws Exception { int rootVolumeSize = Integer.MAX_VALUE; Group group = createGroup(rootVolumeSize); List<CloudResource> build = underTest.build(context, privateId, auth, group, buildableResource, cloudStack); assertNotNull(build); verify(disks).insert(anyString(), anyString(), argThat(argument -> argument.getSizeGb().equals((long) rootVolumeSize))); verify(insert, times(1)).execute(); }
@Test void testBuildWithVerySmallRootVolumeSize() throws Exception { int rootVolumeSize = Integer.MIN_VALUE; Group group = createGroup(rootVolumeSize); List<CloudResource> build = underTest.build(context, privateId, auth, group, buildableResource, cloudStack); assertNotNull(build); verify(disks).insert(anyString(), anyString(), argThat(argument -> argument.getSizeGb().equals((long) rootVolumeSize))); verify(insert, times(1)).execute(); }