@Test public void returnDefaultWhenFieldNotFound() throws Exception { when(defaultCleanupPolicyConfiguration.getConfiguration()).thenReturn(ImmutableMap.of(LAST_BLOB_UPDATED_KEY, true)); when(configuration.getConfiguration()).thenReturn(ImmutableMap.of()); assertThat( underTest.getApplicableFields(ImmutableList.of(LAST_BLOB_UPDATED_KEY)).get(FORMAT).get(LAST_BLOB_UPDATED_KEY), is(true)); }
@DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate public Map<String, Map<String, Boolean>> getApplicableFields(final List<String> fields) { Map<String, Map<String, Boolean>> applicability = new HashMap<>(); for (Entry<String, CleanupPolicyConfiguration> config : cleanupPolicyConfiguration.entrySet()) { String format = config.getKey(); Map<String, Boolean> fieldApplicability = fields.stream() .collect(toMap(identity(), f -> isFieldApplicable(format, f))); applicability.put(format, fieldApplicability); } return applicability; }
CleanupPolicyComponent extends DirectComponentSupport { @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate public Map<String, Map<String, Boolean>> getApplicableFields(final List<String> fields) { Map<String, Map<String, Boolean>> applicability = new HashMap<>(); for (Entry<String, CleanupPolicyConfiguration> config : cleanupPolicyConfiguration.entrySet()) { String format = config.getKey(); Map<String, Boolean> fieldApplicability = fields.stream() .collect(toMap(identity(), f -> isFieldApplicable(format, f))); applicability.put(format, fieldApplicability); } return applicability; } }
CleanupPolicyComponent extends DirectComponentSupport { @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate public Map<String, Map<String, Boolean>> getApplicableFields(final List<String> fields) { Map<String, Map<String, Boolean>> applicability = new HashMap<>(); for (Entry<String, CleanupPolicyConfiguration> config : cleanupPolicyConfiguration.entrySet()) { String format = config.getKey(); Map<String, Boolean> fieldApplicability = fields.stream() .collect(toMap(identity(), f -> isFieldApplicable(format, f))); applicability.put(format, fieldApplicability); } return applicability; } @Inject  CleanupPolicyComponent(final CleanupPolicyStorage cleanupPolicyStorage,
                                final RepositoryManager repositoryManager,
                                final Map<String, CleanupPolicyConfiguration> cleanupPolicyConfiguration,
                                final RepositoryPermissionChecker repositoryPermissionChecker); }
CleanupPolicyComponent extends DirectComponentSupport { @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate public Map<String, Map<String, Boolean>> getApplicableFields(final List<String> fields) { Map<String, Map<String, Boolean>> applicability = new HashMap<>(); for (Entry<String, CleanupPolicyConfiguration> config : cleanupPolicyConfiguration.entrySet()) { String format = config.getKey(); Map<String, Boolean> fieldApplicability = fields.stream() .collect(toMap(identity(), f -> isFieldApplicable(format, f))); applicability.put(format, fieldApplicability); } return applicability; } @Inject  CleanupPolicyComponent(final CleanupPolicyStorage cleanupPolicyStorage,
                                final RepositoryManager repositoryManager,
                                final Map<String, CleanupPolicyConfiguration> cleanupPolicyConfiguration,
                                final RepositoryPermissionChecker repositoryPermissionChecker); @DirectMethod @Timed @ExceptionMetered List<CleanupPolicyXO> readByFormat(final StoreLoadParameters parameters); @DirectMethod @Timed @ExceptionMetered @RequiresPermissions("nexus:*") List<CleanupPolicyXO> readAll(); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate(groups = {Create.class, Default.class}) CleanupPolicyXO create(@NotNull @Valid final CleanupPolicyXO cleanupPolicyXO); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate(groups = {Update.class, Default.class}) CleanupPolicyXO update(@NotNull @Valid final CleanupPolicyXO cleanupPolicyXO); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate void remove(final @NotEmpty String name); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate Map<String, Map<String, Boolean>> getApplicableFields(final List<String> fields); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @Validate Map<String, Object> usage(final String cleanupPolicyName); }
CleanupPolicyComponent extends DirectComponentSupport { @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate public Map<String, Map<String, Boolean>> getApplicableFields(final List<String> fields) { Map<String, Map<String, Boolean>> applicability = new HashMap<>(); for (Entry<String, CleanupPolicyConfiguration> config : cleanupPolicyConfiguration.entrySet()) { String format = config.getKey(); Map<String, Boolean> fieldApplicability = fields.stream() .collect(toMap(identity(), f -> isFieldApplicable(format, f))); applicability.put(format, fieldApplicability); } return applicability; } @Inject  CleanupPolicyComponent(final CleanupPolicyStorage cleanupPolicyStorage,
                                final RepositoryManager repositoryManager,
                                final Map<String, CleanupPolicyConfiguration> cleanupPolicyConfiguration,
                                final RepositoryPermissionChecker repositoryPermissionChecker); @DirectMethod @Timed @ExceptionMetered List<CleanupPolicyXO> readByFormat(final StoreLoadParameters parameters); @DirectMethod @Timed @ExceptionMetered @RequiresPermissions("nexus:*") List<CleanupPolicyXO> readAll(); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate(groups = {Create.class, Default.class}) CleanupPolicyXO create(@NotNull @Valid final CleanupPolicyXO cleanupPolicyXO); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate(groups = {Update.class, Default.class}) CleanupPolicyXO update(@NotNull @Valid final CleanupPolicyXO cleanupPolicyXO); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate void remove(final @NotEmpty String name); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @RequiresPermissions("nexus:*") @Validate Map<String, Map<String, Boolean>> getApplicableFields(final List<String> fields); @DirectMethod @Timed @ExceptionMetered @RequiresAuthentication @Validate Map<String, Object> usage(final String cleanupPolicyName);  }