com.fivefaces.structureclient.service.statemachine.impl.ScaffoldPass Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-structure-client Show documentation
Show all versions of common-structure-client Show documentation
structure Client for Five Faces
The newest version!
package com.fivefaces.structureclient.service.statemachine.impl;
import com.fivefaces.structureclient.service.statemachine.ScaffoldStateMachineResult;
import com.fivefaces.structureclient.service.statemachine.ScaffoldUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
@AllArgsConstructor
public class ScaffoldPass {
private final ScaffoldUtils scaffoldUtils;
public String scaffold(String line, ScaffoldStateMachineResult result, String[] lines, int counter, String stateMachine) throws Exception {
final Map passParameters = scaffoldUtils.getParameters(line, "name");
String next = " \"End\": true";
if (passParameters.containsKey("next")) {
next = String.format(" \"Next\": \"%s\"", passParameters.get("next"));
if (!scaffoldUtils.getSteps(lines).contains(passParameters.get("next"))) {
result.getWarnings().add(String.format("Next value of %s is not valid for step %s",
passParameters.get("next"), passParameters.get("name")));
}
} else {
if (counter + 1 < lines.length) {
next = String.format(" \"Next\": \"%s\"", scaffoldUtils.getStepName(lines[counter + 1]));
}
}
return stateMachine.replace("***" + passParameters.get("name") + "***", String.format(" \"Type\": \"Pass\",\n%s", next));
}
}