Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/03-workflow-actions.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Aplicação API
docker compose up --build
```

## Testes unitários
## Testes unitários (validação)

./mvnw test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ResponseEntity<ProdutoResponseDto> 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);
}
Expand All @@ -58,7 +58,7 @@ public ResponseEntity<ProdutoResponseDto> create(@RequestBody ProdutoCreateDto r
@PutMapping("{id}")
public ResponseEntity<ProdutoResponseDto> update(@PathVariable Long id, @RequestBody ProdutoUpdateDto requestDto) {
if (! produtoService.existsById(id)) {
new RuntimeException("Deu merda");
new RuntimeException("Erro");
}

Produto produto = produtoService.saveOrUpdate(requestDto.toModel());
Expand All @@ -70,7 +70,7 @@ public ResponseEntity<ProdutoResponseDto> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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á");
}

}