Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import com.jorisjonkers.personalstack.agents.application.RepositoryVerificationS
import com.jorisjonkers.personalstack.agents.application.chat.ChatAnswerStreamService
import com.jorisjonkers.personalstack.agents.application.maintenance.RunnerMaintenanceService
import com.jorisjonkers.personalstack.agents.application.query.ChatSessionQueryService
import com.jorisjonkers.personalstack.agents.application.query.GetConversationQueryService
import com.jorisjonkers.personalstack.agents.application.query.GetMessageQueryService
import com.jorisjonkers.personalstack.agents.application.query.GetTurnHistoryQueryService
import com.jorisjonkers.personalstack.agents.application.query.GetWorkspaceQueryService
import com.jorisjonkers.personalstack.agents.application.query.ListWorkspacesQueryService
Expand Down Expand Up @@ -36,14 +34,12 @@ import com.jorisjonkers.personalstack.agents.infrastructure.web.AgentSessionCont
import com.jorisjonkers.personalstack.agents.infrastructure.web.AgentSetupController
import com.jorisjonkers.personalstack.agents.infrastructure.web.AgentSetupExceptionHandler
import com.jorisjonkers.personalstack.agents.infrastructure.web.ChatSessionController
import com.jorisjonkers.personalstack.agents.infrastructure.web.ConversationController
import com.jorisjonkers.personalstack.agents.infrastructure.web.CredentialController
import com.jorisjonkers.personalstack.agents.infrastructure.web.GitController
import com.jorisjonkers.personalstack.agents.infrastructure.web.HealthController
import com.jorisjonkers.personalstack.agents.infrastructure.web.InternalCredentialController
import com.jorisjonkers.personalstack.agents.infrastructure.web.InternalGitHubTokenController
import com.jorisjonkers.personalstack.agents.infrastructure.web.KubernetesExceptionHandler
import com.jorisjonkers.personalstack.agents.infrastructure.web.MessageController
import com.jorisjonkers.personalstack.agents.infrastructure.web.ProjectController
import com.jorisjonkers.personalstack.agents.infrastructure.web.RepositoryAccessDeniedExceptionHandler
import com.jorisjonkers.personalstack.agents.infrastructure.web.RepositoryController
Expand Down Expand Up @@ -81,13 +77,11 @@ import java.nio.file.Paths
AgentSetupController::class,
AgentSessionController::class,
ChatSessionController::class,
ConversationController::class,
CredentialController::class,
GitController::class,
HealthController::class,
InternalCredentialController::class,
InternalGitHubTokenController::class,
MessageController::class,
ProjectController::class,
RepositoryController::class,
SessionStatusController::class,
Expand Down Expand Up @@ -118,13 +112,11 @@ import java.nio.file.Paths
AgentSetupController::class,
AgentSessionController::class,
ChatSessionController::class,
ConversationController::class,
CredentialController::class,
GitController::class,
HealthController::class,
InternalCredentialController::class,
InternalGitHubTokenController::class,
MessageController::class,
ProjectController::class,
RepositoryController::class,
SessionStatusController::class,
Expand Down Expand Up @@ -256,12 +248,6 @@ class OpenApiSpecExportTest
@Bean
fun chatSessionQueryService(): ChatSessionQueryService = mockk(relaxed = true)

@Bean
fun getConversationQueryService(): GetConversationQueryService = mockk(relaxed = true)

@Bean
fun getMessageQueryService(): GetMessageQueryService = mockk(relaxed = true)

@Bean
fun getTurnHistoryQueryService(): GetTurnHistoryQueryService = mockk(relaxed = true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,57 +45,6 @@ class AgentsApiContractIntegrationTest
.andExpect(jsonPath("$.paths").exists())
}

@Test
fun conversationCreationResponseMatchesExpectedSchema() {
val userId = UUID.randomUUID().toString()

mockMvc
.perform(
post("/api/v1/conversations")
.header("X-User-Id", userId)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(mapOf("title" to "Contract Test Chat"))),
).andExpect(status().isCreated)
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.id").exists())
.andExpect(jsonPath("$.userId").exists())
.andExpect(jsonPath("$.title").value("Contract Test Chat"))
.andExpect(jsonPath("$.status").value("ACTIVE"))
.andExpect(jsonPath("$.createdAt").exists())
.andExpect(jsonPath("$.updatedAt").exists())
}

@Test
fun messageResponseMatchesExpectedSchema() {
val userId = UUID.randomUUID().toString()

val convResult =
mockMvc
.perform(
post("/api/v1/conversations")
.header("X-User-Id", userId)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(mapOf("title" to "Message Schema Test"))),
).andExpect(status().isCreated)
.andReturn()

val conversationId = objectMapper.readTree(convResult.response.contentAsString)["id"].asText()

mockMvc
.perform(
post("/api/v1/conversations/$conversationId/messages")
.header("X-User-Id", userId)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(mapOf("content" to "Schema check"))),
).andExpect(status().isCreated)
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.id").exists())
.andExpect(jsonPath("$.conversationId").exists())
.andExpect(jsonPath("$.role").value("USER"))
.andExpect(jsonPath("$.content").value("Schema check"))
.andExpect(jsonPath("$.createdAt").exists())
}

@Test
fun healthEndpointResponseMatchesSchema() {
mockMvc
Expand Down Expand Up @@ -329,26 +278,4 @@ class AgentsApiContractIntegrationTest
.andExpect(jsonPath("$.session.id").value(sessionId))
.andExpect(jsonPath("$.messages[0].body").value("hello world"))
}

@Test
fun conversationListResponseIsValidJSONArray() {
val userId = UUID.randomUUID().toString()

// Create a conversation so the list is non-empty
mockMvc.perform(
post("/api/v1/conversations")
.header("X-User-Id", userId)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(mapOf("title" to "List Test Chat"))),
)

mockMvc
.perform(get("/api/v1/conversations").header("X-User-Id", userId))
.andExpect(status().isOk)
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$").isArray)
.andExpect(jsonPath("$[0].id").exists())
.andExpect(jsonPath("$[0].title").exists())
.andExpect(jsonPath("$[0].status").exists())
}
}

This file was deleted.

Loading
Loading