########################## add

### add valid comment
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "user_id": 42,
  "sku": 1004005,
  "comment": "hello world"
}

### Expect:
### {
###  "id": "1001"
### }


### add invalid comment, miss user_id
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "sku": 1004005,
  "comment": "hello world"
}

### Expect:
### {
###  "code": 3,
###  "message": "invalid CommentAddRequest.UserId: value must be greater than 0",
###  "details": []
### }


### add invalid comment, negative user_id
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "user_id": -42,
  "sku": 1004005,
  "comment": "hello world"
}

### Expect:
### {
###  "code": 3,
###  "message": "invalid CommentAddRequest.UserId: value must be greater than 0",
###  "details": []
### }


### add invalid comment, miss sku
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "user_id": 42,
  "comment": "hello world"
}

### Expect:
### {
###  "code": 3,
###  "message": "invalid CommentAddRequest.Sku: value must be greater than 0",
###  "details": []
### }


### add invalid comment, negative sku
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "user_id": 42,
  "sku": -10,
  "comment": "hello world"
}

### Expect:
### {
###  "code": 3,
###  "message": "invalid CommentAddRequest.Sku: value must be greater than 0",
###  "details": []
### }


### add invalid comment, miss comment
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "user_id": 42,
  "sku": 1004005
}

### Expect:
### {
###  "code": 3,
###  "message": "invalid CommentAddRequest.Comment: value length must be between 1 and 255 runes, inclusive",
###  "details": []
### }


### add invalid comment, empty comment
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "user_id": 42,
  "sku": 1004005,
  "comment": ""
}


### Expect:
### {
###  "code": 3,
###  "message": "invalid CommentAddRequest.Comment: value length must be between 1 and 255 runes, inclusive",
###  "details": []
### }


### add invalid comment, too large comment
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "user_id": 42,
  "sku": 1004005,
  "comment": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"
}

### Expect:
### {
###  "code": 3,
###  "message": "invalid CommentAddRequest.Comment: value length must be between 1 and 255 runes, inclusive",
###  "details": []
### }





########################## get by id

### set precondition BEGIN ###
### save comment_id from response

### add valid comment
POST http://localhost:8086/comment/add
Content-Type: application/json

{
  "user_id": 123,
  "sku": 456005,
  "comment": "hello world 123"
}

### Expect:
### {
###   "id": "8000"
### }

### set precondition END ###

### get valid, previously created, comment
POST http://localhost:8086/comment/get-by-id
Content-Type: application/json

{
  "id": 8000
}

### Expect:
### {
###   "id": "8000",
###   "user_id": "123",
###   "sku": "456005",
###   "comment": "hello world 123",
###   "created_at": "2025-01-13T17:15:17.252417Z"
### }


### get comment by invalid id (negative)
POST http://localhost:8086/comment/get-by-id
Content-Type: application/json

{
  "id": -8000
}

### Expect:
### {
###   "code": 3,
###   "message": "invalid CommentGetByIDRequest.Id: value must be greater than 0",
###   "details": []
### }


### get comment by id, which not exists
POST http://localhost:8086/comment/get-by-id
Content-Type: application/json

{
  "id": 404000
}

### Expect:
### {
###   "code": 5,
###   "message": "comment with id=404000 not found",
###   "details": []
### }





########################## edit

### edit valid comment
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 42,
  "comment_id": 1001,
  "new_comment": "hello world changed"
}

### Expect
### {}


### edit invalid comment, user is not an author
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 555555,
  "comment_id": 1001,
  "new_comment": "hello world changed"
}

### Expect
### {
###  "code": 7,
###  "message": "unable to edit comment: given user is not an author of modified comment",
###  "details": []
### }


### edit invalid comment, comment is not exists
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 42,
  "comment_id": 555551001,
  "new_comment": "hello world changed"
}

### Expect
### {
###  "code": 5,
###  "message": "editing comment is not found",
###  "details": []
### }


### edit invalid comment, miss user_id
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "comment_id": 1001,
  "new_comment": "hello world changed"
}

### Expect
### {
###  "code": 3,
###  "message": "invalid CommentEditRequest.UserId: value must be greater than 0",
###  "details": []
### }


### edit invalid comment, negative user_id
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": -42,
  "comment_id": 1001,
  "new_comment": "hello world changed"
}

### Expect
### {
###  "code": 3,
###  "message": "invalid CommentEditRequest.UserId: value must be greater than 0",
###  "details": []
### }


### edit invalid comment, miss comment_id
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 42,
  "new_comment": "hello world changed"
}

### Expect
### {
###  "code": 3,
###  "message": "invalid CommentEditRequest.CommentId: value must be greater than 0",
###  "details": []
### }


### edit invalid comment, negative comment_id
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 42,
  "comment_id": -1001,
  "new_comment": "hello world changed"
}

### Expect
### {
###  "code": 3,
###  "message": "invalid CommentEditRequest.CommentId: value must be greater than 0",
###  "details": []
### }


### edit invalid comment, miss new_comment
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 42,
  "comment_id": 1001
}

### Expect
### {
###  "code": 3,
###  "message": "invalid CommentEditRequest.NewComment: value length must be between 1 and 255 runes, inclusive",
###  "details": []
### }


### edit invalid comment, empty new_comment
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 42,
  "comment_id": 1001,
  "new_comment": ""
}

### Expect
### {
###  "code": 3,
###  "message": "invalid CommentEditRequest.NewComment: value length must be between 1 and 255 runes, inclusive",
###  "details": []
### }


### edit invalid comment, too long new_comment
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 42,
  "comment_id": 1001,
  "new_comment": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"
}

### Expect
### {
###  "code": 3,
###  "message": "invalid CommentEditRequest.NewComment: value length must be between 1 and 255 runes, inclusive",
###  "details": []
### }


### edit valid comment, but editable time expired (CHANGE EditInterval!!!)
POST http://localhost:8086/comment/edit
Content-Type: application/json

{
  "user_id": 42,
  "comment_id": 1001,
  "new_comment": "hello world changed 3"
}

### Expect
### {
###  "code": 9,
###  "message": "unable to edit comment: editing time interval expired",
###  "details": []
### }





########################## list by sku

### set precondition BEGIN ###

### add valid comment 1
POST http://localhost:8086/comment/add
Content-Type: application/json

{"user_id": 71, "sku": 123, "comment": "hello world 1"}

### add valid comment 2
POST http://localhost:8086/comment/add
Content-Type: application/json

{"user_id": 71, "sku": 123, "comment": "hello world 2"}

### add valid comment 3
POST http://localhost:8086/comment/add
Content-Type: application/json

{"user_id": 71, "sku": 123, "comment": "hello world 3"}

### set precondition END ###

### list comments by sku
POST http://localhost:8086/comment/list-by-sku
Content-Type: application/json

{"sku": 123}

### Expected (order created_at DESC, IMPORTANT!!!):
### {
###   "comments": [
###     {
###       "id": "5001",
###       "user_id": "71",
###       "comment": "hello world 3",
###       "created_at": "2024-12-24T22:32:54.301507Z"
###     },
###     {
###       "id": "4001",
###       "user_id": "71",
###       "comment": "hello world 2",
###       "created_at": "2024-12-24T22:32:52.656693Z"
###     },
###     {
###       "id": "3001",
###       "user_id": "71",
###       "comment": "hello world 1",
###       "created_at": "2024-12-24T22:32:50.302224Z"
###     }
###   ]
### }


### list comments by sku, sku have no comments yet
POST http://localhost:8086/comment/list-by-sku
Content-Type: application/json

{"sku": 444444}

### Expected:
### {
###   "comments": []
### }


### list comments by sku, invalid, miss sku
POST http://localhost:8086/comment/list-by-sku
Content-Type: application/json

{}

### Expected:
### {
###   "code": 3,
###   "message": "invalid CommentListBySKURequest.Sku: value must be greater than 0",
###   "details": []
### }


### list comments by sku, invalid, negative sku
POST http://localhost:8086/comment/list-by-sku
Content-Type: application/json

{
  "sku": -1234
}

### Expected:
### {
###   "code": 3,
###   "message": "invalid CommentListBySKURequest.Sku: value must be greater than 0",
###   "details": []
### }





########################## list by user
### set precondition BEGIN ###

### add valid comment 1
POST http://localhost:8086/comment/add
Content-Type: application/json

{"user_id": 54, "sku": 789, "comment": "comment #1 54-789 (shard-2)"}

### add valid comment 1
POST http://localhost:8086/comment/add
Content-Type: application/json

{"user_id": 54, "sku": 456, "comment": "comment #1 54-456 (shard-1)"}

### add valid comment 2
POST http://localhost:8086/comment/add
Content-Type: application/json

{"user_id": 54, "sku": 220, "comment": "comment #2 54-220 (shard-1)"}

### add valid comment 3
POST http://localhost:8086/comment/add
Content-Type: application/json

{"user_id": 54, "sku": 567, "comment": "comment #2 54-567 (shard-2)"}

### set precondition END ###


### list comments by user
POST http://localhost:8086/comment/list-by-user
Content-Type: application/json

{"user_id": 54}

### Expected (order by created_at DESC, IMPORTANT!!!):
### {
###   "comments": [
###     {
###       "id": "13001",
###       "sku": "567",
###       "comment": "comment #2 54-567 (shard-2)",
###       "created_at": "2024-12-24T22:45:52.284861Z"
###     },
###     {
###       "id": "5000",
###       "sku": "220",
###       "comment": "comment #2 54-220 (shard-1)",
###       "created_at": "2024-12-24T22:45:49.050342Z"
###     },
###     {
###       "id": "4000",
###       "sku": "456",
###       "comment": "comment #1 54-456 (shard-1)",
###       "created_at": "2024-12-24T22:45:45.511675Z"
###     },
###     {
###       "id": "12001",
###       "sku": "789",
###       "comment": "comment #1 54-789 (shard-2)",
###       "created_at": "2024-12-24T22:45:39.449233Z"
###     }
###   ]
### }


### list comments by user, no comments for user
POST http://localhost:8086/comment/list-by-user
Content-Type: application/json

{"user_id": 32423423}

### Expected:
### {
###   "comments": []
### }
