From ddd298c00f6f8981f1b5f880b0385e46d19193e4 Mon Sep 17 00:00:00 2001 From: Fabiano Chiaretto Fernandes <58859234+fabianofernandeszup@users.noreply.github.com> Date: Tue, 27 Oct 2020 14:50:08 -0300 Subject: [PATCH] Fix inputs and outputs template java11 (#291) * Fix inputs and outputs template java11 Signed-off-by: Fabiano Chiareto Fernandes * Fix method name runNoSecresInput to runNoSecretsInput Signed-off-by: Fabiano Chiareto Fernandes --- .../languages/java11/config.json | 20 ++++++++------ .../src/main/java/com/ritchie/Main.java | 13 +++++---- .../java/com/ritchie/formula/Formula.java | 27 +++++++++++-------- .../java/com/ritchie/formula/FormulaTest.java | 14 +++++----- .../java/com/ritchie/formula/FormulaTest.java | 2 +- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/templates/create_formula/languages/java11/config.json b/templates/create_formula/languages/java11/config.json index 55f75ccd..d3362bdf 100644 --- a/templates/create_formula/languages/java11/config.json +++ b/templates/create_formula/languages/java11/config.json @@ -9,7 +9,8 @@ }, "label": "Type your name: ", "name": "input_text", - "type": "text" + "type": "text", + "required": true }, { "default": "false", @@ -17,9 +18,10 @@ "false", "true" ], - "label": "Have you ever used Ritchie?", + "label": "Have you ever used Ritchie? ", "name": "input_boolean", - "type": "bool" + "type": "bool", + "required": false }, { "default": "everything", @@ -29,14 +31,16 @@ "toils", "everything" ], - "label": "What do you want to automate?", + "label": "What do you want to automate? ", "name": "input_list", - "type": "text" + "type": "text", + "required": false }, { "label": "Tell us a secret: ", - "name": "password", - "type": "password" + "name": "input_password", + "type": "password", + "required": true } ] -} +} \ No newline at end of file diff --git a/templates/create_formula/languages/java11/src/main/java/com/ritchie/Main.java b/templates/create_formula/languages/java11/src/main/java/com/ritchie/Main.java index 333ff114..9eaec0f5 100644 --- a/templates/create_formula/languages/java11/src/main/java/com/ritchie/Main.java +++ b/templates/create_formula/languages/java11/src/main/java/com/ritchie/Main.java @@ -3,12 +3,15 @@ import com.ritchie.formula.Formula; public class Main { + public static void main(String[] args) { - String input_text = System.getenv("INPUT_TEXT"); - String input_list = System.getenv("INPUT_LIST"); - String password = System.getenv("PASSWORD"); - boolean input_boolean = Boolean.parseBoolean(System.getenv("INPUT_BOOLEAN")); - Formula formula = new Formula(input_text, input_list, password, input_boolean); + + String inputText = System.getenv("INPUT_TEXT"); + boolean inputBoolean = Boolean.parseBoolean(System.getenv("INPUT_BOOLEAN")); + String inputList = System.getenv("INPUT_LIST"); + String inputPassword = System.getenv("INPUT_PASSWORD"); + + Formula formula = new Formula(inputText, inputBoolean, inputList, inputPassword); formula.Run(); } } diff --git a/templates/create_formula/languages/java11/src/main/java/com/ritchie/formula/Formula.java b/templates/create_formula/languages/java11/src/main/java/com/ritchie/formula/Formula.java index cbf97da7..f029e1b2 100644 --- a/templates/create_formula/languages/java11/src/main/java/com/ritchie/formula/Formula.java +++ b/templates/create_formula/languages/java11/src/main/java/com/ritchie/formula/Formula.java @@ -9,21 +9,26 @@ public class Formula { private final String inputList; private final String inputPassword; + public Formula(String inputText, boolean inputBoolean, String inputList, String inputPassword) { + this.inputText = inputText; + this.inputBoolean = inputBoolean; + this.inputList = inputList; + this.inputPassword = inputPassword; + } + public void Run() { System.out.println("Hello World!"); + System.out.println(Chalk.on(String.format("My name is %s.", inputText)).green()); - if (inputBoolean) - System.out.println(Chalk.on("I’ve already created formulas using Ritchie.").cyan()); - else - System.out.println(Chalk.on("I’m excited in creating new formulas using Ritchie.").red()); + + if (inputBoolean) { + System.out.println(Chalk.on("I've already created formulas using Ritchie.").cyan()); + } else { + System.out.println(Chalk.on("I'm excited in creating new formulas using Ritchie.").red()); + } + System.out.println(Chalk.on(String.format("Today, I want to automate %s.", inputList)).yellow()); - System.out.println(Chalk.on(String.format("My secret is %s.", inputPassword)).magenta()); - } - public Formula(String inputText, String inputList, String inputPassword, boolean inputBoolean) { - this.inputText = inputText; - this.inputList = inputList; - this.inputPassword = inputPassword; - this.inputBoolean = inputBoolean; + System.out.println(Chalk.on(String.format("My secret is %s.", inputPassword)).magenta()); } } diff --git a/templates/create_formula/languages/java11/src/test/java/com/ritchie/formula/FormulaTest.java b/templates/create_formula/languages/java11/src/test/java/com/ritchie/formula/FormulaTest.java index 2b2c9f09..60c26890 100644 --- a/templates/create_formula/languages/java11/src/test/java/com/ritchie/formula/FormulaTest.java +++ b/templates/create_formula/languages/java11/src/test/java/com/ritchie/formula/FormulaTest.java @@ -26,33 +26,33 @@ public void restoreStreams() { @Test public void runTrueInput() { - new Formula("Hello", "world", "pass", true).Run(); + new Formula("Hello", true, "world", "pass").Run(); + assertEquals("Hello World!\n" + "\u001B[32mMy name is Hello.\u001B[39m\n" + - "\u001B[36mI’ve already created formulas using Ritchie.\u001B[39m\n" + + "\u001B[36mI've already created formulas using Ritchie.\u001B[39m\n" + "\u001B[33mToday, I want to automate world.\u001B[39m\n" + "\u001B[35mMy secret is pass.\u001B[39m\n", outContent.toString()); } - @Test public void runFalseInput() { - new Formula("Hello", "world", "pass", false).Run(); + new Formula("Hello", false, "world", "pass").Run(); assertEquals("Hello World!\n" + "\u001B[32mMy name is Hello.\u001B[39m\n" + - "\u001B[31mI’m excited in creating new formulas using Ritchie.\u001B[39m\n" + + "\u001B[31mI'm excited in creating new formulas using Ritchie.\u001B[39m\n" + "\u001B[33mToday, I want to automate world.\u001B[39m\n" + "\u001B[35mMy secret is pass.\u001B[39m\n", outContent.toString()); } @Test public void runNoSecretsInput() { - new Formula("Hello", "world", "", false).Run(); + new Formula("Hello", false, "world", "").Run(); assertEquals("Hello World!\n" + "\u001B[32mMy name is Hello.\u001B[39m\n" + - "\u001B[31mI’m excited in creating new formulas using Ritchie.\u001B[39m\n" + + "\u001B[31mI'm excited in creating new formulas using Ritchie.\u001B[39m\n" + "\u001B[33mToday, I want to automate world.\u001B[39m\n" + "\u001B[35mMy secret is .\u001B[39m\n", outContent.toString()); } diff --git a/templates/create_formula/languages/java8/src/test/java/com/ritchie/formula/FormulaTest.java b/templates/create_formula/languages/java8/src/test/java/com/ritchie/formula/FormulaTest.java index 6f840055..60c26890 100644 --- a/templates/create_formula/languages/java8/src/test/java/com/ritchie/formula/FormulaTest.java +++ b/templates/create_formula/languages/java8/src/test/java/com/ritchie/formula/FormulaTest.java @@ -47,7 +47,7 @@ public void runFalseInput() { } @Test - public void runNoSecresInput() { + public void runNoSecretsInput() { new Formula("Hello", false, "world", "").Run(); assertEquals("Hello World!\n" +