ClipboardAction extends Action { @Override public boolean acceptsArguments(@NonNull ActionArguments arguments) { switch (arguments.getSituation()) { case Action.SITUATION_BACKGROUND_NOTIFICATION_ACTION_BUTTON: case Action.SITUATION_FOREGROUND_NOTIFICATION_ACTION_BUTTON: case Action.SITUATION_PUSH_OPENED: case Action.SITUATION_MANUAL_INVOCATION: case Action.SITUATION_WEB_VIEW_INVOCATION: case Action.SITUATION_AUTOMATION: if (arguments.getValue().getMap() != null) { return arguments.getValue().getMap().opt("text").isString(); } return arguments.getValue().getString() != null; case Action.SITUATION_PUSH_RECEIVED: default: return false; } }  @Override boolean acceptsArguments(@NonNull ActionArguments arguments); @NonNull @Override ActionResult perform(@NonNull final ActionArguments arguments); @Override boolean shouldRunOnMainThread(); @NonNull
    static final String DEFAULT_REGISTRY_NAME; @NonNull
    static final String DEFAULT_REGISTRY_SHORT_NAME; @NonNull
    static final String LABEL_KEY; @NonNull
    static final String TEXT_KEY; }
@Test public void testAcceptsArgumentWithMap() { Map<String, String> clipboardMap = new HashMap<>(); clipboardMap.put("label", "clipboard label"); clipboardMap.put("text", "clipboard text"); for (@Action.Situation int situation : acceptedSituations) { ActionArguments args = ActionTestUtils.createArgs(situation, clipboardMap); assertTrue("Should accept arguments in situation " + situation, action.acceptsArguments(args)); } for (@Action.Situation int situation : rejectedSituations) { ActionArguments args = ActionTestUtils.createArgs(situation, clipboardMap); assertFalse("Should reject arguments in situation " + situation, action.acceptsArguments(args)); } }
@Test public void testAcceptsArgumentWithString() { String clipboardString = "oh hi"; for (@Action.Situation int situation : acceptedSituations) { ActionArguments args = ActionTestUtils.createArgs(situation, clipboardString); assertTrue("Should accept arguments in situation " + situation, action.acceptsArguments(args)); } for (@Action.Situation int situation : rejectedSituations) { ActionArguments args = ActionTestUtils.createArgs(situation, clipboardString); assertFalse("Should reject arguments in situation " + situation, action.acceptsArguments(args)); } }