@Override @Nonnull public String toGroovy(@Nonnull InputDirective directive) { if (directive.getMessage() != null) { StringBuilder result = new StringBuilder("input {\n"); result.append("message ").append(Snippetizer.object2Groovy(directive.getMessage())).append("\n"); if (!StringUtils.isEmpty(directive.getId())) { result.append("id ").append(Snippetizer.object2Groovy(directive.getId())).append("\n"); if (!StringUtils.isEmpty(directive.getOk())) { result.append("ok ").append(Snippetizer.object2Groovy(directive.getOk())).append("\n"); if (!StringUtils.isEmpty(directive.getSubmitter())) { result.append("submitter ").append(Snippetizer.object2Groovy(directive.getSubmitter())).append("\n"); if (!StringUtils.isEmpty(directive.getSubmitterParameter())) { result.append("submitterParameter ").append(Snippetizer.object2Groovy(directive.getSubmitterParameter())).append("\n"); if (!directive.getParameters().isEmpty()) { result.append("parameters {\n"); for (ParameterDefinition p : directive.getParameters()) { result.append(Snippetizer.object2Groovy(UninstantiatedDescribable.from(p))).append("\n");
@Test public void fullInput() throws Exception { InputDirective input = new InputDirective("hello"); input.setId("banana"); input.setOk("Yeah, do it"); input.setSubmitter("bob"); input.setSubmitterParameter("subParam"); List<ParameterDefinition> params = new ArrayList<>(); params.add(new StringParameterDefinition("aString", "steve", "Hey, a string")); params.add(new BooleanParameterDefinition("aBool", true, "A boolean now")); input.setParameters(params); assertGenerateDirective(input, "input {\n" + " message 'hello'\n" + " id 'banana'\n" + " ok 'Yeah, do it'\n" + " submitter 'bob'\n" + " submitterParameter 'subParam'\n" + " parameters {\n" + // StringParameterDefinition added trim field in 2.90 " string defaultValue: 'steve', description: 'Hey, a string', name: 'aString'" + trimParamOrEmpty() + "\n" + " booleanParam defaultValue: true, description: 'A boolean now', name: 'aBool'\n" + " }\n" + "}"); }
@Test public void simpleInput() throws Exception { InputDirective input = new InputDirective("hello"); assertGenerateDirective(input, "input {\n" + " message 'hello'\n" + "}"); }