EnableFeatureAction extends Action { @Override public boolean acceptsArguments(@NonNull ActionArguments arguments) { switch (arguments.getSituation()) { case SITUATION_PUSH_OPENED: case SITUATION_WEB_VIEW_INVOCATION: case SITUATION_MANUAL_INVOCATION: case SITUATION_FOREGROUND_NOTIFICATION_ACTION_BUTTON: case SITUATION_AUTOMATION: break; case SITUATION_PUSH_RECEIVED: case SITUATION_BACKGROUND_NOTIFICATION_ACTION_BUTTON: default: return false; } String feature = arguments.getValue().getString(); if (feature == null) { return false; } switch (feature) { case FEATURE_BACKGROUND_LOCATION: case FEATURE_LOCATION: case FEATURE_USER_NOTIFICATIONS: return true; default: return false; } } EnableFeatureAction(@NonNull PermissionsRequester permissionsRequester);  EnableFeatureAction(); @Override boolean acceptsArguments(@NonNull ActionArguments arguments); @NonNull @Override ActionResult perform(@NonNull ActionArguments arguments); @NonNull
    static final String DEFAULT_REGISTRY_NAME; @NonNull
    static final String DEFAULT_REGISTRY_SHORT_NAME; @NonNull
    static final String FEATURE_USER_NOTIFICATIONS; @NonNull
    static final String FEATURE_LOCATION; @NonNull
    static final String FEATURE_BACKGROUND_LOCATION; }
@Test public void testAcceptsArgumentWithString() { List<String> validValues = Arrays.asList(EnableFeatureAction.FEATURE_BACKGROUND_LOCATION, EnableFeatureAction.FEATURE_USER_NOTIFICATIONS, EnableFeatureAction.FEATURE_LOCATION); for (String value : validValues) { for (@Action.Situation int situation : acceptedSituations) { ActionArguments args = ActionTestUtils.createArgs(situation, value); assertTrue("Should accept arguments in situation " + situation, action.acceptsArguments(args)); } for (@Action.Situation int situation : rejectedSituations) { ActionArguments args = ActionTestUtils.createArgs(situation, value); assertFalse("Should reject arguments in situation " + situation, action.acceptsArguments(args)); } } ActionArguments args = ActionTestUtils.createArgs(Action.SITUATION_AUTOMATION, "invalid"); assertFalse(action.acceptsArguments(args)); }