SanStorage extends HarddriveStorage { @Override public double getTransferTime(final int fileSize) { final double storageDeviceReadTime = super.getTransferTime(fileSize); final double networkTransferTime = getTransferTime(fileSize, bandwidth); return storageDeviceReadTime + networkTransferTime + getNetworkLatency(); } SanStorage(final long capacity, final double bandwidth, final double networkLatency);  SanStorage(final String name, final long capacity, final double bandwidth, final double networkLatency); @Override double addReservedFile(final File file); @Override double addFile(final File file); @Override double getTransferTime(final int fileSize); @Override double deleteFile(final File file); double getBandwidth(); final void setBandwidth(final double bandwidth); double getNetworkLatency(); final void setNetworkLatency(final double networkLatency); @Override String toString();  }
@Test public void testGetTransferTimeWhenDiskRateAndBwAreEqual() { final double bwMbps = 10; final double diskRateMbps = bwMbps; final SanStorage instance = new SanStorage(CAPACITY, bwMbps, NETWORK_LATENCY); instance.setMaxTransferRate(diskRateMbps); final int fileSizeMB = 100; final double expectedTime = 162; assertEquals(expectedTime, instance.getTransferTime(fileSizeMB), 0.01); }
@Test public void testGetTransferTimeWhenDiskReadTimeIsNegligible() { final double bwMbps = 10; final double diskRateMbps = 1000000; final SanStorage instance = new SanStorage(CAPACITY, bwMbps, NETWORK_LATENCY); instance.setMaxTransferRate(diskRateMbps); final int fileSizeMB = 100; final double expectedTime = 82.0008; assertEquals(expectedTime, instance.getTransferTime(fileSizeMB), 0.01); }
@Test public void testGetTransferTimeWhenNetworkTransferTimeIsNegligible() { final double bwMbps = 1000000; final double diskRateMbps = 10; final double latency = 0.0001; final SanStorage instance = new SanStorage(CAPACITY, bwMbps, latency); instance.setMaxTransferRate(diskRateMbps); final int fileSizeMB = 100; final double expectedTime = 80.0009; assertEquals(expectedTime, instance.getTransferTime(fileSizeMB), 0.01); }
@Test public void testGetTransferTimeWhenBwIsLowerThanDiskRate() { final double bwMbps = 10; final double diskRateMbps = bwMbps*10; final SanStorage instance = new SanStorage(CAPACITY, bwMbps, NETWORK_LATENCY); instance.setMaxTransferRate(diskRateMbps); final int fileSizeMB = 100; final double expectedTime = 90; assertEquals(expectedTime, instance.getTransferTime(fileSizeMB), 0.01); }
@Test public void testGetTransferTimeWhenBwIsLowerThanDiskRateAndLatencyIsAlmostZero() { final double bwMbps = 10; final double diskRateMbps = bwMbps*10; final double latency = 0.0001; final SanStorage instance = new SanStorage(CAPACITY, bwMbps, latency); instance.setMaxTransferRate(diskRateMbps); final int fileSizeMB = 100; final double expectedTime = 88.0; assertEquals(expectedTime, instance.getTransferTime(fileSizeMB), 0.01); }
@Test public void testGetTransferTimeWhenDiskRateIsLowerThanBw() { final double diskRateMbps = 10; final double bwMbps = diskRateMbps*100; final SanStorage instance = new SanStorage(CAPACITY, bwMbps, NETWORK_LATENCY); instance.setMaxTransferRate(diskRateMbps); final int fileSizeMB = 100; final double expectedTime = 82.8; assertEquals(expectedTime, instance.getTransferTime(fileSizeMB), 0.01); }
@Test public void testGetTransferTimeWhenBwIsEqualToDiskRate() { final double bwAndDiskRateMbps = 10; final SanStorage instance = new SanStorage(CAPACITY, bwAndDiskRateMbps, NETWORK_LATENCY); instance.setMaxTransferRate(bwAndDiskRateMbps); final int fileSizeMB = 100; final double expectedTime = 162; assertEquals(expectedTime, instance.getTransferTime(fileSizeMB), 0.1); }