@Test public void itShouldReturnFailedOnErrorAndCustomOutput() { actionStep.setErrorOutput("not found"); given(webSiteConnector.getDriver().getPageSource()).willReturn("something"); ExecuteResult result = symbol.execute(connectorManager); assertFalse(result.isSuccess()); assertEquals(ExecuteResult.DEFAULT_ERROR_OUTPUT + " (not found)", result.getOutput()); }
@Override public ExecuteResult execute(ConnectorManager connectors) throws SULException { LOGGER.info(LoggerMarkers.LEARNER, "Executing Symbol {} ({})...", String.valueOf(id), name); if (steps.isEmpty()) { return new ExecuteResult(false, "Not implemented"); } final Map<String, Integer> labels = getLabelsMap(); ExecuteResult result = new ExecuteResult(true); final long startTime = System.currentTimeMillis(); for (int i = 0; i < steps.size(); i++) { final SymbolStep step = steps.get(i); if (!step.isDisabled()) { final ExecuteResult stepResult = step.execute(i, connectors); if (!stepResult.isSuccess() && !step.isIgnoreFailure()) { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { continue; } result = stepResult; if (step.errorOutput != null && !step.errorOutput.equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, getProjectId(), step.errorOutput)); } else { result.setMessage(String.valueOf(i + 1)); } result.addTrace(this, result); break; } else { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { final String label = ((JumpToLabelAction) ((SymbolActionStep) step).getAction()).getLabel(); i = labels.get(label); } } } } result.setTime(System.currentTimeMillis() - startTime); if (result.isSuccess()) { if (successOutput != null && !successOutput.trim().equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, project.getId(), successOutput)); } } LOGGER.info(LoggerMarkers.LEARNER, "Executed the Symbol {} ({}) => {}.", String.valueOf(id), name, result); return result; }
Symbol implements ContextExecutableInput<ExecuteResult, ConnectorManager>, Serializable { @Override public ExecuteResult execute(ConnectorManager connectors) throws SULException { LOGGER.info(LoggerMarkers.LEARNER, "Executing Symbol {} ({})...", String.valueOf(id), name); if (steps.isEmpty()) { return new ExecuteResult(false, "Not implemented"); } final Map<String, Integer> labels = getLabelsMap(); ExecuteResult result = new ExecuteResult(true); final long startTime = System.currentTimeMillis(); for (int i = 0; i < steps.size(); i++) { final SymbolStep step = steps.get(i); if (!step.isDisabled()) { final ExecuteResult stepResult = step.execute(i, connectors); if (!stepResult.isSuccess() && !step.isIgnoreFailure()) { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { continue; } result = stepResult; if (step.errorOutput != null && !step.errorOutput.equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, getProjectId(), step.errorOutput)); } else { result.setMessage(String.valueOf(i + 1)); } result.addTrace(this, result); break; } else { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { final String label = ((JumpToLabelAction) ((SymbolActionStep) step).getAction()).getLabel(); i = labels.get(label); } } } } result.setTime(System.currentTimeMillis() - startTime); if (result.isSuccess()) { if (successOutput != null && !successOutput.trim().equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, project.getId(), successOutput)); } } LOGGER.info(LoggerMarkers.LEARNER, "Executed the Symbol {} ({}) => {}.", String.valueOf(id), name, result); return result; } }
Symbol implements ContextExecutableInput<ExecuteResult, ConnectorManager>, Serializable { @Override public ExecuteResult execute(ConnectorManager connectors) throws SULException { LOGGER.info(LoggerMarkers.LEARNER, "Executing Symbol {} ({})...", String.valueOf(id), name); if (steps.isEmpty()) { return new ExecuteResult(false, "Not implemented"); } final Map<String, Integer> labels = getLabelsMap(); ExecuteResult result = new ExecuteResult(true); final long startTime = System.currentTimeMillis(); for (int i = 0; i < steps.size(); i++) { final SymbolStep step = steps.get(i); if (!step.isDisabled()) { final ExecuteResult stepResult = step.execute(i, connectors); if (!stepResult.isSuccess() && !step.isIgnoreFailure()) { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { continue; } result = stepResult; if (step.errorOutput != null && !step.errorOutput.equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, getProjectId(), step.errorOutput)); } else { result.setMessage(String.valueOf(i + 1)); } result.addTrace(this, result); break; } else { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { final String label = ((JumpToLabelAction) ((SymbolActionStep) step).getAction()).getLabel(); i = labels.get(label); } } } } result.setTime(System.currentTimeMillis() - startTime); if (result.isSuccess()) { if (successOutput != null && !successOutput.trim().equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, project.getId(), successOutput)); } } LOGGER.info(LoggerMarkers.LEARNER, "Executed the Symbol {} ({}) => {}.", String.valueOf(id), name, result); return result; } Symbol(); }
Symbol implements ContextExecutableInput<ExecuteResult, ConnectorManager>, Serializable { @Override public ExecuteResult execute(ConnectorManager connectors) throws SULException { LOGGER.info(LoggerMarkers.LEARNER, "Executing Symbol {} ({})...", String.valueOf(id), name); if (steps.isEmpty()) { return new ExecuteResult(false, "Not implemented"); } final Map<String, Integer> labels = getLabelsMap(); ExecuteResult result = new ExecuteResult(true); final long startTime = System.currentTimeMillis(); for (int i = 0; i < steps.size(); i++) { final SymbolStep step = steps.get(i); if (!step.isDisabled()) { final ExecuteResult stepResult = step.execute(i, connectors); if (!stepResult.isSuccess() && !step.isIgnoreFailure()) { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { continue; } result = stepResult; if (step.errorOutput != null && !step.errorOutput.equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, getProjectId(), step.errorOutput)); } else { result.setMessage(String.valueOf(i + 1)); } result.addTrace(this, result); break; } else { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { final String label = ((JumpToLabelAction) ((SymbolActionStep) step).getAction()).getLabel(); i = labels.get(label); } } } } result.setTime(System.currentTimeMillis() - startTime); if (result.isSuccess()) { if (successOutput != null && !successOutput.trim().equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, project.getId(), successOutput)); } } LOGGER.info(LoggerMarkers.LEARNER, "Executed the Symbol {} ({}) => {}.", String.valueOf(id), name, result); return result; } Symbol(); @ManyToOne(fetch = FetchType.EAGER, optional = false) @JoinColumn(name = "projectId") @JsonIgnore Project getProject(); @JsonIgnore void setProject(Project project); @Transient @JsonProperty("project") Long getProjectId(); @JsonProperty("project") void setProjectId(Long projectId); @ManyToOne(fetch = FetchType.EAGER, optional = false) @JoinColumn(name = "groupId") @JsonIgnore SymbolGroup getGroup(); @JsonIgnore void setGroup(SymbolGroup group); @Transient @JsonProperty("group") Long getGroupId(); @JsonProperty("group") void setGroupId(Long groupId); @Id @GeneratedValue @JsonProperty Long getId(); @JsonProperty void setId(Long id); @NotBlank @JsonProperty String getName(); @JsonProperty void setName(String name); @JsonProperty @Column(columnDefinition = "MEDIUMTEXT") String getDescription(); @JsonProperty void setDescription(String description); @JsonProperty @Column(columnDefinition = "MEDIUMTEXT") String getExpectedResult(); @Column void setExpectedResult(String expectedResult); boolean isHidden(); void setHidden(boolean hidden); @JsonProperty String getSuccessOutput(); @JsonProperty void setSuccessOutput(String successOutput); @OneToMany( cascade = {CascadeType.REMOVE}, orphanRemoval = true ) @OrderBy("name ASC") @JsonProperty List<SymbolInputParameter> getInputs(); @JsonProperty void setInputs(List<SymbolInputParameter> inputs); @OneToMany( cascade = {CascadeType.REMOVE}, orphanRemoval = true ) @OrderBy("name ASC") @JsonProperty List<SymbolOutputParameter> getOutputs(); @JsonProperty void setOutputs(List<SymbolOutputParameter> outputs); @OneToMany( cascade = {CascadeType.REMOVE, CascadeType.MERGE}, mappedBy = "symbol" ) @OrderBy("position ASC") @JsonProperty List<SymbolStep> getSteps(); @JsonProperty void setSteps(List<SymbolStep> steps); ZonedDateTime getUpdatedOn(); void setUpdatedOn(ZonedDateTime updatedOn); @Transient @JsonProperty("updatedOn") String getUpdatedOnString(); @JsonProperty("updatedOn") void setUpdatedOnString(String updatedOnString); @Override ExecuteResult execute(ConnectorManager connectors); boolean containsParameter(SymbolParameter parameter); void addParameter(SymbolParameter parameter); void removeParameter(SymbolParameter parameter); SymbolInputParameter findInputByNameAndType(String name, SymbolParameter.ParameterType type); SymbolOutputParameter findOutputByNameAndType(String name, SymbolParameter.ParameterType type); @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "lastUpdatedById") @JsonProperty("lastUpdatedBy") User getlastUpdatedBy(); @JsonIgnore void setlastUpdatedBy(User user); @Override @SuppressWarnings({"checkstyle:needbraces", "checkstyle:operatorwrap"}) // Partly auto generated by IntelliJ boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
Symbol implements ContextExecutableInput<ExecuteResult, ConnectorManager>, Serializable { @Override public ExecuteResult execute(ConnectorManager connectors) throws SULException { LOGGER.info(LoggerMarkers.LEARNER, "Executing Symbol {} ({})...", String.valueOf(id), name); if (steps.isEmpty()) { return new ExecuteResult(false, "Not implemented"); } final Map<String, Integer> labels = getLabelsMap(); ExecuteResult result = new ExecuteResult(true); final long startTime = System.currentTimeMillis(); for (int i = 0; i < steps.size(); i++) { final SymbolStep step = steps.get(i); if (!step.isDisabled()) { final ExecuteResult stepResult = step.execute(i, connectors); if (!stepResult.isSuccess() && !step.isIgnoreFailure()) { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { continue; } result = stepResult; if (step.errorOutput != null && !step.errorOutput.equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, getProjectId(), step.errorOutput)); } else { result.setMessage(String.valueOf(i + 1)); } result.addTrace(this, result); break; } else { if (step instanceof SymbolActionStep && ((SymbolActionStep) step).getAction() instanceof JumpToLabelAction) { final String label = ((JumpToLabelAction) ((SymbolActionStep) step).getAction()).getLabel(); i = labels.get(label); } } } } result.setTime(System.currentTimeMillis() - startTime); if (result.isSuccess()) { if (successOutput != null && !successOutput.trim().equals("")) { result.setMessage(SearchHelper.insertVariableValues(connectors, project.getId(), successOutput)); } } LOGGER.info(LoggerMarkers.LEARNER, "Executed the Symbol {} ({}) => {}.", String.valueOf(id), name, result); return result; } Symbol(); @ManyToOne(fetch = FetchType.EAGER, optional = false) @JoinColumn(name = "projectId") @JsonIgnore Project getProject(); @JsonIgnore void setProject(Project project); @Transient @JsonProperty("project") Long getProjectId(); @JsonProperty("project") void setProjectId(Long projectId); @ManyToOne(fetch = FetchType.EAGER, optional = false) @JoinColumn(name = "groupId") @JsonIgnore SymbolGroup getGroup(); @JsonIgnore void setGroup(SymbolGroup group); @Transient @JsonProperty("group") Long getGroupId(); @JsonProperty("group") void setGroupId(Long groupId); @Id @GeneratedValue @JsonProperty Long getId(); @JsonProperty void setId(Long id); @NotBlank @JsonProperty String getName(); @JsonProperty void setName(String name); @JsonProperty @Column(columnDefinition = "MEDIUMTEXT") String getDescription(); @JsonProperty void setDescription(String description); @JsonProperty @Column(columnDefinition = "MEDIUMTEXT") String getExpectedResult(); @Column void setExpectedResult(String expectedResult); boolean isHidden(); void setHidden(boolean hidden); @JsonProperty String getSuccessOutput(); @JsonProperty void setSuccessOutput(String successOutput); @OneToMany( cascade = {CascadeType.REMOVE}, orphanRemoval = true ) @OrderBy("name ASC") @JsonProperty List<SymbolInputParameter> getInputs(); @JsonProperty void setInputs(List<SymbolInputParameter> inputs); @OneToMany( cascade = {CascadeType.REMOVE}, orphanRemoval = true ) @OrderBy("name ASC") @JsonProperty List<SymbolOutputParameter> getOutputs(); @JsonProperty void setOutputs(List<SymbolOutputParameter> outputs); @OneToMany( cascade = {CascadeType.REMOVE, CascadeType.MERGE}, mappedBy = "symbol" ) @OrderBy("position ASC") @JsonProperty List<SymbolStep> getSteps(); @JsonProperty void setSteps(List<SymbolStep> steps); ZonedDateTime getUpdatedOn(); void setUpdatedOn(ZonedDateTime updatedOn); @Transient @JsonProperty("updatedOn") String getUpdatedOnString(); @JsonProperty("updatedOn") void setUpdatedOnString(String updatedOnString); @Override ExecuteResult execute(ConnectorManager connectors); boolean containsParameter(SymbolParameter parameter); void addParameter(SymbolParameter parameter); void removeParameter(SymbolParameter parameter); SymbolInputParameter findInputByNameAndType(String name, SymbolParameter.ParameterType type); SymbolOutputParameter findOutputByNameAndType(String name, SymbolParameter.ParameterType type); @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "lastUpdatedById") @JsonProperty("lastUpdatedBy") User getlastUpdatedBy(); @JsonIgnore void setlastUpdatedBy(User user); @Override @SuppressWarnings({"checkstyle:needbraces", "checkstyle:operatorwrap"}) // Partly auto generated by IntelliJ boolean equals(Object o); @Override int hashCode(); @Override String toString();  }