RegisterImageBackedByEbsOptions extends RegisterImageOptions { public RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName, @Nullable String virtualName, int volumeSize) { formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.DeleteOnTermination", "false"); addNewEphemeralBlockDevice(deviceName, virtualName, volumeSize); 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 testAddNewBlockDevice() { RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); options.addNewBlockDevice("deviceName", "virtualName", 1); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", "virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); }
@Test public void testAddNewBlockDeviceNullVirtualName() { RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); options.addNewBlockDevice("deviceName", null, 1); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); }
@Test public void testAddNewBlockDeviceStatic() { RegisterImageBackedByEbsOptions options = addNewBlockDevice("deviceName", "virtualName", 1); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", "virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); }
@Test(expectedExceptions = NullPointerException.class) public void testAddNewBlockDeviceNPE() { addNewBlockDevice(null, null, 1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddNewBlockDeviceTooBig() { addNewBlockDevice("deviceName", "virtualName", 1025); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddNewBlockDeviceTooSmall() { addNewBlockDevice("deviceName", "virtualName", 0); }