From 01b61cd34ed684eb0910f72b369799d9f8202dc3 Mon Sep 17 00:00:00 2001 From: Michal Krzyz Date: Tue, 6 Aug 2024 15:06:51 +0200 Subject: [PATCH] feat(filter): Implement wild card searching for issue #95 - Add search filter for wildcard-like searching - Add compose makefile targets Signed-off-by: Michal Krzyz --- Makefile | 28 +++- docker-compose.yaml | 1 + .../api/graphql/graph/baseResolver/issue.go | 2 + internal/api/graphql/graph/generated.go | 12 +- .../api/graphql/graph/model/models_gen.go | 4 +- .../api/graphql/graph/resolver/activity.go | 3 - .../api/graphql/graph/resolver/component.go | 3 - .../graph/resolver/component_instance.go | 3 - .../graph/resolver/component_version.go | 3 - .../api/graphql/graph/resolver/evidence.go | 3 - internal/api/graphql/graph/resolver/issue.go | 3 - .../api/graphql/graph/resolver/issue_match.go | 3 - .../graph/resolver/issue_match_change.go | 3 - .../graph/resolver/issue_repository.go | 3 - .../graphql/graph/resolver/issue_variant.go | 3 - .../api/graphql/graph/resolver/mutation.go | 3 - internal/api/graphql/graph/resolver/query.go | 3 - .../api/graphql/graph/resolver/service.go | 3 - .../graphql/graph/resolver/support_group.go | 3 - internal/api/graphql/graph/resolver/user.go | 3 - .../api/graphql/graph/schema/issue.graphqls | 4 +- internal/database/mariadb/database.go | 8 +- internal/database/mariadb/issue.go | 9 +- internal/database/mariadb/issue_test.go | 65 +++++++++ internal/entity/issue.go | 1 + internal/mocks/mock_Database.go | 5 +- internal/mocks/mock_Heureka.go | 123 +++++++++++++++++- 27 files changed, 238 insertions(+), 69 deletions(-) diff --git a/Makefile b/Makefile index 71e18184..7a27879c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ VERSION ?= $(shell git log -1 --pretty=format:"%H") OS := $(shell go env GOOS) ARCH := $(shell go env GOARCH) -.PHONY: all test doc gqlgen test-all test-e2e test-app test-db +.PHONY: all test doc gqlgen test-all test-e2e test-app test-db fmt compose-prepare compose-up compose-down compose-restart compose-build # Source the .env file to use the env vars with make -include .env @@ -55,16 +55,32 @@ mockery: mockery test-all: - ginkgo -r + go run github.com/onsi/ginkgo/v2/ginkgo -r test-e2e: - ginkgo internal/e2e + go run github.com/onsi/ginkgo/v2/ginkgo -r internal/e2e test-app: - ginkgo internal/app + go run github.com/onsi/ginkgo/v2/ginkgo -r internal/app test-db: - ginkgo internal/database/mariadb + go run github.com/onsi/ginkgo/v2/ginkgo -r internal/database/mariadb fmt: - go fmt ./... \ No newline at end of file + go fmt ./... + +DOCKER_COMPOSE := docker-compose -f docker-compose.yaml +DOCKER_COMPOSE_SERVICES := heureka-app heureka-db +compose-prepare: + sed 's/^SEED_MODE=false/SEED_MODE=true/g' .test.env > .env + +compose-up: + $(DOCKER_COMPOSE) up -d $(DOCKER_COMPOSE_SERVICES) + +compose-down: + $(DOCKER_COMPOSE) down $(DOCKER_COMPOSE_SERVICES) + +compose-restart: compose-down compose-up + +compose-build: + $(DOCKER_COMPOSE) build $(DOCKER_COMPOSE_SERVICES) diff --git a/docker-compose.yaml b/docker-compose.yaml index e72f2373..637c2c67 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -33,6 +33,7 @@ services: heureka-app: build: . + container_name: heureka-app profiles: - heureka environment: diff --git a/internal/api/graphql/graph/baseResolver/issue.go b/internal/api/graphql/graph/baseResolver/issue.go index d5e2c870..da1e4276 100644 --- a/internal/api/graphql/graph/baseResolver/issue.go +++ b/internal/api/graphql/graph/baseResolver/issue.go @@ -97,6 +97,8 @@ func IssueBaseResolver(app app.Heureka, ctx context.Context, filter *model.Issue PrimaryName: filter.PrimaryName, Type: lo.Map(filter.IssueType, func(item *model.IssueTypes, _ int) *string { return pointer.String(item.String()) }), + Search: filter.Search, + IssueMatchStatus: nil, //@todo Implement IssueMatchDiscoveryDate: nil, //@todo Implement IssueMatchTargetRemediationDate: nil, //@todo Implement diff --git a/internal/api/graphql/graph/generated.go b/internal/api/graphql/graph/generated.go index 0e0dfc25..325f8f5a 100644 --- a/internal/api/graphql/graph/generated.go +++ b/internal/api/graphql/graph/generated.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph @@ -23259,7 +23256,7 @@ func (ec *executionContext) unmarshalInputIssueFilter(ctx context.Context, obj i asMap[k] = v } - fieldsInOrder := [...]string{"affectedService", "primaryName", "issueMatchStatus", "issueType", "componentVersionId"} + fieldsInOrder := [...]string{"affectedService", "primaryName", "issueMatchStatus", "issueType", "componentVersionId", "search"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -23301,6 +23298,13 @@ func (ec *executionContext) unmarshalInputIssueFilter(ctx context.Context, obj i return it, err } it.ComponentVersionID = data + case "search": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("search")) + data, err := ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Search = data } } diff --git a/internal/api/graphql/graph/model/models_gen.go b/internal/api/graphql/graph/model/models_gen.go index 816b0852..f273bd82 100644 --- a/internal/api/graphql/graph/model/models_gen.go +++ b/internal/api/graphql/graph/model/models_gen.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model @@ -333,6 +330,7 @@ type IssueFilter struct { IssueMatchStatus []*IssueMatchStatusValues `json:"issueMatchStatus,omitempty"` IssueType []*IssueTypes `json:"issueType,omitempty"` ComponentVersionID []*string `json:"componentVersionId,omitempty"` + Search []*string `json:"search,omitempty"` } type IssueInput struct { diff --git a/internal/api/graphql/graph/resolver/activity.go b/internal/api/graphql/graph/resolver/activity.go index 4195da8e..945884bb 100644 --- a/internal/api/graphql/graph/resolver/activity.go +++ b/internal/api/graphql/graph/resolver/activity.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/component.go b/internal/api/graphql/graph/resolver/component.go index eff197b0..36e46037 100644 --- a/internal/api/graphql/graph/resolver/component.go +++ b/internal/api/graphql/graph/resolver/component.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/component_instance.go b/internal/api/graphql/graph/resolver/component_instance.go index d7e86254..574b7d38 100644 --- a/internal/api/graphql/graph/resolver/component_instance.go +++ b/internal/api/graphql/graph/resolver/component_instance.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/component_version.go b/internal/api/graphql/graph/resolver/component_version.go index 516c1e38..7af279d2 100644 --- a/internal/api/graphql/graph/resolver/component_version.go +++ b/internal/api/graphql/graph/resolver/component_version.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/evidence.go b/internal/api/graphql/graph/resolver/evidence.go index 83505ef1..6832c112 100644 --- a/internal/api/graphql/graph/resolver/evidence.go +++ b/internal/api/graphql/graph/resolver/evidence.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/issue.go b/internal/api/graphql/graph/resolver/issue.go index 26c3962e..09ddb09c 100644 --- a/internal/api/graphql/graph/resolver/issue.go +++ b/internal/api/graphql/graph/resolver/issue.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/issue_match.go b/internal/api/graphql/graph/resolver/issue_match.go index 27c62754..33b59b63 100644 --- a/internal/api/graphql/graph/resolver/issue_match.go +++ b/internal/api/graphql/graph/resolver/issue_match.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/issue_match_change.go b/internal/api/graphql/graph/resolver/issue_match_change.go index 89ba84f4..7fb5680c 100644 --- a/internal/api/graphql/graph/resolver/issue_match_change.go +++ b/internal/api/graphql/graph/resolver/issue_match_change.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/issue_repository.go b/internal/api/graphql/graph/resolver/issue_repository.go index 5c35c1fd..3bd2d87a 100644 --- a/internal/api/graphql/graph/resolver/issue_repository.go +++ b/internal/api/graphql/graph/resolver/issue_repository.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/issue_variant.go b/internal/api/graphql/graph/resolver/issue_variant.go index c48c8de5..a7632cc6 100644 --- a/internal/api/graphql/graph/resolver/issue_variant.go +++ b/internal/api/graphql/graph/resolver/issue_variant.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/mutation.go b/internal/api/graphql/graph/resolver/mutation.go index 68629a4f..75b42aee 100644 --- a/internal/api/graphql/graph/resolver/mutation.go +++ b/internal/api/graphql/graph/resolver/mutation.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/query.go b/internal/api/graphql/graph/resolver/query.go index dc657842..478ff256 100644 --- a/internal/api/graphql/graph/resolver/query.go +++ b/internal/api/graphql/graph/resolver/query.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/service.go b/internal/api/graphql/graph/resolver/service.go index 996426cc..4a017d22 100644 --- a/internal/api/graphql/graph/resolver/service.go +++ b/internal/api/graphql/graph/resolver/service.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/support_group.go b/internal/api/graphql/graph/resolver/support_group.go index 7acdd9fb..7cdc55d3 100644 --- a/internal/api/graphql/graph/resolver/support_group.go +++ b/internal/api/graphql/graph/resolver/support_group.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/resolver/user.go b/internal/api/graphql/graph/resolver/user.go index 1069c631..4c465a3b 100644 --- a/internal/api/graphql/graph/resolver/user.go +++ b/internal/api/graphql/graph/resolver/user.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - package resolver // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/internal/api/graphql/graph/schema/issue.graphqls b/internal/api/graphql/graph/schema/issue.graphqls index e5364fb5..14c7752e 100644 --- a/internal/api/graphql/graph/schema/issue.graphqls +++ b/internal/api/graphql/graph/schema/issue.graphqls @@ -58,6 +58,8 @@ input IssueFilter { componentVersionId: [String], + search: [String], + # leave away for MVP # cveDescription: [String] # fromAdvisory: ID, @@ -69,4 +71,4 @@ enum IssueTypes { Vulnerability, PolicyViolation, SecurityEvent -} \ No newline at end of file +} diff --git a/internal/database/mariadb/database.go b/internal/database/mariadb/database.go index 35383b92..6df0a77e 100644 --- a/internal/database/mariadb/database.go +++ b/internal/database/mariadb/database.go @@ -165,8 +165,14 @@ func buildFilterQuery[T any](filter []T, expr string, op string) string { } func buildQueryParameters[T any](params []interface{}, filter []T) []interface{} { + return buildQueryParametersCount(params, filter, 1) +} + +func buildQueryParametersCount[T any](params []interface{}, filter []T, count int) []interface{} { for _, item := range filter { - params = append(params, item) + for i := 0; i < count; i++ { + params = append(params, item) + } } return params } diff --git a/internal/database/mariadb/issue.go b/internal/database/mariadb/issue.go index f7e4b12c..cc3fffe2 100644 --- a/internal/database/mariadb/issue.go +++ b/internal/database/mariadb/issue.go @@ -12,6 +12,11 @@ import ( "github.wdf.sap.corp/cc/heureka/internal/entity" ) +const ( + wildCardFilterQuery = "IV.issuevariant_secondary_name LIKE Concat('%',?,'%') OR I.issue_primary_name LIKE Concat('%',?,'%')" + wildCardFilterParamCount = 2 +) + func (s *SqlDatabase) getIssueFilterString(filter *entity.IssueFilter) string { var fl []string fl = append(fl, buildFilterQuery(filter.ServiceName, "S.service_name = ?", OP_OR)) @@ -23,6 +28,7 @@ func (s *SqlDatabase) getIssueFilterString(filter *entity.IssueFilter) string { fl = append(fl, buildFilterQuery(filter.IssueVariantId, "IV.issuevariant_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Type, "I.issue_type = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.PrimaryName, "I.issue_primary_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.Search, wildCardFilterQuery, OP_OR)) fl = append(fl, "I.issue_deleted_at IS NULL") return combineFilterQueries(fl, OP_AND) @@ -55,7 +61,7 @@ func (s *SqlDatabase) getIssueJoins(filter *entity.IssueFilter, withAggregations `) } - if len(filter.IssueVariantId) > 0 { + if len(filter.IssueVariantId) > 0 || len(filter.Search) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN IssueVariant IV ON I.issue_id = IV.issuevariant_issue_id `) @@ -164,6 +170,7 @@ func (s *SqlDatabase) buildIssueStatement(baseQuery string, filter *entity.Issue filterParameters = buildQueryParameters(filterParameters, filter.IssueVariantId) filterParameters = buildQueryParameters(filterParameters, filter.Type) filterParameters = buildQueryParameters(filterParameters, filter.PrimaryName) + filterParameters = buildQueryParametersCount(filterParameters, filter.Search, wildCardFilterParamCount) if withCursor { filterParameters = append(filterParameters, cursor.Value) filterParameters = append(filterParameters, cursor.Limit) diff --git a/internal/database/mariadb/issue_test.go b/internal/database/mariadb/issue_test.go index debc39e8..ccf02fb8 100644 --- a/internal/database/mariadb/issue_test.go +++ b/internal/database/mariadb/issue_test.go @@ -326,6 +326,71 @@ var _ = Describe("Issue", Label("database", "Issue"), func() { Expect(entry.Type).To(BeEquivalentTo(issueType)) } }) + It("can filter issue PrimaryName using wild card search", func() { + row := seedCollection.IssueRows[rand.Intn(len(seedCollection.IssueRows))] + + const charactersToRemoveFromBeginning = 2 + const charactersToRemoveFromEnd = 2 + const minimalCharactersToKeep = 5 + + start := charactersToRemoveFromBeginning + end := len(row.PrimaryName.String) - charactersToRemoveFromEnd + + Expect(start+minimalCharactersToKeep < end).To(BeTrue()) + + searchStr := row.PrimaryName.String[start:end] + filter := &entity.IssueFilter{Search: []*string{&searchStr}} + + entries, err := db.GetIssues(filter) + + issueIds := []int64{} + for _, entry := range entries { + issueIds = append(issueIds, entry.Id) + } + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + By("at least single value was discarded (filtered)", func() { + Expect(len(seedCollection.IssueRows) > len(issueIds)).To(BeTrue()) + }) + + By("returning the expected elements", func() { + Expect(issueIds).To(ContainElement(row.Id.Int64)) + }) + }) + It("can filter issue variant SecondaryName using wild card search", func() { + // select an issueVariant + issueVariantRow := seedCollection.IssueVariantRows[rand.Intn(len(seedCollection.IssueVariantRows))] + + const charactersToRemoveFromBeginning = 2 + const charactersToRemoveFromEnd = 2 + const minimalCharactersToKeep = 5 + + start := charactersToRemoveFromBeginning + end := len(issueVariantRow.SecondaryName.String) - charactersToRemoveFromEnd + + Expect(start+minimalCharactersToKeep < end).To(BeTrue()) + + searchStr := issueVariantRow.SecondaryName.String[start:end] + filter := &entity.IssueFilter{Search: []*string{&searchStr}} + + entries, err := db.GetIssues(filter) + + issueIds := []int64{} + for _, entry := range entries { + issueIds = append(issueIds, entry.Id) + } + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + By("returning the expected elements", func() { + Expect(issueIds).To(ContainElement(issueVariantRow.IssueId.Int64)) + }) + }) }) Context("and using pagination", func() { DescribeTable("can correctly paginate", func(pageSize int) { diff --git a/internal/entity/issue.go b/internal/entity/issue.go index 5e5a9182..8ba717b4 100644 --- a/internal/entity/issue.go +++ b/internal/entity/issue.go @@ -57,6 +57,7 @@ type IssueFilter struct { IssueMatchId []*int64 `json:"issue_match_id"` ComponentVersionId []*int64 `json:"component_version_id"` IssueVariantId []*int64 `json:"issue_variant_id"` + Search []*string `json:"search"` IssueMatchStatus []*string `json:"issue_match_status"` IssueMatchDiscoveryDate *TimeFilter `json:"issue_match_discovery_date"` IssueMatchTargetRemediationDate *TimeFilter `json:"issue_match_target_remediation_date"` diff --git a/internal/mocks/mock_Database.go b/internal/mocks/mock_Database.go index d61728b8..5ae6c793 100644 --- a/internal/mocks/mock_Database.go +++ b/internal/mocks/mock_Database.go @@ -1,7 +1,4 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by mockery v2.42.1. DO NOT EDIT. +// Code generated by mockery v2.44.1. DO NOT EDIT. package mocks diff --git a/internal/mocks/mock_Heureka.go b/internal/mocks/mock_Heureka.go index ba70f0e0..2784e1e4 100644 --- a/internal/mocks/mock_Heureka.go +++ b/internal/mocks/mock_Heureka.go @@ -1,7 +1,4 @@ -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by mockery v2.42.1. DO NOT EDIT. +// Code generated by mockery v2.44.1. DO NOT EDIT. package mocks @@ -437,6 +434,65 @@ func (_c *MockHeureka_AddServiceToSupportGroup_Call) RunAndReturn(run func(int64 return _c } +// AddUserToSupportGroup provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) AddUserToSupportGroup(_a0 int64, _a1 int64) (*entity.SupportGroup, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for AddUserToSupportGroup") + } + + var r0 *entity.SupportGroup + var r1 error + if rf, ok := ret.Get(0).(func(int64, int64) (*entity.SupportGroup, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(int64, int64) *entity.SupportGroup); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*entity.SupportGroup) + } + } + + if rf, ok := ret.Get(1).(func(int64, int64) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHeureka_AddUserToSupportGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUserToSupportGroup' +type MockHeureka_AddUserToSupportGroup_Call struct { + *mock.Call +} + +// AddUserToSupportGroup is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockHeureka_Expecter) AddUserToSupportGroup(_a0 interface{}, _a1 interface{}) *MockHeureka_AddUserToSupportGroup_Call { + return &MockHeureka_AddUserToSupportGroup_Call{Call: _e.mock.On("AddUserToSupportGroup", _a0, _a1)} +} + +func (_c *MockHeureka_AddUserToSupportGroup_Call) Run(run func(_a0 int64, _a1 int64)) *MockHeureka_AddUserToSupportGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockHeureka_AddUserToSupportGroup_Call) Return(_a0 *entity.SupportGroup, _a1 error) *MockHeureka_AddUserToSupportGroup_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHeureka_AddUserToSupportGroup_Call) RunAndReturn(run func(int64, int64) (*entity.SupportGroup, error)) *MockHeureka_AddUserToSupportGroup_Call { + _c.Call.Return(run) + return _c +} + // CreateActivity provides a mock function with given fields: _a0 func (_m *MockHeureka) CreateActivity(_a0 *entity.Activity) (*entity.Activity, error) { ret := _m.Called(_a0) @@ -3318,6 +3374,65 @@ func (_c *MockHeureka_RemoveServiceFromSupportGroup_Call) RunAndReturn(run func( return _c } +// RemoveUserFromSupportGroup provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) RemoveUserFromSupportGroup(_a0 int64, _a1 int64) (*entity.SupportGroup, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for RemoveUserFromSupportGroup") + } + + var r0 *entity.SupportGroup + var r1 error + if rf, ok := ret.Get(0).(func(int64, int64) (*entity.SupportGroup, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(int64, int64) *entity.SupportGroup); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*entity.SupportGroup) + } + } + + if rf, ok := ret.Get(1).(func(int64, int64) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHeureka_RemoveUserFromSupportGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUserFromSupportGroup' +type MockHeureka_RemoveUserFromSupportGroup_Call struct { + *mock.Call +} + +// RemoveUserFromSupportGroup is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockHeureka_Expecter) RemoveUserFromSupportGroup(_a0 interface{}, _a1 interface{}) *MockHeureka_RemoveUserFromSupportGroup_Call { + return &MockHeureka_RemoveUserFromSupportGroup_Call{Call: _e.mock.On("RemoveUserFromSupportGroup", _a0, _a1)} +} + +func (_c *MockHeureka_RemoveUserFromSupportGroup_Call) Run(run func(_a0 int64, _a1 int64)) *MockHeureka_RemoveUserFromSupportGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockHeureka_RemoveUserFromSupportGroup_Call) Return(_a0 *entity.SupportGroup, _a1 error) *MockHeureka_RemoveUserFromSupportGroup_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHeureka_RemoveUserFromSupportGroup_Call) RunAndReturn(run func(int64, int64) (*entity.SupportGroup, error)) *MockHeureka_RemoveUserFromSupportGroup_Call { + _c.Call.Return(run) + return _c +} + // Shutdown provides a mock function with given fields: func (_m *MockHeureka) Shutdown() error { ret := _m.Called()