Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b1bdd0d
Primeiros testes e configuração local
Jul 9, 2025
0e10cb5
add classe bebida inicial
guibree2-IN Jul 10, 2025
0f5ab5d
criando classe teste bebida
guibree2-IN Jul 11, 2025
e80443b
subindo classe de teste vazia para teste de commit
gabrielripper1 Jul 12, 2025
bab4f63
Mock de Cadastro de Cliente
Jul 12, 2025
aaa76d4
Mock de Cadastro de Cliente
Jul 12, 2025
015046b
Salvando arquivos antes do merge
Jul 12, 2025
66f5a8d
Mock de Cadastro de Cliente
Jul 12, 2025
8eefa96
Mock de Cadastro de Cliente
Jul 12, 2025
7acfd5a
Refatora Remover ingredientes
Jul 12, 2025
d44ac50
subindo a classe de teste do validador cookie e deletando a classe de…
gabrielripper1 Jul 12, 2025
ee137dc
Testes remover ingredientes
Jul 12, 2025
573a95f
Merge branch 'master' of https://github.com/DanFP00/APS-04-Lanchonete…
gabrielripper1 Jul 12, 2025
392ec93
Merge branch 'master' of https://github.com/DanFP00/APS-04-Lanchonete…
DenielR Jul 12, 2025
fc787c3
+ refatoração e + testes de ingredientes
DenielR Jul 12, 2025
121e336
Testes de integração ingredientes + adição de comentários
DenielR Jul 12, 2025
a762917
Teste de sistema + organizar pastas
DenielR Jul 13, 2025
389c8b9
add classe DaoBebidaTest
guibree2-IN Jul 13, 2025
2f49162
add mock da classe de teste daobebida
guibree2-IN Jul 13, 2025
053cbb4
add testes da classe de teste daobebida
guibree2-IN Jul 13, 2025
9d39f3f
mudando para a pasta certa teste de daobebida
guibree2-IN Jul 13, 2025
fdcfa81
subindo o teste de integracao para o fluxo de compra
gabrielripper1 Jul 13, 2025
308fcf6
Merge branch 'master' of https://github.com/DanFP00/APS-04-Lanchonete…
gabrielripper1 Jul 13, 2025
b7fc170
Testes de integração
Jul 13, 2025
4b10506
Merge branch 'testes/Cliente'
Jul 13, 2025
5dca197
Alterações de Teste de Integração e de Sistemas
Jul 14, 2025
feeee59
testes unitários
Jul 14, 2025
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM maven:3.8.4-openjdk-8 AS build
FROM maven:3.8.4-openjdk-17 AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
COPY web ./web
RUN mvn clean package
RUN mvn clean package -DskipTests

FROM tomcat:8.5-jre8
FROM tomcat:8.5-jdk17-temurin

# Instala o unzip para inspeção do .war
RUN apt-get update && apt-get install -y unzip

# Copia o .war gerado pelo Maven
COPY --from=build /app/target/*.war /usr/local/tomcat/webapps/ROOT.war
COPY context.xml /usr/local/tomcat/conf/
EXPOSE 8080
CMD ["catalina.sh", "run"]
EXPOSE 8080 5005
CMD ["catalina.sh", "run"]
5 changes: 5 additions & 0 deletions Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM maven:3.8.4-openjdk-8

RUN apt-get update && apt-get install -y postgresql-client

WORKDIR /app
87 changes: 85 additions & 2 deletions banco.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CREATE TABLE tb_status_lanchonete (
data_alteracao TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO tb_status_lanchonete (status) VALUES ('FECHADO');
INSERT INTO tb_status_lanchonete (status) VALUES ('ABERTO');

CREATE TABLE tb_funcionarios(
id_funcionario SERIAL,
Expand Down Expand Up @@ -127,4 +127,87 @@ CREATE TABLE tb_tokens(
-- Usuário admin padrão
-- senha: admin (hash MD5: 21232f297a57a5a743894a0e4a801fc3)
INSERT INTO tb_funcionarios (nome, sobrenome, usuario, senha, cargo, salario, cad_por, fg_ativo)
VALUES ('Admin', 'Master', 'admin', '21232f297a57a5a743894a0e4a801fc3', 'admin', 9999.99, NULL, 1);
VALUES ('Admin', 'Master', 'admin', '21232f297a57a5a743894a0e4a801fc3', 'admin', 9999.99, NULL, 1);


INSERT INTO tb_ingredientes (nm_ingrediente, descricao, quantidade, valor_compra, valor_venda, tipo, fg_ativo) VALUES
('Pão de Hambúrguer', 'Pão tradicional para hambúrguer', 100, 0.50, 1.00, 'Pão', 1),
('Carne Bovina 150g', 'Hambúrguer de carne bovina 150g', 50, 3.00, 6.00, 'Proteína', 1),
('Queijo Cheddar', 'Fatia de queijo cheddar', 80, 0.80, 1.50, 'Queijo', 1),
('Alface', 'Folhas de alface fresca', 30, 0.20, 0.50, 'Vegetal', 1),
('Tomate', 'Fatias de tomate fresco', 40, 0.30, 0.60, 'Vegetal', 1),
('Cebola', 'Fatias de cebola roxa', 25, 0.15, 0.40, 'Vegetal', 1),
('Bacon', 'Fatias de bacon crocante', 35, 1.20, 2.50, 'Proteína', 1),
('Molho Especial', 'Molho especial da casa', 60, 0.30, 0.80, 'Molho', 1),
('Maionese', 'Maionese tradicional', 50, 0.25, 0.60, 'Molho', 1),
('Ketchup', 'Molho ketchup', 45, 0.20, 0.50, 'Molho', 1),
('Mostarda', 'Molho mostarda', 40, 0.25, 0.55, 'Molho', 1),
('Picles', 'Picles em fatias', 30, 0.40, 0.80, 'Conserva', 1),
('Batata Frita', 'Porção de batata frita', 70, 1.50, 4.00, 'Acompanhamento', 1),
('Cebola Caramelizada', 'Cebola doce caramelizada', 20, 0.80, 1.80, 'Vegetal', 1),
('Frango Grelhado', 'Peito de frango grelhado', 40, 2.50, 5.50, 'Proteína', 1);


INSERT INTO tb_lanches (nm_lanche, descricao, valor_venda, fg_ativo) VALUES
('X-Burguer', 'Hambúrguer tradicional com carne, queijo, alface e tomate', 12.90, 1),
('X-Bacon', 'Hambúrguer com carne, bacon, queijo, alface e tomate', 15.90, 1),
('X-Frango', 'Hambúrguer de frango grelhado com queijo, alface e tomate', 13.90, 1),
('X-Especial', 'Hambúrguer especial com carne, bacon, queijo, molho especial', 18.90, 1),
('X-Veggie', 'Hambúrguer vegetariano com queijo, alface, tomate e molhos', 11.90, 1);

INSERT INTO tb_ingredientes_lanche (id_lanche, id_ingrediente, quantidade) VALUES
(1, 1, 1), -- Pão
(1, 2, 1), -- Carne
(1, 3, 1), -- Queijo
(1, 4, 2), -- Alface
(1, 5, 2), -- Tomate
(1, 9, 1); -- Maionese

INSERT INTO tb_ingredientes_lanche (id_lanche, id_ingrediente, quantidade) VALUES
(2, 1, 1), -- Pão
(2, 2, 1), -- Carne
(2, 7, 2), -- Bacon
(2, 3, 1), -- Queijo
(2, 4, 2), -- Alface
(2, 5, 2), -- Tomate
(2, 9, 1); -- Maionese

INSERT INTO tb_ingredientes_lanche (id_lanche, id_ingrediente, quantidade) VALUES
(3, 1, 1), -- Pão
(3, 15, 1), -- Frango
(3, 3, 1), -- Queijo
(3, 4, 2), -- Alface
(3, 5, 2), -- Tomate
(3, 9, 1); -- Maionese

INSERT INTO tb_ingredientes_lanche (id_lanche, id_ingrediente, quantidade) VALUES
(4, 1, 1), -- Pão
(4, 2, 1), -- Carne
(4, 7, 2), -- Bacon
(4, 3, 1), -- Queijo
(4, 14, 1), -- Cebola Caramelizada
(4, 8, 1), -- Molho Especial
(4, 12, 2); -- Picles

INSERT INTO tb_ingredientes_lanche (id_lanche, id_ingrediente, quantidade) VALUES
(5, 1, 1), -- Pão
(5, 3, 1), -- Queijo
(5, 4, 3), -- Alface
(5, 5, 3), -- Tomate
(5, 6, 2), -- Cebola
(5, 9, 1), -- Maionese
(5, 11, 1); -- Mostarda

INSERT INTO tb_bebidas (nm_bebida, descricao, quantidade, valor_compra, valor_venda, tipo, fg_ativo) VALUES
('Coca-Cola 350ml', 'Refrigerante Coca-Cola lata 350ml', 100, 1.50, 4.50, 'Refrigerante', 1),
('Pepsi 350ml', 'Refrigerante Pepsi lata 350ml', 80, 1.40, 4.30, 'Refrigerante', 1),
('Guaraná Antarctica 350ml', 'Refrigerante Guaraná Antarctica lata 350ml', 90, 1.45, 4.40, 'Refrigerante', 1),
('Fanta Laranja 350ml', 'Refrigerante Fanta Laranja lata 350ml', 70, 1.40, 4.30, 'Refrigerante', 1),
('Sprite 350ml', 'Refrigerante Sprite lata 350ml', 75, 1.40, 4.30, 'Refrigerante', 1),
('Suco de Laranja 300ml', 'Suco natural de laranja 300ml', 40, 2.00, 5.50, 'Suco Natural', 1),
('Suco de Uva 300ml', 'Suco natural de uva 300ml', 35, 2.20, 5.70, 'Suco Natural', 1),
('Água Mineral 500ml', 'Água mineral sem gás 500ml', 60, 0.80, 2.50, 'Água', 1),
('Água com Gás 500ml', 'Água mineral com gás 500ml', 45, 1.00, 2.80, 'Água', 1),
('Milkshake Chocolate', 'Milkshake cremoso sabor chocolate', 25, 3.50, 8.90, 'Milkshake', 1),
('Milkshake Morango', 'Milkshake cremoso sabor morango', 25, 3.50, 8.90, 'Milkshake', 1),
('Café Expresso', 'Café expresso tradicional', 50, 0.60, 3.50, 'Café', 1);
20 changes: 18 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'

services:
db:
Expand Down Expand Up @@ -27,4 +26,21 @@ services:
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/lanchonete
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=postgres
- SPRING_DATASOURCE_PASSWORD=postgres

tests:
image: maven:3.8.4-openjdk-8
working_dir: /app
volumes:
- ./:/app
depends_on:
db:
condition: service_healthy
# Instala o psql e roda o script de testes
command: /bin/bash -c "apt-get update && apt-get install -y postgresql-client && ./scripts/run_tests.sh"
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/lanchonete
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=postgres
ports:
- "5005:5005"
51 changes: 51 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<!-- Selenium Java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.21.0</version> <!-- ou a versão mais recente compatível -->
</dependency>

<!-- WebDriverManager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.8.0</version>
</dependency>

<!-- JSTL -->
<dependency>
Expand Down Expand Up @@ -51,6 +65,33 @@
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>

<!-- Mockito Core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.15.0</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -64,6 +105,11 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
Expand All @@ -74,6 +120,11 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat9-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

echo "Esperando o banco de dados ficar pronto..."
until pg_isready -h db -p 5432 -U postgres; do
>&2 echo "Banco de dados não está pronto ainda..."
sleep 2
done

echo "Banco de dados está pronto. Rodando testes em modo DEBUG..."

# Forçando debug manualmente com suspend=y para aguardar conexão do IntelliJ
mvn test -DforkCount=0 -Dmaven.surefire.argLine="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"
4 changes: 2 additions & 2 deletions src/java/Controllers/cadastro.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re

//E Para finalizar, salva no Banco usando o DAO deles
cliente.setEndereco(endereco);

DaoCliente clienteDAO = new DaoCliente();
clienteDAO.salvar(cliente);

Expand Down Expand Up @@ -119,7 +119,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
Expand Down
Loading