Command implements Serializable { public String toUri() { String baseUri = buildUri(getRoot()); StringBuilder sb = new StringBuilder(baseUri); sb.append(Constants.SEPARATOR_URI.code).append(getAction().name()); if(isEvent()) { sb.append(Constants.SEPARATOR_URI.code).append(getEvent()); } sb.append(Constants.REQUEST_PARAMETER_MARKER.code).append(Constants.MARKER_URI_BEHAVIOR.code).append(Constants.PARAM_ASSIGNMENT_MARKER.code); sb.append(getBehaviors().get(0).name()); getBehaviors().stream().sequential().skip(1).forEach(b->{ sb.append(Constants.SEPARATOR_AND.code).append(b.name()); }); addRequestParamsToUri(sb); return sb.toString(); } 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 testToUri() { Command cmd = CommandBuilder.withUri("/anthem/fep/icr/p/umcase_view:100/pageCreateCaseInfo/tileCreateCaseInfo/sectionUMCaseInfo/formUMCaseInfo/_get").getCommand(); assertEquals("/anthem/fep/icr/p/umcase_view:100/pageCreateCaseInfo/tileCreateCaseInfo/sectionUMCaseInfo/formUMCaseInfo/_get?b=$execute", cmd.toUri()); }
@Test public void testToUriMultipleBehaviors() { Command cmd = CommandBuilder.withUri("/anthem/fep/icr/p/umcase_view:100/pageCreateCaseInfo/tileCreateCaseInfo/sectionUMCaseInfo/formUMCaseInfo/_get").getCommand(); cmd.getBehaviors().add(Behavior.$nav); assertEquals("/anthem/fep/icr/p/umcase_view:100/pageCreateCaseInfo/tileCreateCaseInfo/sectionUMCaseInfo/formUMCaseInfo/_get?b=$executeAnd$nav", cmd.toUri()); }
@Test public void testToUriWithEvent() { Command cmd = CommandBuilder.withUri("/anthem/fep/icr/p/umcase_view:100/pageCreateCaseInfo/tileCreateCaseInfo/sectionUMCaseInfo/formUMCaseInfo/_get").getCommand(); cmd.setEvent("someEvent"); assertEquals("/anthem/fep/icr/p/umcase_view:100/pageCreateCaseInfo/tileCreateCaseInfo/sectionUMCaseInfo/formUMCaseInfo/_get/someEvent?b=$execute", cmd.toUri()); }
@Test public void testToUriWithQueryParams() { Command cmd = CommandBuilder.withUri("/anthem/fep/icr/p/umcase_view:100/pageCreateCaseInfo/tileCreateCaseInfo/sectionUMCaseInfo/formUMCaseInfo/_get?b=$state&abc=cba&abc=xyz&pqr=mnc").getCommand(); String uriWithQueryParams = cmd.toUri(); Command cmd2 = CommandBuilder.withUri(uriWithQueryParams).getCommand(); assertThat(cmd.getRequestParams().size()).isEqualTo(cmd2.getRequestParams().size()); }
@Test public void testToUriWithDefaultBehaviorAndQueryParams() { Command cmd = CommandBuilder.withUri("/anthem/fep/icr/p/umcase_view:100/pageCreateCaseInfo/tileCreateCaseInfo/sectionUMCaseInfo/formUMCaseInfo/_get?abc=cba&abc=xyz&pqr=mnc").getCommand(); String uriWithQueryParams = cmd.toUri(); Command cmd2 = CommandBuilder.withUri(uriWithQueryParams).getCommand(); assertThat(cmd.getRequestParams().size()).isLessThan(cmd2.getRequestParams().size()); }