### Question:
PropagateErrorsDownloadPolicy 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 ( IGNORE.equals( policySetting ) ) { log.debug( "Error policy set to IGNORE." ); return false; } String repositoryId = request.getProperty( "remoteRepositoryId" ); if ( STOP.equals( policySetting ) ) { return true; } if ( QUEUE.equals( policySetting ) ) { previousExceptions.put( repositoryId, exception ); return true; } throw new PolicyConfigurationException( "Unable to process checksum policy of [" + policySetting + "], please file a bug report." ); } PropagateErrorsDownloadPolicy(); @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 STOP; static final DownloadErrorOption QUEUE; static final DownloadErrorOption IGNORE; }### 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( PropagateErrorsDownloadPolicy.STOP, 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<>(); assertTrue(policy.applyPolicy( PropagateErrorsDownloadPolicy.QUEUE, request, localFile, ex, exMap )); }
@Test public void testPolicyIgnore() throws Exception { DownloadErrorPolicy policy = lookupPolicy(); StorageAsset localFile = getFile(); Properties request = createRequest(); Exception ex = new RuntimeException(); Map<String, Exception> exMap = new HashMap<>(); assertFalse(policy.applyPolicy( PropagateErrorsDownloadPolicy.IGNORE, request, localFile, ex, exMap )); }