package fr.cat.tcc.sj.adapter.api.v1.operation; import…
- User
package fr.cat.tcc.sj.adapter.api.v1.operation;
import fr.cat.tcc.sj.adapter.operation_postgres.entity.OperationEntity; import fr.cat.tcc.sj.adapter.operation_postgres.repository.OperationRepository; import fr.cat.tcc.sj.config.SJBackAppIntegration; import fr.cat.tcc.sj.util.SchemaUtils; import org.jeasy.random.EasyRandom; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.MessageSource; import org.springframework.http.MediaType; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import javax.sql.DataSource;
import java.util.UUID;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ExtendWith(SpringExtension.class) @SpringBootTest(classes = {SJBackAppIntegration.class, MessageSource.class}) @AutoConfigureMockMvc @ActiveProfiles("integration-test") @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD) @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) class OperationControllerIntTest {
codeprivate static final EasyRandom EASY_RANDOM = new EasyRandom(); @Autowired private OperationRepository operationRepository; @Autowired private MockMvc mockMvc; @Autowired private DataSource dataSource; @AfterEach public void cleanUp() throws Exception { SchemaUtils.cleanupSchema(dataSource); } @Test @WithMockUser(username = "user", roles = {"USER"}) void when_fetching_operations_then_operations_returned() throws Exception { // Given : already theres 24 saved operation var operationEntity = EASY_RANDOM.nextObject(OperationEntity.class); operationRepository.save(operationEntity); // When var results = mockMvc.perform(MockMvcRequestBuilders .get("/api/v1/operations") .accept(MediaType.APPLICATION_JSON)); // Then results .andExpect(status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$.operations").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$.operations.length()").value(0)); } - Assistant
- User
@Table(name = "tb_operation") @Inheritance(strategy = InheritanceType.JOINED) public class OperationEntity {
code@Id @Column(name = "id", length = 35) private String id; @Column(name = "application_reference ", length = 35, nullable = false) private String applicationReference; @Column(name = "application_code", length = 35) private String applicationCode; @Column(name = "operation_type") @Enumerated(EnumType.STRING) private OperationType operationType; @Column(name = "operation_code", length = 4) private String operationCode;Je parle ici pour operationCode ou id par exemple
on voit la length=4 et 35
- Assistant
- User
... 33 more Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(8) at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2725) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2412) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:371) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:502) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:419) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:194) at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:155) at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:194) ... 54 more
- Assistant
L'erreur que vous rencontrez
ERROR: value too long for type character varying(8)indique clairement que vous essayez d'insérer une valeur dans une colonne de typecharacter varying(8)qui dépasse la longueur maximale autorisée (8 caractères).Dans votre entité
OperationEntity, vous avez défini la longueur de la colonne à 35 caractères. Cependant, l'erreur indique que la longueur maximale attendue est de 8 caractères, ce qui est probablement une erreur dans la définition de la colonne dans la base de données ou une mauvaise configuration.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.