From f58920fad50bcd9d75d8ff9f0233d3be43447edf Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Wed, 27 Oct 2021 09:14:41 -0400 Subject: [PATCH] Add fetchdata to message/messages and dep ?data on msg Signed-off-by: Peter Broadhurst --- docs/swagger/swagger.yaml | 13 ++- internal/apiserver/route_get_msg_by_id.go | 10 ++- .../apiserver/route_get_msg_by_id_test.go | 6 +- internal/apiserver/route_get_msgs.go | 8 +- internal/apiserver/route_get_msgs_test.go | 22 ++++++ internal/i18n/en_translations.go | 1 + internal/oapispec/openapi3.go | 23 +++--- internal/oapispec/routes.go | 2 + internal/orchestrator/data_query.go | 53 ++++++++----- internal/orchestrator/data_query_test.go | 79 ++++++++++++++++--- internal/orchestrator/orchestrator.go | 4 +- mocks/orchestratormocks/orchestrator.go | 69 ++++++++++++++-- 12 files changed, 230 insertions(+), 60 deletions(-) diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index cf094abe31..efb46488d1 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -2004,6 +2004,11 @@ paths: schema: example: default type: string + - description: Fetch the data and include it in the messages returned + in: query + name: fetchdata + schema: + type: string - description: Server-side request timeout (millseconds, or set a custom suffix like 10s) in: header @@ -2214,11 +2219,17 @@ paths: required: true schema: type: string - - description: 'TODO: Description' + - deprecated: true + description: 'TODO: Description' in: query name: data schema: type: string + - description: Fetch the data and include it in the messages returned + in: query + name: fetchdata + schema: + type: string - description: Server-side request timeout (millseconds, or set a custom suffix like 10s) in: header diff --git a/internal/apiserver/route_get_msg_by_id.go b/internal/apiserver/route_get_msg_by_id.go index d4fb5d0c25..1be1ae61c4 100644 --- a/internal/apiserver/route_get_msg_by_id.go +++ b/internal/apiserver/route_get_msg_by_id.go @@ -35,7 +35,9 @@ var getMsgByID = &oapispec.Route{ {Name: "msgid", Description: i18n.MsgTBD}, }, QueryParams: []*oapispec.QueryParam{ - {Name: "data", IsBool: true, Description: i18n.MsgTBD}, + // Confusing using 'data' for this one, as we cannot use it on the collection one + {Name: "data", IsBool: true, Description: i18n.MsgTBD, Deprecated: true}, + {Name: "fetchdata", IsBool: true, Description: i18n.MsgFetchDataDesc}, }, FilterFactory: nil, Description: i18n.MsgTBD, @@ -43,7 +45,9 @@ var getMsgByID = &oapispec.Route{ JSONOutputValue: func() interface{} { return &fftypes.MessageInOut{} }, // can include full values JSONOutputCodes: []int{http.StatusOK}, JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) { - output, err = r.Or.GetMessageByID(r.Ctx, r.PP["ns"], r.PP["msgid"], strings.EqualFold(r.QP["data"], "true")) - return output, err + if strings.EqualFold(r.QP["data"], "true") || strings.EqualFold(r.QP["fetchdata"], "true") { + return r.Or.GetMessageByIDWithData(r.Ctx, r.PP["ns"], r.PP["msgid"]) + } + return r.Or.GetMessageByID(r.Ctx, r.PP["ns"], r.PP["msgid"]) }, } diff --git a/internal/apiserver/route_get_msg_by_id_test.go b/internal/apiserver/route_get_msg_by_id_test.go index 815298629e..916ff3b6bc 100644 --- a/internal/apiserver/route_get_msg_by_id_test.go +++ b/internal/apiserver/route_get_msg_by_id_test.go @@ -31,8 +31,8 @@ func TestGetMessageByID(t *testing.T) { req.Header.Set("Content-Type", "application/json; charset=utf-8") res := httptest.NewRecorder() - o.On("GetMessageByID", mock.Anything, "mynamespace", "abcd12345", false). - Return(&fftypes.MessageInOut{}, nil) + o.On("GetMessageByID", mock.Anything, "mynamespace", "abcd12345"). + Return(&fftypes.Message{}, nil) r.ServeHTTP(res, req) assert.Equal(t, 200, res.Result().StatusCode) @@ -44,7 +44,7 @@ func TestGetMessageByIDWithData(t *testing.T) { req.Header.Set("Content-Type", "application/json; charset=utf-8") res := httptest.NewRecorder() - o.On("GetMessageByID", mock.Anything, "mynamespace", "abcd12345", true). + o.On("GetMessageByIDWithData", mock.Anything, "mynamespace", "abcd12345"). Return(&fftypes.MessageInOut{}, nil) r.ServeHTTP(res, req) diff --git a/internal/apiserver/route_get_msgs.go b/internal/apiserver/route_get_msgs.go index f4c83c64ec..0e7245dc01 100644 --- a/internal/apiserver/route_get_msgs.go +++ b/internal/apiserver/route_get_msgs.go @@ -18,6 +18,7 @@ package apiserver import ( "net/http" + "strings" "github.com/hyperledger/firefly/internal/config" "github.com/hyperledger/firefly/internal/i18n" @@ -33,13 +34,18 @@ var getMsgs = &oapispec.Route{ PathParams: []*oapispec.PathParam{ {Name: "ns", ExampleFromConf: config.NamespacesDefault, Description: i18n.MsgTBD}, }, - QueryParams: nil, + QueryParams: []*oapispec.QueryParam{ + {Name: "fetchdata", IsBool: true, Description: i18n.MsgFetchDataDesc}, + }, FilterFactory: database.MessageQueryFactory, Description: i18n.MsgTBD, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*fftypes.Message{} }, JSONOutputCodes: []int{http.StatusOK}, JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) { + if strings.EqualFold(r.QP["fetchdata"], "true") { + return filterResult(r.Or.GetMessagesWithData(r.Ctx, r.PP["ns"], r.Filter)) + } return filterResult(r.Or.GetMessages(r.Ctx, r.PP["ns"], r.Filter)) }, } diff --git a/internal/apiserver/route_get_msgs_test.go b/internal/apiserver/route_get_msgs_test.go index a0010dd78c..1f151fa371 100644 --- a/internal/apiserver/route_get_msgs_test.go +++ b/internal/apiserver/route_get_msgs_test.go @@ -61,3 +61,25 @@ func TestGetMessagesWithCount(t *testing.T) { assert.Equal(t, int64(0), resWithCount.Count) assert.Equal(t, int64(10), resWithCount.Total) } + +func TestGetMessagesWithCountAndData(t *testing.T) { + o, r := newTestAPIServer() + req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/messages?count&fetchdata", nil) + req.Header.Set("Content-Type", "application/json; charset=utf-8") + res := httptest.NewRecorder() + + var ten int64 = 10 + o.On("GetMessagesWithData", mock.Anything, "mynamespace", mock.Anything). + Return([]*fftypes.MessageInOut{}, &database.FilterResult{ + TotalCount: &ten, + }, nil) + r.ServeHTTP(res, req) + + assert.Equal(t, 200, res.Result().StatusCode) + var resWithCount filterResultsWithCount + err := json.NewDecoder(res.Body).Decode(&resWithCount) + assert.NoError(t, err) + assert.NotNil(t, resWithCount.Items) + assert.Equal(t, int64(0), resWithCount.Count) + assert.Equal(t, int64(10), resWithCount.Total) +} diff --git a/internal/i18n/en_translations.go b/internal/i18n/en_translations.go index 681c226848..da8818bb20 100644 --- a/internal/i18n/en_translations.go +++ b/internal/i18n/en_translations.go @@ -206,4 +206,5 @@ var ( MsgFailedToDecodeCertificate = ffm("FF10286", "Failed to decode certificate: %s", 500) MsgInvalidMessageType = ffm("FF10287", "Invalid message type - allowed types are %s", 400) MsgNoUUID = ffm("FF10288", "Field '%s' must not be a UUID", 400) + MsgFetchDataDesc = ffm("FF10289", "Fetch the data and include it in the messages returned", 400) ) diff --git a/internal/oapispec/openapi3.go b/internal/oapispec/openapi3.go index b52df533ac..a215e2bc6d 100644 --- a/internal/oapispec/openapi3.go +++ b/internal/oapispec/openapi3.go @@ -150,7 +150,7 @@ func addOutput(ctx context.Context, route *Route, output interface{}, op *openap } } -func addParam(ctx context.Context, op *openapi3.Operation, in, name, def, example string, description i18n.MessageKey, msgArgs ...interface{}) { +func addParam(ctx context.Context, op *openapi3.Operation, in, name, def, example string, description i18n.MessageKey, deprecated bool, msgArgs ...interface{}) { required := false if in == "path" { required = true @@ -168,6 +168,7 @@ func addParam(ctx context.Context, op *openapi3.Operation, in, name, def, exampl In: in, Name: name, Required: required, + Deprecated: deprecated, Description: i18n.Expand(ctx, description, msgArgs...), Schema: &openapi3.SchemaRef{ Value: &openapi3.Schema{ @@ -213,28 +214,28 @@ func addRoute(ctx context.Context, doc *openapi3.T, route *Route) { if p.ExampleFromConf != "" { example = config.GetString(p.ExampleFromConf) } - addParam(ctx, op, "path", p.Name, p.Default, example, p.Description) + addParam(ctx, op, "path", p.Name, p.Default, example, p.Description, false) } for _, q := range route.QueryParams { example := q.Example if q.ExampleFromConf != "" { example = config.GetString(q.ExampleFromConf) } - addParam(ctx, op, "query", q.Name, q.Default, example, q.Description) + addParam(ctx, op, "query", q.Name, q.Default, example, q.Description, q.Deprecated) } - addParam(ctx, op, "header", "Request-Timeout", config.GetString(config.APIRequestTimeout), "", i18n.MsgRequestTimeoutDesc) + addParam(ctx, op, "header", "Request-Timeout", config.GetString(config.APIRequestTimeout), "", i18n.MsgRequestTimeoutDesc, false) if route.FilterFactory != nil { fields := route.FilterFactory.NewFilter(ctx).Fields() sort.Strings(fields) for _, field := range fields { - addParam(ctx, op, "query", field, "", "", i18n.MsgFilterParamDesc) + addParam(ctx, op, "query", field, "", "", i18n.MsgFilterParamDesc, false) } - addParam(ctx, op, "query", "sort", "", "", i18n.MsgFilterSortDesc) - addParam(ctx, op, "query", "ascending", "", "", i18n.MsgFilterAscendingDesc) - addParam(ctx, op, "query", "descending", "", "", i18n.MsgFilterDescendingDesc) - addParam(ctx, op, "query", "skip", "", "", i18n.MsgFilterSkipDesc, config.GetUint(config.APIMaxFilterSkip)) - addParam(ctx, op, "query", "limit", "", config.GetString(config.APIDefaultFilterLimit), i18n.MsgFilterLimitDesc, config.GetUint(config.APIMaxFilterLimit)) - addParam(ctx, op, "query", "count", "", "", i18n.MsgFilterCountDesc) + addParam(ctx, op, "query", "sort", "", "", i18n.MsgFilterSortDesc, false) + addParam(ctx, op, "query", "ascending", "", "", i18n.MsgFilterAscendingDesc, false) + addParam(ctx, op, "query", "descending", "", "", i18n.MsgFilterDescendingDesc, false) + addParam(ctx, op, "query", "skip", "", "", i18n.MsgFilterSkipDesc, false, config.GetUint(config.APIMaxFilterSkip)) + addParam(ctx, op, "query", "limit", "", config.GetString(config.APIDefaultFilterLimit), i18n.MsgFilterLimitDesc, false, config.GetUint(config.APIMaxFilterLimit)) + addParam(ctx, op, "query", "count", "", "", i18n.MsgFilterCountDesc, false) } switch route.Method { case http.MethodGet: diff --git a/internal/oapispec/routes.go b/internal/oapispec/routes.go index a2d8c5068a..e9c4da0ec5 100644 --- a/internal/oapispec/routes.go +++ b/internal/oapispec/routes.go @@ -91,6 +91,8 @@ type QueryParam struct { ExampleFromConf config.RootKey // Description is a message key to a translatable description of the parameter Description i18n.MessageKey + // Deprecated whether this param is deprecated + Deprecated bool } // FormParam is a description of a multi-part form parameter diff --git a/internal/orchestrator/data_query.go b/internal/orchestrator/data_query.go index a181c86180..febd8aec73 100644 --- a/internal/orchestrator/data_query.go +++ b/internal/orchestrator/data_query.go @@ -75,33 +75,31 @@ func (or *orchestrator) getMessageByID(ctx context.Context, ns, id string) (*fft return msg, err } -func (or *orchestrator) GetMessageByID(ctx context.Context, ns, id string, withValues bool) (*fftypes.MessageInOut, error) { - msg, err := or.getMessageByID(ctx, ns, id) - if err != nil { - return nil, err - } +func (or *orchestrator) GetMessageByID(ctx context.Context, ns, id string) (*fftypes.Message, error) { + return or.getMessageByID(ctx, ns, id) +} + +func (or *orchestrator) fetchMessageData(ctx context.Context, msg *fftypes.Message) (*fftypes.MessageInOut, error) { msgI := &fftypes.MessageInOut{ Message: *msg, } - if withValues { - // Lookup the full data - data, _, err := or.data.GetMessageData(ctx, msg, true) - if err != nil { - return nil, err - } - msgI.SetInlineData(data) - } else { - // Just put the data refs into the serialized struct - msgI.InlineData = make(fftypes.InlineData, len(msg.Data)) - for i, dr := range msg.Data { - msgI.InlineData[i] = &fftypes.DataRefOrValue{ - DataRef: *dr, - } - } + // Lookup the full data + data, _, err := or.data.GetMessageData(ctx, msg, true) + if err != nil { + return nil, err } + msgI.SetInlineData(data) return msgI, err } +func (or *orchestrator) GetMessageByIDWithData(ctx context.Context, ns, id string) (*fftypes.MessageInOut, error) { + msg, err := or.getMessageByID(ctx, ns, id) + if err != nil { + return nil, err + } + return or.fetchMessageData(ctx, msg) +} + func (or *orchestrator) GetBatchByID(ctx context.Context, ns, id string) (*fftypes.Batch, error) { u, err := or.verifyIDAndNamespace(ctx, ns, id) if err != nil { @@ -170,6 +168,21 @@ func (or *orchestrator) GetMessages(ctx context.Context, ns string, filter datab return or.database.GetMessages(ctx, filter) } +func (or *orchestrator) GetMessagesWithData(ctx context.Context, ns string, filter database.AndFilter) ([]*fftypes.MessageInOut, *database.FilterResult, error) { + filter = or.scopeNS(ns, filter) + msgs, fr, err := or.database.GetMessages(ctx, filter) + if err != nil { + return nil, nil, err + } + msgsData := make([]*fftypes.MessageInOut, len(msgs)) + for i, msg := range msgs { + if msgsData[i], err = or.fetchMessageData(ctx, msg); err != nil { + return nil, nil, err + } + } + return msgsData, fr, err +} + func (or *orchestrator) GetMessageData(ctx context.Context, ns, id string) ([]*fftypes.Data, error) { msg, err := or.getMessageByID(ctx, ns, id) if err != nil || msg == nil { diff --git a/internal/orchestrator/data_query_test.go b/internal/orchestrator/data_query_test.go index 015db1a971..bc6d6413c6 100644 --- a/internal/orchestrator/data_query_test.go +++ b/internal/orchestrator/data_query_test.go @@ -83,11 +83,11 @@ func TestGetTransactions(t *testing.T) { func TestGetMessageByIDBadID(t *testing.T) { or := newTestOrchestrator() - _, err := or.GetMessageByID(context.Background(), "", "", false) + _, err := or.GetMessageByID(context.Background(), "", "") assert.Regexp(t, "FF10142", err) } -func TestGetMessageByIDOkNoValues(t *testing.T) { +func TestGetMessageByIDNoValuesOk(t *testing.T) { or := newTestOrchestrator() msgID := fftypes.NewUUID() msg := &fftypes.Message{ @@ -101,17 +101,15 @@ func TestGetMessageByIDOkNoValues(t *testing.T) { } or.mdi.On("GetMessageByID", mock.Anything, mock.MatchedBy(func(u *fftypes.UUID) bool { return u.Equals(msgID) })).Return(msg, nil) - msgI, err := or.GetMessageByID(context.Background(), "ns1", msgID.String(), false) + msgI, err := or.GetMessageByID(context.Background(), "ns1", msgID.String()) assert.NoError(t, err) - assert.NotNil(t, msgI.InlineData[0].ID) - assert.NotNil(t, msgI.InlineData[0].Hash) - assert.Nil(t, msgI.InlineData[0].Value) - assert.NotNil(t, msgI.InlineData[1].ID) - assert.NotNil(t, msgI.InlineData[1].Hash) - assert.Nil(t, msgI.InlineData[1].Value) + assert.NotNil(t, msgI.Data[0].ID) + assert.NotNil(t, msgI.Data[0].Hash) + assert.NotNil(t, msgI.Data[1].ID) + assert.NotNil(t, msgI.Data[1].Hash) } -func TestGetMessageByIDOkWithValues(t *testing.T) { +func TestGetMessageByIDWithDataOk(t *testing.T) { or := newTestOrchestrator() msgID := fftypes.NewUUID() msg := &fftypes.Message{ @@ -129,7 +127,7 @@ func TestGetMessageByIDOkWithValues(t *testing.T) { {ID: fftypes.NewUUID(), Hash: fftypes.NewRandB32(), Value: fftypes.Byteable("{}")}, }, true, nil) - msgI, err := or.GetMessageByID(context.Background(), "ns1", msgID.String(), true) + msgI, err := or.GetMessageByIDWithData(context.Background(), "ns1", msgID.String()) assert.NoError(t, err) assert.NotNil(t, msgI.InlineData[0].ID) assert.NotNil(t, msgI.InlineData[0].Hash) @@ -139,7 +137,16 @@ func TestGetMessageByIDOkWithValues(t *testing.T) { assert.NotNil(t, msgI.InlineData[1].Value) } -func TestGetMessageByIDValuesFail(t *testing.T) { +func TestGetMessageByIDWithDataMsgFail(t *testing.T) { + or := newTestOrchestrator() + msgID := fftypes.NewUUID() + or.mdi.On("GetMessageByID", mock.Anything, mock.Anything).Return(nil, fmt.Errorf("pop")) + + _, err := or.GetMessageByIDWithData(context.Background(), "ns1", msgID.String()) + assert.EqualError(t, err, "pop") +} + +func TestGetMessageByIDWithDataFail(t *testing.T) { or := newTestOrchestrator() msgID := fftypes.NewUUID() msg := &fftypes.Message{ @@ -154,9 +161,10 @@ func TestGetMessageByIDValuesFail(t *testing.T) { or.mdi.On("GetMessageByID", mock.Anything, mock.Anything).Return(msg, nil) or.mdm.On("GetMessageData", mock.Anything, mock.Anything, true).Return(nil, false, fmt.Errorf("pop")) - _, err := or.GetMessageByID(context.Background(), "ns1", msgID.String(), true) + _, err := or.GetMessageByIDWithData(context.Background(), "ns1", msgID.String()) assert.EqualError(t, err, "pop") } + func TestGetMessages(t *testing.T) { or := newTestOrchestrator() u := fftypes.NewUUID() @@ -167,6 +175,51 @@ func TestGetMessages(t *testing.T) { assert.NoError(t, err) } +func TestGetMessagesWithDataFailMsg(t *testing.T) { + or := newTestOrchestrator() + or.mdi.On("GetMessages", mock.Anything, mock.Anything).Return(nil, nil, fmt.Errorf("pop")) + fb := database.MessageQueryFactory.NewFilter(context.Background()) + f := fb.And(fb.Eq("id", fftypes.NewUUID())) + _, _, err := or.GetMessagesWithData(context.Background(), "ns1", f) + assert.EqualError(t, err, "pop") +} + +func TestGetMessagesWithDataOk(t *testing.T) { + or := newTestOrchestrator() + u := fftypes.NewUUID() + msgID := fftypes.NewUUID() + msg := &fftypes.Message{ + Header: fftypes.MessageHeader{ + ID: msgID, + }, + Data: fftypes.DataRefs{}, + } + or.mdi.On("GetMessages", mock.Anything, mock.Anything).Return([]*fftypes.Message{msg}, nil, nil) + fb := database.MessageQueryFactory.NewFilter(context.Background()) + or.mdm.On("GetMessageData", mock.Anything, mock.Anything, true).Return([]*fftypes.Data{}, true, nil) + f := fb.And(fb.Eq("id", u)) + _, _, err := or.GetMessagesWithData(context.Background(), "ns1", f) + assert.NoError(t, err) +} + +func TestGetMessagesWithDataFail(t *testing.T) { + or := newTestOrchestrator() + u := fftypes.NewUUID() + msgID := fftypes.NewUUID() + msg := &fftypes.Message{ + Header: fftypes.MessageHeader{ + ID: msgID, + }, + Data: fftypes.DataRefs{}, + } + or.mdi.On("GetMessages", mock.Anything, mock.Anything).Return([]*fftypes.Message{msg}, nil, nil) + fb := database.MessageQueryFactory.NewFilter(context.Background()) + or.mdm.On("GetMessageData", mock.Anything, mock.Anything, true).Return(nil, true, fmt.Errorf("pop")) + f := fb.And(fb.Eq("id", u)) + _, _, err := or.GetMessagesWithData(context.Background(), "ns1", f) + assert.EqualError(t, err, "pop") +} + func TestGetMessagesForData(t *testing.T) { or := newTestOrchestrator() u := fftypes.NewUUID() diff --git a/internal/orchestrator/orchestrator.go b/internal/orchestrator/orchestrator.go index fd14c34022..d8a5e2fa00 100644 --- a/internal/orchestrator/orchestrator.go +++ b/internal/orchestrator/orchestrator.go @@ -87,8 +87,10 @@ type Orchestrator interface { GetTransactionByID(ctx context.Context, ns, id string) (*fftypes.Transaction, error) GetTransactionOperations(ctx context.Context, ns, id string) ([]*fftypes.Operation, *database.FilterResult, error) GetTransactions(ctx context.Context, ns string, filter database.AndFilter) ([]*fftypes.Transaction, *database.FilterResult, error) - GetMessageByID(ctx context.Context, ns, id string, withValues bool) (*fftypes.MessageInOut, error) + GetMessageByID(ctx context.Context, ns, id string) (*fftypes.Message, error) + GetMessageByIDWithData(ctx context.Context, ns, id string) (*fftypes.MessageInOut, error) GetMessages(ctx context.Context, ns string, filter database.AndFilter) ([]*fftypes.Message, *database.FilterResult, error) + GetMessagesWithData(ctx context.Context, ns string, filter database.AndFilter) ([]*fftypes.MessageInOut, *database.FilterResult, error) GetMessageTransaction(ctx context.Context, ns, id string) (*fftypes.Transaction, error) GetMessageOperations(ctx context.Context, ns, id string) ([]*fftypes.Operation, *database.FilterResult, error) GetMessageEvents(ctx context.Context, ns, id string, filter database.AndFilter) ([]*fftypes.Event, *database.FilterResult, error) diff --git a/mocks/orchestratormocks/orchestrator.go b/mocks/orchestratormocks/orchestrator.go index a0b94421fa..4286fcd3fc 100644 --- a/mocks/orchestratormocks/orchestrator.go +++ b/mocks/orchestratormocks/orchestrator.go @@ -480,13 +480,36 @@ func (_m *Orchestrator) GetEvents(ctx context.Context, ns string, filter databas return r0, r1, r2 } -// GetMessageByID provides a mock function with given fields: ctx, ns, id, withValues -func (_m *Orchestrator) GetMessageByID(ctx context.Context, ns string, id string, withValues bool) (*fftypes.MessageInOut, error) { - ret := _m.Called(ctx, ns, id, withValues) +// GetMessageByID provides a mock function with given fields: ctx, ns, id +func (_m *Orchestrator) GetMessageByID(ctx context.Context, ns string, id string) (*fftypes.Message, error) { + ret := _m.Called(ctx, ns, id) + + var r0 *fftypes.Message + if rf, ok := ret.Get(0).(func(context.Context, string, string) *fftypes.Message); ok { + r0 = rf(ctx, ns, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*fftypes.Message) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, ns, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetMessageByIDWithData provides a mock function with given fields: ctx, ns, id +func (_m *Orchestrator) GetMessageByIDWithData(ctx context.Context, ns string, id string) (*fftypes.MessageInOut, error) { + ret := _m.Called(ctx, ns, id) var r0 *fftypes.MessageInOut - if rf, ok := ret.Get(0).(func(context.Context, string, string, bool) *fftypes.MessageInOut); ok { - r0 = rf(ctx, ns, id, withValues) + if rf, ok := ret.Get(0).(func(context.Context, string, string) *fftypes.MessageInOut); ok { + r0 = rf(ctx, ns, id) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*fftypes.MessageInOut) @@ -494,8 +517,8 @@ func (_m *Orchestrator) GetMessageByID(ctx context.Context, ns string, id string } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, string, bool) error); ok { - r1 = rf(ctx, ns, id, withValues) + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, ns, id) } else { r1 = ret.Error(1) } @@ -677,6 +700,38 @@ func (_m *Orchestrator) GetMessagesForData(ctx context.Context, ns string, dataI return r0, r1, r2 } +// GetMessagesWithData provides a mock function with given fields: ctx, ns, filter +func (_m *Orchestrator) GetMessagesWithData(ctx context.Context, ns string, filter database.AndFilter) ([]*fftypes.MessageInOut, *database.FilterResult, error) { + ret := _m.Called(ctx, ns, filter) + + var r0 []*fftypes.MessageInOut + if rf, ok := ret.Get(0).(func(context.Context, string, database.AndFilter) []*fftypes.MessageInOut); ok { + r0 = rf(ctx, ns, filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*fftypes.MessageInOut) + } + } + + var r1 *database.FilterResult + if rf, ok := ret.Get(1).(func(context.Context, string, database.AndFilter) *database.FilterResult); ok { + r1 = rf(ctx, ns, filter) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*database.FilterResult) + } + } + + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, string, database.AndFilter) error); ok { + r2 = rf(ctx, ns, filter) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + // GetNamespace provides a mock function with given fields: ctx, ns func (_m *Orchestrator) GetNamespace(ctx context.Context, ns string) (*fftypes.Namespace, error) { ret := _m.Called(ctx, ns)