@Test public void testGetEffectiveChecksumPolicy_DifferentPolicies() { String[][] testCases = { { RepositoryPolicy.CHECKSUM_POLICY_WARN, RepositoryPolicy.CHECKSUM_POLICY_FAIL }, { RepositoryPolicy.CHECKSUM_POLICY_IGNORE, RepositoryPolicy.CHECKSUM_POLICY_FAIL }, { RepositoryPolicy.CHECKSUM_POLICY_IGNORE, RepositoryPolicy.CHECKSUM_POLICY_WARN } }; for ( String[] testCase : testCases ) { assertEquals( testCase[0] + " vs " + testCase[1], testCase[0], provider.getEffectiveChecksumPolicy( session, testCase[0], testCase[1] ) ); assertEquals( testCase[0] + " vs " + testCase[1], testCase[0], provider.getEffectiveChecksumPolicy( session, testCase[1], testCase[0] ) ); } }
public String getEffectiveChecksumPolicy( RepositorySystemSession session, String policy1, String policy2 ) { if ( policy1 != null && policy1.equals( policy2 ) ) { return policy1; } int ordinal1 = ordinalOfPolicy( policy1 ); int ordinal2 = ordinalOfPolicy( policy2 ); if ( ordinal2 < ordinal1 ) { return ( ordinal2 != ORDINAL_WARN ) ? policy2 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } else { return ( ordinal1 != ORDINAL_WARN ) ? policy1 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } }
DefaultChecksumPolicyProvider implements ChecksumPolicyProvider, Service { public String getEffectiveChecksumPolicy( RepositorySystemSession session, String policy1, String policy2 ) { if ( policy1 != null && policy1.equals( policy2 ) ) { return policy1; } int ordinal1 = ordinalOfPolicy( policy1 ); int ordinal2 = ordinalOfPolicy( policy2 ); if ( ordinal2 < ordinal1 ) { return ( ordinal2 != ORDINAL_WARN ) ? policy2 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } else { return ( ordinal1 != ORDINAL_WARN ) ? policy1 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } } }
DefaultChecksumPolicyProvider implements ChecksumPolicyProvider, Service { public String getEffectiveChecksumPolicy( RepositorySystemSession session, String policy1, String policy2 ) { if ( policy1 != null && policy1.equals( policy2 ) ) { return policy1; } int ordinal1 = ordinalOfPolicy( policy1 ); int ordinal2 = ordinalOfPolicy( policy2 ); if ( ordinal2 < ordinal1 ) { return ( ordinal2 != ORDINAL_WARN ) ? policy2 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } else { return ( ordinal1 != ORDINAL_WARN ) ? policy1 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } } DefaultChecksumPolicyProvider(); @Inject  DefaultChecksumPolicyProvider( LoggerFactory loggerFactory ); }
DefaultChecksumPolicyProvider implements ChecksumPolicyProvider, Service { public String getEffectiveChecksumPolicy( RepositorySystemSession session, String policy1, String policy2 ) { if ( policy1 != null && policy1.equals( policy2 ) ) { return policy1; } int ordinal1 = ordinalOfPolicy( policy1 ); int ordinal2 = ordinalOfPolicy( policy2 ); if ( ordinal2 < ordinal1 ) { return ( ordinal2 != ORDINAL_WARN ) ? policy2 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } else { return ( ordinal1 != ORDINAL_WARN ) ? policy1 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } } DefaultChecksumPolicyProvider(); @Inject  DefaultChecksumPolicyProvider( LoggerFactory loggerFactory ); void initService( ServiceLocator locator ); DefaultChecksumPolicyProvider setLoggerFactory( LoggerFactory loggerFactory ); ChecksumPolicy newChecksumPolicy( RepositorySystemSession session, RemoteRepository repository,
                                             TransferResource resource, String policy ); String getEffectiveChecksumPolicy( RepositorySystemSession session, String policy1, String policy2 ); }
DefaultChecksumPolicyProvider implements ChecksumPolicyProvider, Service { public String getEffectiveChecksumPolicy( RepositorySystemSession session, String policy1, String policy2 ) { if ( policy1 != null && policy1.equals( policy2 ) ) { return policy1; } int ordinal1 = ordinalOfPolicy( policy1 ); int ordinal2 = ordinalOfPolicy( policy2 ); if ( ordinal2 < ordinal1 ) { return ( ordinal2 != ORDINAL_WARN ) ? policy2 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } else { return ( ordinal1 != ORDINAL_WARN ) ? policy1 : RepositoryPolicy.CHECKSUM_POLICY_WARN; } } DefaultChecksumPolicyProvider(); @Inject  DefaultChecksumPolicyProvider( LoggerFactory loggerFactory ); void initService( ServiceLocator locator ); DefaultChecksumPolicyProvider setLoggerFactory( LoggerFactory loggerFactory ); ChecksumPolicy newChecksumPolicy( RepositorySystemSession session, RemoteRepository repository,
                                             TransferResource resource, String policy ); String getEffectiveChecksumPolicy( RepositorySystemSession session, String policy1, String policy2 );  }