Skip to content

Commit

Permalink
Move custom traits to shared file, changed traits namespace, misc pr …
Browse files Browse the repository at this point in the history
…feedback
  • Loading branch information
0marperez committed Sep 17, 2024
1 parent 4e58bbd commit 39f66de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ import software.amazon.smithy.model.node.ObjectNode
import software.amazon.smithy.model.shapes.ShapeId
import software.amazon.smithy.model.traits.AnnotationTrait

/**
* Indicates the annotated service should always return a failed response.
*/
class FailedResponseTrait(node: ObjectNode) : AnnotationTrait(ID, node) {
companion object {
val ID: ShapeId = ShapeId.from("smithy.kotlin.traits#failedResponseTrait")
}
}

/**
* Indicates the annotated service should always return a success response.
*/
class SuccessResponseTrait(node: ObjectNode) : AnnotationTrait(ID, node) {
companion object {
val ID: ShapeId = ShapeId.from("com.test#successResponseTrait")
val ID: ShapeId = ShapeId.from("smithy.kotlin.traits#successResponseTrait")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class SmokeTestsRunnerGenerator(
private val operations = ctx.model.operations(ctx.settings.service).filter { it.hasTrait<SmokeTestsTrait>() }

// Test config
private val hasSuccessResponseTrait = ctx.model.expectShape<ServiceShape>(ctx.settings.service).hasTrait(SuccessResponseTrait.ID)
private val hasFailedResponseTrait = ctx.model.expectShape<ServiceShape>(ctx.settings.service).hasTrait(FailedResponseTrait.ID)
private val hasSuccessResponseTrait = model.expectShape<ServiceShape>(ctx.settings.service).hasTrait(SuccessResponseTrait.ID)
private val hasFailedResponseTrait = model.expectShape<ServiceShape>(ctx.settings.service).hasTrait(FailedResponseTrait.ID)
init {
check(!(hasSuccessResponseTrait && hasFailedResponseTrait)) {
"A service can't have both the success response trait and the failed response trait."
Expand Down

0 comments on commit 39f66de

Please sign in to comment.