Compare commits
No commits in common. "6cf77fecbab18462fb067fbf26a97c38d8f1dfbc" and "00ff840ea519b5b9c6afdfeeeb00b86b5f15d69c" have entirely different histories.
6cf77fecba
...
00ff840ea5
22 changed files with 107 additions and 408 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -67,7 +67,3 @@ coverage
|
||||||
|
|
||||||
test-results/
|
test-results/
|
||||||
playwright-report/
|
playwright-report/
|
||||||
|
|
||||||
.env
|
|
||||||
*Rascunho*
|
|
||||||
http_client/
|
|
55
pom.xml
55
pom.xml
|
@ -9,15 +9,13 @@
|
||||||
<properties>
|
<properties>
|
||||||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
||||||
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
||||||
<quarkus.platform.version>3.25.0</quarkus.platform.version>
|
<quarkus.platform.version>3.24.5</quarkus.platform.version>
|
||||||
<compiler-plugin.version>3.14.0</compiler-plugin.version>
|
<compiler-plugin.version>3.11.0</compiler-plugin.version>
|
||||||
<surefire-plugin.version>3.1.2</surefire-plugin.version>
|
<surefire-plugin.version>3.1.2</surefire-plugin.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<maven.compiler.parameters>true</maven.compiler.parameters>
|
<maven.compiler.parameters>true</maven.compiler.parameters>
|
||||||
<lombok.version>1.18.38</lombok.version>
|
|
||||||
<hibernate.version></hibernate.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -33,41 +31,15 @@
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Geração de código -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${lombok.version}</version>
|
<version>1.18.38</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- HTTP -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-rest-jackson</artifactId>
|
<artifactId>quarkus-rest-jackson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Validação -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-hibernate-validator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Persistência -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-hibernate-orm</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-jdbc-postgresql</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>jakarta.data</groupId>
|
|
||||||
<artifactId>jakarta.data-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Testes -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-junit5</artifactId>
|
<artifactId>quarkus-junit5</artifactId>
|
||||||
|
@ -78,7 +50,6 @@
|
||||||
<artifactId>rest-assured</artifactId>
|
<artifactId>rest-assured</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -86,20 +57,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${compiler-plugin.version}</version>
|
<version>${compiler-plugin.version}</version>
|
||||||
<configuration>
|
|
||||||
<parameters>true</parameters>
|
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>org.hibernate.orm</groupId>
|
|
||||||
<artifactId>hibernate-processor</artifactId>
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.version}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
@ -152,9 +109,7 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<native.image.path>
|
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
||||||
${project.build.directory}/${project.build.finalName}-runner
|
|
||||||
</native.image.path>
|
|
||||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
<maven.home>${maven.home}</maven.home>
|
<maven.home>${maven.home}</maven.home>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
|
@ -166,4 +121,4 @@
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@primeuix/themes": "^1.2.2",
|
"@primeuix/themes": "^1.2.2",
|
||||||
"primeicons": "^7.0.0",
|
|
||||||
"primevue": "^4.3.6",
|
"primevue": "^4.3.6",
|
||||||
"vue": "^3.5.17"
|
"vue": "^3.5.17"
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,9 +11,6 @@ importers:
|
||||||
'@primeuix/themes':
|
'@primeuix/themes':
|
||||||
specifier: ^1.2.2
|
specifier: ^1.2.2
|
||||||
version: 1.2.2
|
version: 1.2.2
|
||||||
primeicons:
|
|
||||||
specifier: ^7.0.0
|
|
||||||
version: 7.0.0
|
|
||||||
primevue:
|
primevue:
|
||||||
specifier: ^4.3.6
|
specifier: ^4.3.6
|
||||||
version: 4.3.6(vue@3.5.18(typescript@5.8.3))
|
version: 4.3.6(vue@3.5.18(typescript@5.8.3))
|
||||||
|
@ -1673,9 +1670,6 @@ packages:
|
||||||
resolution: {integrity: sha512-4yf0QO/sllf/1zbZWYnvWw3NxCQwLXKzIj0G849LSufP15BXKM0rbD2Z3wVnkMfjdn/CB0Dpp444gYAACdsplg==}
|
resolution: {integrity: sha512-4yf0QO/sllf/1zbZWYnvWw3NxCQwLXKzIj0G849LSufP15BXKM0rbD2Z3wVnkMfjdn/CB0Dpp444gYAACdsplg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
primeicons@7.0.0:
|
|
||||||
resolution: {integrity: sha512-jK3Et9UzwzTsd6tzl2RmwrVY/b8raJ3QZLzoDACj+oTJ0oX7L9Hy+XnVwgo4QVKlKpnP/Ur13SXV/pVh4LzaDw==}
|
|
||||||
|
|
||||||
primevue@4.3.6:
|
primevue@4.3.6:
|
||||||
resolution: {integrity: sha512-Wwg2dH6pBmOdkj9L/OnrCQf9AKPHfY5CcfnDyWeh0tNlR+XjYKGl8qvMdJOvGO9jjg6UdsX5MSaU8vDDsSG+sg==}
|
resolution: {integrity: sha512-Wwg2dH6pBmOdkj9L/OnrCQf9AKPHfY5CcfnDyWeh0tNlR+XjYKGl8qvMdJOvGO9jjg6UdsX5MSaU8vDDsSG+sg==}
|
||||||
engines: {node: '>=12.11.0'}
|
engines: {node: '>=12.11.0'}
|
||||||
|
@ -3714,8 +3708,6 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
parse-ms: 4.0.0
|
parse-ms: 4.0.0
|
||||||
|
|
||||||
primeicons@7.0.0: {}
|
|
||||||
|
|
||||||
primevue@4.3.6(vue@3.5.18(typescript@5.8.3)):
|
primevue@4.3.6(vue@3.5.18(typescript@5.8.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@primeuix/styled': 0.7.1
|
'@primeuix/styled': 0.7.1
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { ref, type Ref } from 'vue';
|
import { ref, type Ref } from 'vue';
|
||||||
import TabelaDeJogos from './components/TabelaDeJogos.vue';
|
import TabelaDeJogos from './components/TabelaDeJogos.vue';
|
||||||
import type Jogo from './modelo/Jogo';
|
import type Jogo from './modelo/Jogo';
|
||||||
|
import { Button } from 'primevue';
|
||||||
|
|
||||||
const jogos: Ref<Jogo[]> = ref([]);
|
const jogos: Ref<Jogo[]> = ref([]);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ defineProps<{
|
||||||
<Column field="id" sortable header="ID" />
|
<Column field="id" sortable header="ID" />
|
||||||
<Column field="nome" sortable header="Nome" />
|
<Column field="nome" sortable header="Nome" />
|
||||||
<Column field="estado" sortable header="Estado" />
|
<Column field="estado" sortable header="Estado" />
|
||||||
<Column field="preco" sortable header="Preço" />
|
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
</template>
|
</template>
|
11
src/frontend/src/components/__tests__/HelloWorld.spec.ts
Normal file
11
src/frontend/src/components/__tests__/HelloWorld.spec.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { describe, it, expect } from 'vitest'
|
||||||
|
|
||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import HelloWorld from '../HelloWorld.vue'
|
||||||
|
|
||||||
|
describe('HelloWorld', () => {
|
||||||
|
it('renders properly', () => {
|
||||||
|
const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
|
||||||
|
expect(wrapper.text()).toContain('Hello Vitest')
|
||||||
|
})
|
||||||
|
})
|
|
@ -2,13 +2,8 @@ export default class Jogo {
|
||||||
constructor(
|
constructor(
|
||||||
public id: string,
|
public id: string,
|
||||||
public nome: string,
|
public nome: string,
|
||||||
public ano: number,
|
public estado: Estado
|
||||||
public estado: Estado,
|
|
||||||
public loja: string,
|
|
||||||
public preco: Preco
|
|
||||||
) { }
|
) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Preco = 'VALOR' | 'DE_GRACA' | 'DESCONHECIDO' | 'PRESENTE' | number;
|
export type Estado = 'NOVO' | 'ZERADO';
|
||||||
|
|
||||||
export type Estado = 'NOVO' | 'JOGUEI' | 'SATISFEITO' | 'PALHA' | 'ETERNO';
|
|
|
@ -1,20 +0,0 @@
|
||||||
package casa.sotu.organizajogos.api.excecao;
|
|
||||||
|
|
||||||
public class OrganizaJogosExcecao extends RuntimeException {
|
|
||||||
|
|
||||||
public OrganizaJogosExcecao(String mensagem, Throwable causa) {
|
|
||||||
super(mensagem, causa);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganizaJogosExcecao(Throwable causa) {
|
|
||||||
super(causa);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganizaJogosExcecao(String mensagem) {
|
|
||||||
super(mensagem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrganizaJogosExcecao() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package casa.sotu.organizajogos.api.excecao;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import casa.sotu.organizajogos.api.modelo.Preco.TipoDePreco;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class PrecoInvalidoExcecao extends OrganizaJogosExcecao {
|
|
||||||
|
|
||||||
private final BigDecimal valor;
|
|
||||||
private final TipoDePreco tipo;
|
|
||||||
|
|
||||||
public PrecoInvalidoExcecao(BigDecimal valor, TipoDePreco tipo) {
|
|
||||||
this.tipo = tipo;
|
|
||||||
this.valor = valor;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package casa.sotu.organizajogos.api.json;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JacksonException;
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
|
||||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
|
||||||
|
|
||||||
import casa.sotu.organizajogos.api.modelo.Preco;
|
|
||||||
import casa.sotu.organizajogos.api.modelo.Preco.TipoDePreco;
|
|
||||||
|
|
||||||
public class DesserializadorDePreco extends StdDeserializer<Preco> {
|
|
||||||
|
|
||||||
protected DesserializadorDePreco() {
|
|
||||||
this(Preco.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DesserializadorDePreco(Class<?> vc) {
|
|
||||||
super(vc);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Preco deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException {
|
|
||||||
|
|
||||||
String value = p.getValueAsString();
|
|
||||||
try {
|
|
||||||
return new Preco(new BigDecimal(value));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return new Preco(TipoDePreco.valueOf(value.toUpperCase()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package casa.sotu.organizajogos.api.json;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
|
||||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
|
||||||
|
|
||||||
import casa.sotu.organizajogos.api.modelo.Preco;
|
|
||||||
import casa.sotu.organizajogos.api.modelo.Preco.TipoDePreco;
|
|
||||||
|
|
||||||
public class SerializadorDePreco extends StdSerializer<Preco> {
|
|
||||||
|
|
||||||
protected SerializadorDePreco() {
|
|
||||||
this(Preco.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SerializadorDePreco(Class<Preco> t) {
|
|
||||||
super(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(Preco preco, JsonGenerator generator, SerializerProvider provider) throws IOException {
|
|
||||||
if (preco.tipo() == TipoDePreco.VALOR) {
|
|
||||||
generator.writeString(preco.valor().toString());
|
|
||||||
} else {
|
|
||||||
generator.writeString(preco.tipo().name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
package casa.sotu.organizajogos.api.modelo;
|
package casa.sotu.organizajogos.api.modelo;
|
||||||
|
|
||||||
public enum Estado {
|
public enum Estado {
|
||||||
NOVO, JOGUEI, SATISFEITO, ETERNO;
|
NOVO, ZERADO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,12 @@
|
||||||
package casa.sotu.organizajogos.api.modelo;
|
package casa.sotu.organizajogos.api.modelo;
|
||||||
|
|
||||||
import java.time.Year;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import casa.sotu.organizajogos.api.modelo.Preco.TipoDePreco;
|
import lombok.Data;
|
||||||
import jakarta.persistence.AttributeOverride;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.EnumType;
|
|
||||||
import jakarta.persistence.Enumerated;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@Entity
|
|
||||||
public class Jogo {
|
public class Jogo {
|
||||||
|
|
||||||
@Id
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
private String nome;
|
private String nome;
|
||||||
|
|
||||||
private Year ano;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
private Estado estado;
|
private Estado estado;
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
private String loja;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@AttributeOverride(name = "tipo", column = @Column(name = "tipo_de_preco", nullable = false))
|
|
||||||
private Preco preco = new Preco(TipoDePreco.DESCONHECIDO);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package casa.sotu.organizajogos.api.modelo;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
|
|
||||||
import casa.sotu.organizajogos.api.excecao.PrecoInvalidoExcecao;
|
|
||||||
import casa.sotu.organizajogos.api.json.DesserializadorDePreco;
|
|
||||||
import casa.sotu.organizajogos.api.json.SerializadorDePreco;
|
|
||||||
import jakarta.persistence.Embeddable;
|
|
||||||
import jakarta.persistence.EnumType;
|
|
||||||
import jakarta.persistence.Enumerated;
|
|
||||||
import jakarta.validation.constraints.Min;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
@Embeddable
|
|
||||||
@JsonSerialize(using = SerializadorDePreco.class)
|
|
||||||
@JsonDeserialize(using = DesserializadorDePreco.class)
|
|
||||||
public record Preco(
|
|
||||||
@Min(0) BigDecimal valor,
|
|
||||||
@NotNull @Enumerated(EnumType.STRING) TipoDePreco tipo) {
|
|
||||||
|
|
||||||
public Preco {
|
|
||||||
if (tipo == TipoDePreco.VALOR) {
|
|
||||||
if (valor == null) {
|
|
||||||
throw new PrecoInvalidoExcecao(valor, tipo);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
valor = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Preco(BigDecimal valor) {
|
|
||||||
this(valor, TipoDePreco.VALOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Preco(TipoDePreco tipo) {
|
|
||||||
this(null, tipo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum TipoDePreco {
|
|
||||||
VALOR,
|
|
||||||
DE_GRACA,
|
|
||||||
DESCONHECIDO,
|
|
||||||
PRESENTE;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,31 @@
|
||||||
package casa.sotu.organizajogos.api.persistencia;
|
package casa.sotu.organizajogos.api.persistencia;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import casa.sotu.organizajogos.api.modelo.Jogo;
|
import casa.sotu.organizajogos.api.modelo.Jogo;
|
||||||
import jakarta.data.repository.CrudRepository;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.data.repository.Repository;
|
|
||||||
|
|
||||||
@Repository
|
@ApplicationScoped
|
||||||
public interface ArmarioJogo extends CrudRepository<Jogo, UUID> {
|
public class ArmarioJogo {
|
||||||
|
private Map<UUID, Jogo> jogos = new HashMap<>();
|
||||||
|
|
||||||
|
public void criar(Jogo jogo) {
|
||||||
|
jogo.setId(UUID.randomUUID());
|
||||||
|
jogos.put(jogo.getId(), jogo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Jogo pegar(UUID id) {
|
||||||
|
return jogos.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remover(UUID id) {
|
||||||
|
jogos.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Jogo> listar() {
|
||||||
|
return List.copyOf(jogos.values());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,10 @@ package casa.sotu.organizajogos.api.recursos;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.jboss.resteasy.reactive.ResponseStatus;
|
|
||||||
import org.jboss.resteasy.reactive.RestResponse.StatusCode;
|
|
||||||
|
|
||||||
import casa.sotu.organizajogos.api.modelo.Jogo;
|
import casa.sotu.organizajogos.api.modelo.Jogo;
|
||||||
import casa.sotu.organizajogos.api.persistencia.ArmarioJogo;
|
import casa.sotu.organizajogos.api.persistencia.ArmarioJogo;
|
||||||
import jakarta.data.exceptions.OptimisticLockingFailureException;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import jakarta.ws.rs.DELETE;
|
import jakarta.ws.rs.DELETE;
|
||||||
import jakarta.ws.rs.GET;
|
import jakarta.ws.rs.GET;
|
||||||
import jakarta.ws.rs.NotFoundException;
|
|
||||||
import jakarta.ws.rs.POST;
|
import jakarta.ws.rs.POST;
|
||||||
import jakarta.ws.rs.PUT;
|
import jakarta.ws.rs.PUT;
|
||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
|
@ -20,49 +14,41 @@ import jakarta.ws.rs.PathParam;
|
||||||
|
|
||||||
@Path("jogos")
|
@Path("jogos")
|
||||||
public class RecursoJogo {
|
public class RecursoJogo {
|
||||||
|
|
||||||
private ArmarioJogo armarioJogo;
|
private ArmarioJogo armarioJogo;
|
||||||
|
|
||||||
public RecursoJogo(ArmarioJogo armarioJogo) {
|
public RecursoJogo(ArmarioJogo armarioJogo) {
|
||||||
this.armarioJogo = armarioJogo;
|
this.armarioJogo = armarioJogo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
public List<Jogo> listaJogos() {
|
public List<Jogo> listaJogos() {
|
||||||
return armarioJogo.findAll().toList();
|
return armarioJogo.listar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public Jogo pegaJogo(@PathParam("id") UUID id) {
|
public Jogo pegaJogo(@PathParam("id") UUID id) {
|
||||||
return this.armarioJogo.findById(id).orElseThrow(NotFoundException::new);
|
return this.armarioJogo.pegar(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ResponseStatus(StatusCode.CREATED)
|
public void criaJogo(Jogo jogo) {
|
||||||
public UUID criaJogo(@Valid Jogo jogo) {
|
this.armarioJogo.criar(jogo);
|
||||||
jogo.setId(UUID.randomUUID());
|
|
||||||
this.armarioJogo.insert(jogo);
|
|
||||||
return jogo.getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@ResponseStatus(StatusCode.OK)
|
public void atualizaJogo(@PathParam("id") UUID id, Jogo jogo) {
|
||||||
public void atualizaJogo(@PathParam("id") UUID id, @Valid Jogo jogo) {
|
Jogo atual = this.armarioJogo.pegar(id);
|
||||||
jogo.setId(id);
|
atual.setNome(jogo.getNome());
|
||||||
try {
|
atual.setEstado(jogo.getEstado());
|
||||||
armarioJogo.update(jogo);
|
|
||||||
} catch (OptimisticLockingFailureException e) {
|
|
||||||
throw new NotFoundException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@ResponseStatus(StatusCode.OK)
|
|
||||||
public void remove(@PathParam("id") UUID id) {
|
public void remove(@PathParam("id") UUID id) {
|
||||||
this.armarioJogo.deleteById(id);
|
this.armarioJogo.remover(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,2 @@
|
||||||
# Quarkus Configuration file
|
# Quarkus Configuration file
|
||||||
# key = value
|
# key = value
|
||||||
quarkus.datasource.db-kind=pg
|
|
||||||
quarkus.datasource.username=postgres
|
|
||||||
quarkus.datasource.password=${POSTGRES_PASSWORD}
|
|
||||||
quarkus.datasource.jdbc.url=jdbc:postgresql://${POSTGRES_URL}/
|
|
||||||
quarkus.hibernate-orm.schema-management.strategy=update
|
|
||||||
%dev.quarkus.hibernate-orm.schema-management.strategy=drop-and-create
|
|
||||||
%dev.quarkus.hibernate-orm.dev-ui.allow-hql=true
|
|
||||||
%dev.quarkus.datasource.dev-ui.allowed-db-host=*
|
|
||||||
%dev.quarkus.hibernate-orm.sql-load-script=populacao.sql
|
|
|
@ -1,108 +0,0 @@
|
||||||
INSERT INTO public.jogo (
|
|
||||||
id,
|
|
||||||
ano,
|
|
||||||
valor,
|
|
||||||
estado,
|
|
||||||
loja,
|
|
||||||
nome,
|
|
||||||
tipo_de_preco
|
|
||||||
)
|
|
||||||
VALUES (
|
|
||||||
'7942e64a-878c-44fb-b6b7-646edddf5d02'::uuid,
|
|
||||||
2000,
|
|
||||||
NULL,
|
|
||||||
'JOGUEI',
|
|
||||||
'STEAM',
|
|
||||||
'Cavaleiros de Marta',
|
|
||||||
'DE_GRACA'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'fdb23f2a-faeb-482d-a05c-9d2ee9c28295'::uuid,
|
|
||||||
2001,
|
|
||||||
85.95,
|
|
||||||
'NOVO',
|
|
||||||
'STEAM',
|
|
||||||
'Cavaleiros de Marta 2',
|
|
||||||
'VALOR'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'aef5aa80-0557-4f31-a627-e53f9c741d59'::uuid,
|
|
||||||
1995,
|
|
||||||
10.00,
|
|
||||||
'SATISFEITO',
|
|
||||||
'GOG',
|
|
||||||
'Em Busca do Rodo Perdido',
|
|
||||||
'VALOR'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'10fde0ae-530f-46b1-a9a4-74efaf50d137'::uuid,
|
|
||||||
2000,
|
|
||||||
NULL,
|
|
||||||
'SATISFEITO',
|
|
||||||
'XBOX',
|
|
||||||
'Sábado de Sol',
|
|
||||||
'DESCONHECIDO'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'69282ca9-f722-4758-af46-d6be4f70a651'::uuid,
|
|
||||||
2007,
|
|
||||||
NULL,
|
|
||||||
'ETERNO',
|
|
||||||
'GOG',
|
|
||||||
'Pergaminho 4',
|
|
||||||
'DESCONHECIDO'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'aaef0acc-c6bc-4209-b12e-c1dbc6b8ac39'::uuid,
|
|
||||||
2012,
|
|
||||||
NULL,
|
|
||||||
'ETERNO',
|
|
||||||
'PS3',
|
|
||||||
'Pergaminho 5',
|
|
||||||
'PRESENTE'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'2c9028a3-65e6-43e7-a3ac-a198c9970206'::uuid,
|
|
||||||
2020,
|
|
||||||
30.00,
|
|
||||||
'SATISFEITO',
|
|
||||||
'GOG',
|
|
||||||
'GSP 3',
|
|
||||||
'VALOR'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'c4c8b05c-5b9c-43fa-97ae-f46fdd182cd8'::uuid,
|
|
||||||
2020,
|
|
||||||
23.48,
|
|
||||||
'JOGUEI',
|
|
||||||
'XBOX',
|
|
||||||
'Laehop',
|
|
||||||
'VALOR'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'61819dbc-0eca-431d-b4e4-c651be8fe056'::uuid,
|
|
||||||
2002,
|
|
||||||
500.00,
|
|
||||||
'JOGUEI',
|
|
||||||
'WII',
|
|
||||||
'Caríssimo, O Jogo',
|
|
||||||
'VALOR'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'2976135b-6270-45ea-9beb-7431df88eac4'::uuid,
|
|
||||||
2010,
|
|
||||||
NULL,
|
|
||||||
'NOVO',
|
|
||||||
'STEAM',
|
|
||||||
'Valeu, Mamãe',
|
|
||||||
'PRESENTE'
|
|
||||||
),
|
|
||||||
(
|
|
||||||
'82f59d12-f89c-4015-abcc-d0998376a6e8'::uuid,
|
|
||||||
2023,
|
|
||||||
NULL,
|
|
||||||
'SATISFEITO',
|
|
||||||
'EPIC',
|
|
||||||
'Injeção Na Testa',
|
|
||||||
'DE_GRACA'
|
|
||||||
);
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.acme.getting.started;
|
||||||
|
|
||||||
|
import io.quarkus.test.junit.QuarkusIntegrationTest;
|
||||||
|
|
||||||
|
@QuarkusIntegrationTest
|
||||||
|
public class GreetingResourceIT extends GreetingResourceTest {
|
||||||
|
|
||||||
|
// Execute the same tests but in native mode.
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.acme.getting.started;
|
||||||
|
|
||||||
|
import static io.restassured.RestAssured.given;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
|
||||||
|
@QuarkusTest
|
||||||
|
public class GreetingResourceTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHelloEndpoint() {
|
||||||
|
given()
|
||||||
|
.when().get("/hello")
|
||||||
|
.then()
|
||||||
|
.statusCode(200)
|
||||||
|
.body(is("hello"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGreetingEndpoint() {
|
||||||
|
String uuid = UUID.randomUUID().toString();
|
||||||
|
given()
|
||||||
|
.pathParam("name", uuid)
|
||||||
|
.when().get("/hello/greeting/{name}")
|
||||||
|
.then()
|
||||||
|
.statusCode(200)
|
||||||
|
.body(is("hello " + uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue