### Question:
PropagateErrorsOnUpdateDownloadPolicy extends AbstractPolicy implements DownloadErrorPolicy { @Override public boolean applyPolicy( PolicyOption policySetting, Properties request, StorageAsset localFile, Exception exception, Map<String, Exception> previousExceptions ) throws PolicyConfigurationException { if ( !options.contains( policySetting ) ) { throw new PolicyConfigurationException( "Unknown error policy setting [" + policySetting + "], valid settings are [" + StringUtils.join( options.iterator(), "," ) + "]" ); } if ( ALWAYS.equals( policySetting ) ) { return true; } if ( NOT_PRESENT.equals( policySetting ) ) { return !localFile.exists(); } throw new PolicyConfigurationException( "Unable to process checksum policy of [" + policySetting + "], please file a bug report." ); } PropagateErrorsOnUpdateDownloadPolicy(); @Override boolean applyPolicy( PolicyOption policySetting, Properties request, StorageAsset localFile, Exception exception,
                                Map<String, Exception> previousExceptions ); @Override PolicyOption getDefaultOption(); @Override String getId(); @Override List<PolicyOption> getOptions(); static final DownloadErrorOption ALWAYS; static final DownloadErrorOption NOT_PRESENT; }### Answer:
@Test public void testPolicyStop() throws Exception { DownloadErrorPolicy policy = lookupPolicy(); StorageAsset localFile = getFile(); Properties request = createRequest(); Exception ex = new RuntimeException(); Map<String, Exception> exMap = new HashMap<>(); assertTrue(policy.applyPolicy( PropagateErrorsOnUpdateDownloadPolicy.ALWAYS, request, localFile, ex, exMap )); }
@Test public void testPolicyQueue() throws Exception { DownloadErrorPolicy policy = lookupPolicy(); StorageAsset localFile = getFile(); Properties request = createRequest(); Exception ex = new RuntimeException(); Map<String, Exception> exMap = new HashMap<>(); if (localFile.exists()) { localFile.getStorage().removeAsset(localFile); } assertTrue(policy.applyPolicy( PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT, request, localFile, ex, exMap )); localFile.create(); assertFalse(policy.applyPolicy( PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT, request, localFile, ex, exMap )); }