Skip to content

Commit

Permalink
Merge pull request #2 from leco123/MODULO-3
Browse files Browse the repository at this point in the history
Modulo 3
  • Loading branch information
leco123 authored Dec 9, 2023
2 parents f13ecd1 + 461dec2 commit 1b4d2dd
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.algaworks.junit.blog.negocio;

import com.algaworks.junit.blog.armazenamento.ArmazenamentoEditor;
import com.algaworks.junit.blog.modelo.Editor;

import java.util.List;
import java.util.Optional;

import static java.util.Objects.isNull;

/**
* Implementação Sub, ou seja, Duble, ficticia
*/
public class ArmazenamentoEditorFixoEmMemoria implements ArmazenamentoEditor {

@Override
public Editor salvar(Editor editor) {
if (isNull(editor)) {
editor.setId(1L);
}
return editor;
}

@Override
public Optional<Editor> encontrarPorId(Long editor) {
return Optional.empty();
}

@Override
public Optional<Editor> encontrarPorEmail(String email) {
return Optional.empty();
}

@Override
public Optional<Editor> encontrarPorEmailComIdDiferenteDe(String email, Long id) {
return Optional.empty();
}

@Override
public void remover(Long editorId) {

}

@Override
public List<Editor> encontrarTodos() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.algaworks.junit.blog.negocio;

import com.algaworks.junit.blog.modelo.Editor;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;

@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
class CadastroEditorTest {

static CadastroEditor cadastroEditor;
Editor editor;

//Executa antes de todos os testes
@BeforeAll
static void beforeAll() {

System.out.println("@BeforeAll: Antes de todos os testes");

cadastroEditor = new CadastroEditor(
new ArmazenamentoEditorFixoEmMemoria(),
new GerenciadorEnvioEmail() {

@Override
void enviarEmail(Mensagem mensagem) {
System.out.println("Enviando mensagem para: "+mensagem.getDestinatario());
}
}
);
}

// Preparar as variáveis para o senário de teste;
@BeforeEach
void beforeEach() {

// [A]rrange: Preparar as variáveis para o senário de teste;
System.out.println("@BeforeEach: Executa antes de cada teste");

editor = new Editor();
}

}

0 comments on commit 1b4d2dd

Please sign in to comment.