MessageCenterAction extends Action { @NonNull @Override public ActionResult perform(@NonNull ActionArguments arguments) { MessageCenter messageCenter; try { messageCenter = messageCenterCallable.call(); } catch (Exception e) { return ActionResult.newErrorResult(e); } String messageId = arguments.getValue().getString(); if (MESSAGE_ID_PLACEHOLDER.equalsIgnoreCase(messageId)) { PushMessage pushMessage = arguments.getMetadata().getParcelable(ActionArguments.PUSH_MESSAGE_METADATA); if (pushMessage != null && pushMessage.getRichPushMessageId() != null) { messageId = pushMessage.getRichPushMessageId(); } else if (arguments.getMetadata().containsKey(ActionArguments.RICH_PUSH_ID_METADATA)) { messageId = arguments.getMetadata().getString(ActionArguments.RICH_PUSH_ID_METADATA); } else { messageId = null; } } if (UAStringUtil.isEmpty(messageId)) { messageCenter.showMessageCenter(); } else { messageCenter.showMessageCenter(messageId); } return ActionResult.newEmptyResult(); } MessageCenterAction(); @VisibleForTesting  MessageCenterAction(@NonNull Callable<MessageCenter>  messageCenterCallable); @Override boolean acceptsArguments(@NonNull ActionArguments arguments); @NonNull @Override ActionResult perform(@NonNull ActionArguments arguments); @Override boolean shouldRunOnMainThread(); @NonNull
    static final String DEFAULT_REGISTRY_NAME; @NonNull
    static final String DEFAULT_REGISTRY_SHORT_NAME; @NonNull
    static final String MESSAGE_ID_PLACEHOLDER; }
@Test public void testPerformNoMessageId() { action.perform(createArgs(Action.SITUATION_MANUAL_INVOCATION, null)); verify(mockMessageCenter).showMessageCenter(); }
@Test public void testPerform() { action.perform(createArgs(Action.SITUATION_MANUAL_INVOCATION, "message_id")); verify(mockMessageCenter).showMessageCenter("message_id"); }
@Test public void testPerformMessageIdPlaceHolderPushMetadata() { Bundle pushBundle = new Bundle(); pushBundle.putString(PushMessage.EXTRA_RICH_PUSH_ID, "the_message_id"); Bundle metadata = new Bundle(); metadata.putParcelable(ActionArguments.PUSH_MESSAGE_METADATA, new PushMessage(pushBundle)); action.perform(createArgs(Action.SITUATION_MANUAL_INVOCATION, "auto", metadata)); verify(mockMessageCenter).showMessageCenter("the_message_id"); }
@Test public void testPerformMessageIdPlaceHolderRichPushMessageMetadata() { Bundle metadata = new Bundle(); metadata.putString(ActionArguments.RICH_PUSH_ID_METADATA, "the_message_id"); action.perform(createArgs(Action.SITUATION_MANUAL_INVOCATION, "auto", metadata)); verify(mockMessageCenter).showMessageCenter("the_message_id"); }
@Test public void testPerformMessageIdPlaceHolderNoMetadata() { action.perform(createArgs(Action.SITUATION_MANUAL_INVOCATION, "auto")); verify(mockMessageCenter).showMessageCenter(); }
@Test public void testPerformEmptyMessageId() { action.perform(createArgs(Action.SITUATION_MANUAL_INVOCATION, "")); verify(mockMessageCenter).showMessageCenter(); }