Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Fix inputs and outputs template java11 (#291)
Browse files Browse the repository at this point in the history
* Fix inputs and outputs template java11

Signed-off-by: Fabiano Chiareto Fernandes <[email protected]>

* Fix method name runNoSecresInput to runNoSecretsInput

Signed-off-by: Fabiano Chiareto Fernandes <[email protected]>
  • Loading branch information
fabianofernandeszup authored Oct 27, 2020
1 parent 06126d3 commit ddd298c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 32 deletions.
20 changes: 12 additions & 8 deletions templates/create_formula/languages/java11/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
},
"label": "Type your name: ",
"name": "input_text",
"type": "text"
"type": "text",
"required": true
},
{
"default": "false",
"items": [
"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",
Expand All @@ -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
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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[36mIve 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[31mIm 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[31mIm 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void runFalseInput() {
}

@Test
public void runNoSecresInput() {
public void runNoSecretsInput() {
new Formula("Hello", false, "world", "").Run();

assertEquals("Hello World!\n" +
Expand Down

0 comments on commit ddd298c

Please sign in to comment.