RegisterImageBackedByEbsOptions extends RegisterImageOptions { public RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName, @Nullable String virtualName, String snapshotId) { formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.DeleteOnTermination", "false"); addEphemeralBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId); return this; }  RegisterImageBackedByEbsOptions addEphemeralBlockDeviceFromSnapshot(String deviceName,
            @Nullable String virtualName, String snapshotId); RegisterImageBackedByEbsOptions addNewEphemeralBlockDevice(String deviceName,
            @Nullable String virtualName, int volumeSize); RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName,
            @Nullable String virtualName, String snapshotId); RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName,
            @Nullable String virtualName, int volumeSize); @Override RegisterImageBackedByEbsOptions asArchitecture(Architecture architecture); @Override RegisterImageBackedByEbsOptions withDescription(String info); @Override RegisterImageBackedByEbsOptions withKernelId(String kernelId); @Override RegisterImageBackedByEbsOptions withRamdisk(String ramDiskId);  }
@Test public void testAddBlockDeviceFromSnapshot() { RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); options.addBlockDeviceFromSnapshot("deviceName", "virtualName", "snapshotId"); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", "virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); }
@Test public void testAddBlockDeviceFromSnapshotNullVirtualName() { RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); options.addBlockDeviceFromSnapshot("deviceName", null, "snapshotId"); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); }
@Test public void testAddBlockDeviceFromSnapshotStatic() { RegisterImageBackedByEbsOptions options = addBlockDeviceFromSnapshot("deviceName", "virtualName", "snapshotId"); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", "virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); }
@Test(expectedExceptions = NullPointerException.class) public void testAddBlockDeviceFromSnapshotNPE() { addBlockDeviceFromSnapshot(null, null, null); }