Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
Fixed extracting uuids from incoming message
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanguranda committed Dec 4, 2017
1 parent 15b4225 commit 53b76bf
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

const (
whitelistedCollection = "content-package"
inputFile = "content-collection.json"
inputFile = "content-collection-full-msg.json"
collectionUuid = "45163790-eec9-11e6-abbc-ee7d9c5b3b90"
leadArticleUuid = "ddda0e1c-a9b2-11e7-8e2d-6debe43a48b4"
firstExistingItemUuid = "aaaac4c6-dcc6-11e6-86ac-f253db7791c6"
Expand Down
10 changes: 9 additions & 1 deletion resolver/uuidResolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *fromRequestResolver) Resolve(reqData []byte) (UuidsAndDate, error) {

func resolveUuids(cc contentCollection) ([]string, error) {
var uuidArr []string
for _, item := range cc.Items {
for _, item := range cc.Payload.Items {
err := uuidutils.ValidateUUID(item.Uuid)
if err != nil {
return nil, fmt.Errorf("UUID validation error: %v", err)
Expand All @@ -69,8 +69,16 @@ func resolveLastModified(cc contentCollection) (string, error) {
}

type contentCollection struct {
Payload payload `json:"payload"`
ContentUri string `json:"contentUri"`
LastModified string `json:"lastModified"`
Uuid string `json:"uuid"`
}

type payload struct {
LastModified string `json:"lastModified"`
Items []contentCollectionItem `json:"items"`
Uuid string `json:"uuid"`
}

type contentCollectionItem struct {
Expand Down
2 changes: 1 addition & 1 deletion resolver/uuidResolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestValidInput(t *testing.T) {
ccBytes := readTestFile(t, "content-collection.json")
ccBytes := readTestFile(t, "content-collection-full-msg.json")

r := NewUuidResolver()
uuidsAndDate, err := r.Resolve(ccBytes)
Expand Down
21 changes: 21 additions & 0 deletions test-resources/content-collection-full-msg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"payload":{
"uuid":"45163790-eec9-11e6-abbc-ee7d9c5b3b90",
"items":[
{
"uuid": "aaaac4c6-dcc6-11e6-86ac-f253db7791c6"
},
{
"uuid": "bbbbc4c6-dcc6-11e6-86ac-f253db7791c6"
},
{
"uuid": "d4986a58-de3b-11e6-86ac-f253db7791c6"
}
],
"publishReference":"tdi23377744",
"lastModified":"2017-01-31T15:33:21.687Z"
},
"contentUri":"http://methode-content-collection-mapper.svc.ft.com/content-collection/content-package/45163790-eec9-11e6-abbc-ee7d9c5b3b90",
"lastModified":"2017-01-31T15:33:21.687Z",
"uuid":"45163790-eec9-11e6-abbc-ee7d9c5b3b90"
}
16 changes: 0 additions & 16 deletions test-resources/content-collection.json

This file was deleted.

0 comments on commit 53b76bf

Please sign in to comment.