diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index adc1f6c..eaf6a21 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -40,4 +40,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -P coverage -X -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=gherkin-by-example_java-cucumber + run: mvn -P coverage -X -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=loureqdsz_java-cucumber-lourenco-souza diff --git a/pom.xml b/pom.xml index 2491d93..4c4110f 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ 4.13.2 UTF-8 - gherkin-by-example + loureqdsz https://sonarcloud.io diff --git a/src/main/java/br/masmangan/beecrowd/bee1060/Main.java b/src/main/java/br/masmangan/beecrowd/bee1060/Main.java new file mode 100644 index 0000000..71482be --- /dev/null +++ b/src/main/java/br/masmangan/beecrowd/bee1060/Main.java @@ -0,0 +1,36 @@ +package br.masmangan.beecrowd.bee1060; + +import java.util.ArrayList; +import java.util.Scanner; + +import static java.lang.System.in; +import static java.lang.System.out; + +public class Main { + private Main() { + + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(in); + ArrayList inputedNumbers = new ArrayList(); + + inputedNumbers.add(scanner.nextDouble()); + inputedNumbers.add(scanner.nextDouble()); + inputedNumbers.add(scanner.nextDouble()); + inputedNumbers.add(scanner.nextDouble()); + inputedNumbers.add(scanner.nextDouble()); + inputedNumbers.add(scanner.nextDouble()); + + scanner.close(); + + int count = 0; + for (int i=0; i 0) { + count++; + } + } + + out.printf("%d valores positivos%n", count); + } +} diff --git a/src/test/java/br/masmangan/beecrowd/bee1060/RunCucumberTest.java b/src/test/java/br/masmangan/beecrowd/bee1060/RunCucumberTest.java new file mode 100644 index 0000000..b28422b --- /dev/null +++ b/src/test/java/br/masmangan/beecrowd/bee1060/RunCucumberTest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2021, Gherkin By Example and/or its contributors. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This software is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this code. If not, see . + * + * Please visit Gherkin By Example at https://github.com/gherkin-by-example + * if you need additional information or have any questions. + */ +package br.masmangan.beecrowd.bee1060; + +import io.cucumber.junit.Cucumber; +import io.cucumber.junit.CucumberOptions; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions(plugin = {"pretty"}) +public class RunCucumberTest { + +} \ No newline at end of file diff --git a/src/test/java/br/masmangan/beecrowd/bee1060/bee1060Steps.java b/src/test/java/br/masmangan/beecrowd/bee1060/bee1060Steps.java new file mode 100644 index 0000000..b502634 --- /dev/null +++ b/src/test/java/br/masmangan/beecrowd/bee1060/bee1060Steps.java @@ -0,0 +1,52 @@ +package br.masmangan.beecrowd.bee1060; + +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; + +import java.io.*; +import java.nio.charset.StandardCharsets; + +import static org.junit.Assert.assertEquals; + +public class bee1060Steps { + + private String input; + private String actual; + + @Given("The input is") + public void input_is(String input) { + this.input = input; + } + + @When("Program runs") + public void program_runs() throws IOException { + InputStream inputStream = new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)); + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + PrintStream outputStream = new PrintStream(byteArrayOutputStream); + + PrintStream previousOut = System.out; + InputStream previousIn = System.in; + + System.setIn(inputStream); + System.setOut(outputStream); + + Main.main(null); + + actual = byteArrayOutputStream.toString(); + + inputStream.close(); + outputStream.close(); + + System.setOut(previousOut); + System.setIn(previousIn); + } + + @Then("The output should be") + public void output_should_be(String expected) { + assertEquals(expected, actual); + } + +} diff --git a/src/test/resources/br/masmangan/beecrowd/bee1060/bee1060.feature b/src/test/resources/br/masmangan/beecrowd/bee1060/bee1060.feature new file mode 100644 index 0000000..348bee1 --- /dev/null +++ b/src/test/resources/br/masmangan/beecrowd/bee1060/bee1060.feature @@ -0,0 +1,45 @@ +# +# Copyright (C) 2021, Gherkin By Example and/or its contributors. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This code is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this code. If not, see . +# +# Please visit Gherkin By Example at https://github.com/gherkin-by-example +# if you need additional information or have any questions. +@system +Feature: Bee1060 CLI + + Narrative: + + In order to verify the amount of positive numbers + inserted at the beginning of the program, we create this program + to check how many positive numbers there are in the inserted list. + + Scenario: Run program with input 6, 1, -1, 19, 9, 5 (pos, pos) + + Given The input is +""" +7 +-5 +6 +-3.4 +4.6 +12 +""" + When Program runs + Then The output should be +""" +4 valores positivos + +""" \ No newline at end of file