Skip to content

Commit

Permalink
Fix delete message mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasdinov committed May 21, 2021
1 parent 1e15036 commit 0ca6a19
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 19 deletions.
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand Down Expand Up @@ -138,7 +137,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v0.0.0-20170809224252-890a5c3458b4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand All @@ -153,7 +151,6 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20170825220121-81e90905daef/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand All @@ -167,7 +164,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -193,7 +189,6 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion pkg/message/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (h *Handler) handleMessage(msg consumer.Message) {
}

conceptType := h.Mapper.Config.ESContentTypeMetadataMap.Get(contentType).Collection
if combinedPostPublicationEvent.MarkedDeleted == "true" {
if combinedPostPublicationEvent.Deleted {
_, err = h.esService.DeleteData(conceptType, uuid)
if err != nil {
log.WithError(err).Error("Failed to delete indexed content")
Expand Down
4 changes: 2 additions & 2 deletions pkg/message/message_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestHandleWriteMessageError(t *testing.T) {

func TestHandleDeleteMessage(t *testing.T) {
inputJSON := tst.ReadTestResource("exampleEnrichedContentModel.json")
input := strings.Replace(string(inputJSON), `"markedDeleted": "false"`, `"markedDeleted": "true"`, 1)
input := strings.Replace(string(inputJSON), `"deleted": false`, `"deleted": true`, 1)

serviceMock := &esServiceMock{}
serviceMock.On("DeleteData", "FTCom", "aae9611e-f66c-4fe4-a6c6-2e2bdea69060").Return(&elastic.DeleteResult{}, nil)
Expand All @@ -410,7 +410,7 @@ func TestHandleDeleteMessage(t *testing.T) {

func TestHandleDeleteMessageError(t *testing.T) {
inputJSON := tst.ReadTestResource("exampleEnrichedContentModel.json")
input := strings.Replace(string(inputJSON), `"markedDeleted": "false"`, `"markedDeleted": "true"`, 1)
input := strings.Replace(string(inputJSON), `"deleted": false`, `"deleted": true`, 1)

serviceMock := &esServiceMock{}

Expand Down
6 changes: 3 additions & 3 deletions pkg/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ type EnrichedContent struct {
Content Content `json:"content"`
Metadata Annotations `json:"metadata"`

ContentURI string `json:"contentUri"`
LastModified string `json:"lastModified"`
MarkedDeleted string `json:"markedDeleted"`
ContentURI string `json:"contentUri"`
LastModified string `json:"lastModified"`
Deleted bool `json:"deleted"`
}

type Content struct {
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/exampleAudioModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
"metadata": [],
"contentUri": "http://methode-article-mapper.svc.ft.com/content/aae9611e-f66c-4fe4-a6c6-2e2bdea69060",
"lastModified": "2020-07-06T12:58:00.347Z",
"markedDeleted": "false"
"deleted": false
}
4 changes: 2 additions & 2 deletions test/testdata/exampleEnrichedContentModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,5 @@
],
"contentUri": "http://methode-article-mapper.svc.ft.com/content/aae9611e-f66c-4fe4-a6c6-2e2bdea69060",
"lastModified": "2018-04-04T12:58:00.347Z",
"markedDeleted": "false"
}
"deleted": false
}
2 changes: 1 addition & 1 deletion test/testdata/exampleEnrichedContentModelWithBodyXML.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,5 @@
],
"contentUri": "http://methode-article-mapper.svc.ft.com/content/aae9611e-f66c-4fe4-a6c6-2e2bdea69060",
"lastModified": "2018-04-04T12:58:00.347Z",
"markedDeleted": "false"
"deleted": false
}
4 changes: 2 additions & 2 deletions test/testdata/testEnrichedContentModel1.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,5 @@
],
"contentUri": "http://methode-article-mapper.svc.ft.com/content/35ebcdf5-54b2-4834-8309-ba5ae3d5dd15",
"lastModified": "2018-04-11T12:27:51.148Z",
"markedDeleted": "false"
}
"deleted": false
}
4 changes: 2 additions & 2 deletions test/testdata/testEnrichedContentModel4.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@
],
"contentUri": "",
"lastModified": "2018-04-25T11:09:11.199Z",
"markedDeleted": ""
}
"deleted": false
}

0 comments on commit 0ca6a19

Please sign in to comment.