EBSRaiderImpl implements EBSRaider { public List<Volume> getVolumesForGivenInstanceId(String instanceId) { return ec2Delegator.getEc2().describeVolumes(new DescribeVolumesRequest() .withFilters(new Filter() .withName("attachment.instance-id") .withValues(instanceId))) .getVolumes(); } EBSRaiderImpl(); String detachEbsVolume(String volumeId); String attachEbsVolume(String instanceId, String deviceName, String volumeId); Map getVolumesState(String... volumeIds); List<Volume> getVolumesForGivenInstanceId(String instanceId);  }
@Test public void testgetVolumesForGivenInstanceId() throws Exception{ List<Volume> volumes = ebsRaiderImplUnderTest.getVolumesForGivenInstanceId("1234"); Assert.assertTrue(volumes.isEmpty()); volumes = new ArrayList<Volume>(); Volume volume = new Volume(); volume.setVolumeId("123"); volume.setState("attached"); volumes.add(volume); PowerMockito.when(describeVolumesResult.getVolumes()).thenReturn(volumes); Assert.assertFalse(volumes.isEmpty()); Assert.assertEquals(volumes.get(0).getVolumeId(), "123"); Assert.assertEquals(volumes.get(0).getState(), "attached"); }