Command implements Serializable { public void validate() { Optional.ofNullable(getAction()) .orElseThrow(()->new InvalidConfigException(String.format(MISSING_COMMAND_ARGUMENTS_MSG, getAbsoluteUri(), "Action"))); if(CollectionUtils.isEmpty(getBehaviors())) throw new InvalidConfigException(String.format(MISSING_COMMAND_ARGUMENTS_MSG, getAbsoluteUri(), "Behavior")); validateCommandArgument(Type.ClientAlias); validateCommandArgument(Type.AppAlias); validateCommandArgument(Type.PlatformMarker); validateCommandArgument(Type.DomainAlias); } Command(String absoluteUri);  Command(Command source); CollectionsTemplate<List<Behavior>, Behavior> templateBehaviors(); void validate(); boolean isRootDomainOnly(); CommandElementLinked root(); boolean isEvent(); Command createRootDomainCommand(); String getAliasUri(Type type); RefId<?> getRefId(Type type); String getAbsoluteUri(Type type); String getAlias(Type type); Optional<CommandElementLinked> getElement(Type type); CommandElementLinked getElementSafely(Type type); String getRelativeUri(String input); boolean isView(); String getAppAlias(); String getRootClientAlias(); CommandElement getRootDomainElement(); String getRootDomainAlias(); String getRootDomainUri(); String getAbsoluteDomainAlias(); String getAbsoluteDomainUri(); String getProcessAlias(); String getProcessUri(); String getAbsoluteAlias(); String getAbsoluteAliasWithAction(); String getAbsoluteAliasTillRootDomain(); String buildAlias(CommandElementLinked startElem); String buildAlias(Type endWhentype); String buildAlias(CommandElementLinked startElem, Type endWhentype); String buildUri(CommandElementLinked startElem); String buildUri(Type endWhenType); String buildUri(CommandElementLinked startElem, Type endWhenType); String traverseElements(CommandElementLinked startElem, BiConsumer<CommandElement, StringBuilder> cb); void traverseElements(CommandElementLinked startElem, Consumer<CommandElement> cb); String traverseElements(CommandElementLinked startElem, Type type, BiConsumer<CommandElement, StringBuilder> cb); void traverseElements(CommandElementLinked startElem, Type type, Consumer<CommandElement> cb); CommandElementLinked createRoot(Type type, String uri); String toUri(); String toRemoteUri(Type endWhenType, Action withAction, Behavior withBehavior); String[] getParameterValue(String requestParameter); String getFirstParameterValue(String requestParameter); boolean hasRawPayload(); String getRawPayload(); boolean containsFunction();  }
@Test public void testInvalidCommandMissingAction() throws Exception { expectedEx.expect(InvalidConfigException.class); expectedEx.expectMessage("Command with URI: /anthem/p/umcase_view:100 cannot have null Action."); Command cmd = CommandBuilder.withUri("/anthem/p/umcase_view:100").getCommand(); cmd.validate(); }
@Test public void testInvalidCommandMissingBehavior() throws Exception { expectedEx.expect(InvalidConfigException.class); expectedEx.expectMessage("Command with URI: /anthem/org/fep/p/umcase_view:100/_get cannot have null Behavior."); Command cmd = CommandBuilder.withUri("/anthem/org/fep/p/umcase_view:100/_get").getCommand(); cmd.setBehaviors(null); cmd.validate(); }
@Test public void testInvalidCommandMissingAppAlias() throws Exception { expectedEx.expect(InvalidConfigException.class); expectedEx.expectMessage("Command with URI: /anthem/p/umcase_view:100/_get cannot have null AppAlias."); Command cmd = CommandBuilder.withUri("/anthem/p/umcase_view:100/_get").getCommand(); cmd.validate(); }
@Test public void testInvalidCommandMissingDomainAlias() throws Exception { expectedEx.expect(InvalidConfigException.class); expectedEx.expectMessage("Command with URI: /anthem/org/fep/p/_get cannot have null DomainAlias."); Command cmd = CommandBuilder.withUri("/anthem/org/fep/p/_get").getCommand(); cmd.validate(); }