diff --git a/.github/03-workflow-actions.yaml b/.github/03-workflow-actions.yaml new file mode 100644 index 0000000..e5a39da --- /dev/null +++ b/.github/03-workflow-actions.yaml @@ -0,0 +1,29 @@ +name: 03 - Actions 1.0 + +on: + push: + branches: "feature/**" + +jobs: + checkout_java_docker: + runs-on: ubuntu-latest + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Java SDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Build + uses: docker/build-push-action@v6 + with: + push: false + + - name: Executar scripts + run: | + git branch + java --version + mvn clean package \ No newline at end of file diff --git a/README.md b/README.md index a75f17c..541f35a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Aplicação API docker compose up --build ``` -## Testes unitários +## Testes unitários (validação) ./mvnw test diff --git a/src/main/java/com/github/fiap/simple_api_java/controller/ProdutoController.java b/src/main/java/com/github/fiap/simple_api_java/controller/ProdutoController.java index 7e8ca4c..2204bb2 100644 --- a/src/main/java/com/github/fiap/simple_api_java/controller/ProdutoController.java +++ b/src/main/java/com/github/fiap/simple_api_java/controller/ProdutoController.java @@ -42,7 +42,7 @@ public ResponseEntity findById(@PathVariable Long id) { ProdutoResponseDto responseDto = produtoService .findById(id) .map(produto -> new ProdutoResponseDto().toDto(produto)) - .orElseThrow(() -> new RuntimeException("Deu merda")); + .orElseThrow(() -> new RuntimeException("Erro")); return ResponseEntity.ok().body(responseDto); } @@ -58,7 +58,7 @@ public ResponseEntity create(@RequestBody ProdutoCreateDto r @PutMapping("{id}") public ResponseEntity update(@PathVariable Long id, @RequestBody ProdutoUpdateDto requestDto) { if (! produtoService.existsById(id)) { - new RuntimeException("Deu merda"); + new RuntimeException("Erro"); } Produto produto = produtoService.saveOrUpdate(requestDto.toModel()); @@ -70,7 +70,7 @@ public ResponseEntity update(@PathVariable Long id, @Request @DeleteMapping("{id}") public ResponseEntity update(@PathVariable Long id) { if (!produtoService.existsById(id)) { - new RuntimeException("Deu merda"); + new RuntimeException("Erro"); } produtoService.delete(id); diff --git a/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java b/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java index 3c23c4a..9670a52 100644 --- a/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java +++ b/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java @@ -1,5 +1,6 @@ package com.github.fiap.simple_api_java.controller; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -56,7 +57,7 @@ void testGivenNewProduto_whenCreate_thenSavedProduto() throws Exception{ @DisplayName("test fail") @Test void testGivenNewProduto_whenCreate_thenFail() throws Exception{ - // fail("Uma falha forçada"); + // fail("Um erro acontecerá"); } }