### Question:
RegisterImageBackedByEbsOptions extends RegisterImageOptions { public RegisterImageBackedByEbsOptions addNewEphemeralBlockDevice(String deviceName, @Nullable String virtualName, int volumeSize) { checkArgument(volumeSize > 0 && volumeSize < 1025, "volumeSize must be between 1 and 1024 gb"); formParameters.put("BlockDeviceMapping." + deviceIndex + ".DeviceName", checkNotNull( deviceName, "deviceName")); if (virtualName != null) formParameters.put("BlockDeviceMapping." + deviceIndex + ".VirtualName", checkNotNull( virtualName, "virtualName")); formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.VolumeSize", volumeSize + ""); deviceIndex++; 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, boolean deleteOnTermination,
            @Nullable String volumeType, @Nullable Integer iops, boolean encrypted); RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName,
                                                            @Nullable String virtualName,
                                                            int volumeSize,
                                                            boolean deleteOnTermination,
                                                            @Nullable String volumeType,
                                                            @Nullable Integer iops,
                                                            boolean encrypted); 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);  }### Answer:
@Test public void testAddNewEphemeralBlockDevice() { RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); options.addNewEphemeralBlockDevice("deviceName", "virtualName", 1); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", "virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); }
@Test public void testAddNewEphemeralBlockDeviceNullVirtualName() { RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); options.addNewEphemeralBlockDevice("deviceName", null, 1); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); }
@Test public void testAddNewEphemeralBlockDeviceStatic() { RegisterImageBackedByEbsOptions options = addNewEphemeralBlockDevice("deviceName", "virtualName", 1); assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", "virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); }
@Test(expectedExceptions = NullPointerException.class) public void testAddNewEphemeralBlockDeviceNPE() { addNewEphemeralBlockDevice(null, null, 1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddNewEphemeralBlockDeviceTooBig() { addNewEphemeralBlockDevice("deviceName", "virtualName", 1025); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddNewEphemeralBlockDeviceTooSmall() { addNewEphemeralBlockDevice("deviceName", "virtualName", 0); }