From a0a9be6f34c792c2e4e3bcbb969051ce70f9dea7 Mon Sep 17 00:00:00 2001 From: Michael Reimsbach Date: Tue, 9 Jul 2024 16:16:19 +0200 Subject: [PATCH 1/2] feat(service): add mutations for relations --- internal/api/graphql/graph/generated.go | 1175 +++++++++++++++-- .../activity/addService.graphql | 19 + .../activity/removeService.graphql | 19 + .../service/addIssueRepository.graphql | 21 + .../queryCollection/service/addOwner.graphql | 20 + .../service/removeIssueRepository.graphql | 20 + .../service/removeOwner.graphql | 20 + .../supportGroup/addService.graphql | 20 + .../supportGroup/removeService.graphql | 20 + .../api/graphql/graph/resolver/mutation.go | 176 +++ .../graphql/graph/schema/mutation.graphqls | 8 + internal/app/activity.go | 64 +- internal/app/activity_test.go | 44 + internal/app/interface.go | 8 + internal/app/service.go | 98 +- internal/app/service_test.go | 92 +- internal/app/support_group.go | 63 +- internal/app/support_group_test.go | 44 + internal/database/interface.go | 8 + internal/database/mariadb/activity.go | 50 + internal/database/mariadb/activity_test.go | 65 + internal/database/mariadb/entity.go | 4 +- internal/database/mariadb/service.go | 103 ++ internal/database/mariadb/service_test.go | 131 ++ internal/database/mariadb/support_group.go | 50 + .../database/mariadb/support_group_test.go | 65 + internal/e2e/activity_query_test.go | 117 ++ internal/e2e/service_query_test.go | 233 ++++ internal/e2e/support_group_query_test.go | 115 ++ internal/entity/service.go | 2 +- internal/entity/test/service.go | 2 +- internal/mocks/mock_Database.go | 377 ++++++ internal/mocks/mock_Heureka.go | 350 +++++ 33 files changed, 3438 insertions(+), 165 deletions(-) create mode 100644 internal/api/graphql/graph/queryCollection/activity/addService.graphql create mode 100644 internal/api/graphql/graph/queryCollection/activity/removeService.graphql create mode 100644 internal/api/graphql/graph/queryCollection/service/addIssueRepository.graphql create mode 100644 internal/api/graphql/graph/queryCollection/service/addOwner.graphql create mode 100644 internal/api/graphql/graph/queryCollection/service/removeIssueRepository.graphql create mode 100644 internal/api/graphql/graph/queryCollection/service/removeOwner.graphql create mode 100644 internal/api/graphql/graph/queryCollection/supportGroup/addService.graphql create mode 100644 internal/api/graphql/graph/queryCollection/supportGroup/removeService.graphql diff --git a/internal/api/graphql/graph/generated.go b/internal/api/graphql/graph/generated.go index 5187205c..ca52833f 100644 --- a/internal/api/graphql/graph/generated.go +++ b/internal/api/graphql/graph/generated.go @@ -348,45 +348,53 @@ type ComplexityRoot struct { } Mutation struct { - CreateActivity func(childComplexity int, input model.ActivityInput) int - CreateComponent func(childComplexity int, input model.ComponentInput) int - CreateComponentInstance func(childComplexity int, input model.ComponentInstanceInput) int - CreateComponentVersion func(childComplexity int, input model.ComponentVersionInput) int - CreateEvidence func(childComplexity int, input model.EvidenceInput) int - CreateIssue func(childComplexity int, input model.IssueInput) int - CreateIssueMatch func(childComplexity int, input model.IssueMatchInput) int - CreateIssueMatchChange func(childComplexity int, input model.IssueMatchChangeInput) int - CreateIssueRepository func(childComplexity int, input model.IssueRepositoryInput) int - CreateIssueVariant func(childComplexity int, input model.IssueVariantInput) int - CreateService func(childComplexity int, input model.ServiceInput) int - CreateSupportGroup func(childComplexity int, input model.SupportGroupInput) int - CreateUser func(childComplexity int, input model.UserInput) int - DeleteActivity func(childComplexity int, id string) int - DeleteComponent func(childComplexity int, id string) int - DeleteComponentInstance func(childComplexity int, id string) int - DeleteComponentVersion func(childComplexity int, id string) int - DeleteEvidence func(childComplexity int, id string) int - DeleteIssue func(childComplexity int, id string) int - DeleteIssueMatch func(childComplexity int, id string) int - DeleteIssueMatchChange func(childComplexity int, id string) int - DeleteIssueRepository func(childComplexity int, id string) int - DeleteIssueVariant func(childComplexity int, id string) int - DeleteService func(childComplexity int, id string) int - DeleteSupportGroup func(childComplexity int, id string) int - DeleteUser func(childComplexity int, id string) int - UpdateActivity func(childComplexity int, id string, input model.ActivityInput) int - UpdateComponent func(childComplexity int, id string, input model.ComponentInput) int - UpdateComponentInstance func(childComplexity int, id string, input model.ComponentInstanceInput) int - UpdateComponentVersion func(childComplexity int, id string, input model.ComponentVersionInput) int - UpdateEvidence func(childComplexity int, id string, input model.EvidenceInput) int - UpdateIssue func(childComplexity int, id string, input model.IssueInput) int - UpdateIssueMatch func(childComplexity int, id string, input model.IssueMatchInput) int - UpdateIssueMatchChange func(childComplexity int, id string, input model.IssueMatchChangeInput) int - UpdateIssueRepository func(childComplexity int, id string, input model.IssueRepositoryInput) int - UpdateIssueVariant func(childComplexity int, id string, input model.IssueVariantInput) int - UpdateService func(childComplexity int, id string, input model.ServiceInput) int - UpdateSupportGroup func(childComplexity int, id string, input model.SupportGroupInput) int - UpdateUser func(childComplexity int, id string, input model.UserInput) int + AddIssueRepositoryToService func(childComplexity int, serviceID string, issueRepositoryID string, priority int) int + AddOwnerToService func(childComplexity int, serviceID string, userID string) int + AddServiceToActivity func(childComplexity int, activityID string, serviceID string) int + AddServiceToSupportGroup func(childComplexity int, supportGroupID string, serviceID string) int + CreateActivity func(childComplexity int, input model.ActivityInput) int + CreateComponent func(childComplexity int, input model.ComponentInput) int + CreateComponentInstance func(childComplexity int, input model.ComponentInstanceInput) int + CreateComponentVersion func(childComplexity int, input model.ComponentVersionInput) int + CreateEvidence func(childComplexity int, input model.EvidenceInput) int + CreateIssue func(childComplexity int, input model.IssueInput) int + CreateIssueMatch func(childComplexity int, input model.IssueMatchInput) int + CreateIssueMatchChange func(childComplexity int, input model.IssueMatchChangeInput) int + CreateIssueRepository func(childComplexity int, input model.IssueRepositoryInput) int + CreateIssueVariant func(childComplexity int, input model.IssueVariantInput) int + CreateService func(childComplexity int, input model.ServiceInput) int + CreateSupportGroup func(childComplexity int, input model.SupportGroupInput) int + CreateUser func(childComplexity int, input model.UserInput) int + DeleteActivity func(childComplexity int, id string) int + DeleteComponent func(childComplexity int, id string) int + DeleteComponentInstance func(childComplexity int, id string) int + DeleteComponentVersion func(childComplexity int, id string) int + DeleteEvidence func(childComplexity int, id string) int + DeleteIssue func(childComplexity int, id string) int + DeleteIssueMatch func(childComplexity int, id string) int + DeleteIssueMatchChange func(childComplexity int, id string) int + DeleteIssueRepository func(childComplexity int, id string) int + DeleteIssueVariant func(childComplexity int, id string) int + DeleteService func(childComplexity int, id string) int + DeleteSupportGroup func(childComplexity int, id string) int + DeleteUser func(childComplexity int, id string) int + RemoveIssueRepositoryFromService func(childComplexity int, serviceID string, issueRepositoryID string) int + RemoveOwnerFromService func(childComplexity int, serviceID string, userID string) int + RemoveServiceFromActivity func(childComplexity int, activityID string, serviceID string) int + RemoveServiceFromSupportGroup func(childComplexity int, supportGroupID string, serviceID string) int + UpdateActivity func(childComplexity int, id string, input model.ActivityInput) int + UpdateComponent func(childComplexity int, id string, input model.ComponentInput) int + UpdateComponentInstance func(childComplexity int, id string, input model.ComponentInstanceInput) int + UpdateComponentVersion func(childComplexity int, id string, input model.ComponentVersionInput) int + UpdateEvidence func(childComplexity int, id string, input model.EvidenceInput) int + UpdateIssue func(childComplexity int, id string, input model.IssueInput) int + UpdateIssueMatch func(childComplexity int, id string, input model.IssueMatchInput) int + UpdateIssueMatchChange func(childComplexity int, id string, input model.IssueMatchChangeInput) int + UpdateIssueRepository func(childComplexity int, id string, input model.IssueRepositoryInput) int + UpdateIssueVariant func(childComplexity int, id string, input model.IssueVariantInput) int + UpdateService func(childComplexity int, id string, input model.ServiceInput) int + UpdateSupportGroup func(childComplexity int, id string, input model.SupportGroupInput) int + UpdateUser func(childComplexity int, id string, input model.UserInput) int } Page struct { @@ -549,6 +557,8 @@ type MutationResolver interface { CreateSupportGroup(ctx context.Context, input model.SupportGroupInput) (*model.SupportGroup, error) UpdateSupportGroup(ctx context.Context, id string, input model.SupportGroupInput) (*model.SupportGroup, error) DeleteSupportGroup(ctx context.Context, id string) (string, error) + AddServiceToSupportGroup(ctx context.Context, supportGroupID string, serviceID string) (*model.SupportGroup, error) + RemoveServiceFromSupportGroup(ctx context.Context, supportGroupID string, serviceID string) (*model.SupportGroup, error) CreateComponent(ctx context.Context, input model.ComponentInput) (*model.Component, error) UpdateComponent(ctx context.Context, id string, input model.ComponentInput) (*model.Component, error) DeleteComponent(ctx context.Context, id string) (string, error) @@ -561,6 +571,10 @@ type MutationResolver interface { CreateService(ctx context.Context, input model.ServiceInput) (*model.Service, error) UpdateService(ctx context.Context, id string, input model.ServiceInput) (*model.Service, error) DeleteService(ctx context.Context, id string) (string, error) + AddOwnerToService(ctx context.Context, serviceID string, userID string) (*model.Service, error) + RemoveOwnerFromService(ctx context.Context, serviceID string, userID string) (*model.Service, error) + AddIssueRepositoryToService(ctx context.Context, serviceID string, issueRepositoryID string, priority int) (*model.Service, error) + RemoveIssueRepositoryFromService(ctx context.Context, serviceID string, issueRepositoryID string) (*model.Service, error) CreateIssueRepository(ctx context.Context, input model.IssueRepositoryInput) (*model.IssueRepository, error) UpdateIssueRepository(ctx context.Context, id string, input model.IssueRepositoryInput) (*model.IssueRepository, error) DeleteIssueRepository(ctx context.Context, id string) (string, error) @@ -582,6 +596,8 @@ type MutationResolver interface { CreateActivity(ctx context.Context, input model.ActivityInput) (*model.Activity, error) UpdateActivity(ctx context.Context, id string, input model.ActivityInput) (*model.Activity, error) DeleteActivity(ctx context.Context, id string) (string, error) + AddServiceToActivity(ctx context.Context, activityID string, serviceID string) (*model.Activity, error) + RemoveServiceFromActivity(ctx context.Context, activityID string, serviceID string) (*model.Activity, error) } type QueryResolver interface { Issues(ctx context.Context, filter *model.IssueFilter, first *int, after *string) (*model.IssueConnection, error) @@ -1950,6 +1966,54 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.IssueVariantEdge.UpdatedAt(childComplexity), true + case "Mutation.addIssueRepositoryToService": + if e.complexity.Mutation.AddIssueRepositoryToService == nil { + break + } + + args, err := ec.field_Mutation_addIssueRepositoryToService_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.AddIssueRepositoryToService(childComplexity, args["serviceId"].(string), args["issueRepositoryId"].(string), args["priority"].(int)), true + + case "Mutation.addOwnerToService": + if e.complexity.Mutation.AddOwnerToService == nil { + break + } + + args, err := ec.field_Mutation_addOwnerToService_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.AddOwnerToService(childComplexity, args["serviceId"].(string), args["userId"].(string)), true + + case "Mutation.addServiceToActivity": + if e.complexity.Mutation.AddServiceToActivity == nil { + break + } + + args, err := ec.field_Mutation_addServiceToActivity_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.AddServiceToActivity(childComplexity, args["activityId"].(string), args["serviceId"].(string)), true + + case "Mutation.addServiceToSupportGroup": + if e.complexity.Mutation.AddServiceToSupportGroup == nil { + break + } + + args, err := ec.field_Mutation_addServiceToSupportGroup_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.AddServiceToSupportGroup(childComplexity, args["supportGroupId"].(string), args["serviceId"].(string)), true + case "Mutation.createActivity": if e.complexity.Mutation.CreateActivity == nil { break @@ -2262,6 +2326,54 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.DeleteUser(childComplexity, args["id"].(string)), true + case "Mutation.removeIssueRepositoryFromService": + if e.complexity.Mutation.RemoveIssueRepositoryFromService == nil { + break + } + + args, err := ec.field_Mutation_removeIssueRepositoryFromService_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.RemoveIssueRepositoryFromService(childComplexity, args["serviceId"].(string), args["issueRepositoryId"].(string)), true + + case "Mutation.removeOwnerFromService": + if e.complexity.Mutation.RemoveOwnerFromService == nil { + break + } + + args, err := ec.field_Mutation_removeOwnerFromService_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.RemoveOwnerFromService(childComplexity, args["serviceId"].(string), args["userId"].(string)), true + + case "Mutation.removeServiceFromActivity": + if e.complexity.Mutation.RemoveServiceFromActivity == nil { + break + } + + args, err := ec.field_Mutation_removeServiceFromActivity_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.RemoveServiceFromActivity(childComplexity, args["activityId"].(string), args["serviceId"].(string)), true + + case "Mutation.removeServiceFromSupportGroup": + if e.complexity.Mutation.RemoveServiceFromSupportGroup == nil { + break + } + + args, err := ec.field_Mutation_removeServiceFromSupportGroup_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.RemoveServiceFromSupportGroup(childComplexity, args["supportGroupId"].(string), args["serviceId"].(string)), true + case "Mutation.updateActivity": if e.complexity.Mutation.UpdateActivity == nil { break @@ -3653,6 +3765,111 @@ func (ec *executionContext) field_Issue_issueVariants_args(ctx context.Context, return args, nil } +func (ec *executionContext) field_Mutation_addIssueRepositoryToService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["serviceId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["serviceId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["issueRepositoryId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("issueRepositoryId")) + arg1, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["issueRepositoryId"] = arg1 + var arg2 int + if tmp, ok := rawArgs["priority"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) + arg2, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["priority"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Mutation_addOwnerToService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["serviceId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["serviceId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["userId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + arg1, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["userId"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_addServiceToActivity_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["activityId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("activityId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["activityId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["serviceId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceId")) + arg1, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["serviceId"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_addServiceToSupportGroup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["supportGroupId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportGroupId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["supportGroupId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["serviceId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceId")) + arg1, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["serviceId"] = arg1 + return args, nil +} + func (ec *executionContext) field_Mutation_createActivity_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -4043,6 +4260,102 @@ func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context, return args, nil } +func (ec *executionContext) field_Mutation_removeIssueRepositoryFromService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["serviceId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["serviceId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["issueRepositoryId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("issueRepositoryId")) + arg1, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["issueRepositoryId"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_removeOwnerFromService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["serviceId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["serviceId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["userId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + arg1, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["userId"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_removeServiceFromActivity_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["activityId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("activityId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["activityId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["serviceId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceId")) + arg1, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["serviceId"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_removeServiceFromSupportGroup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["supportGroupId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportGroupId")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["supportGroupId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["serviceId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceId")) + arg1, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["serviceId"] = arg1 + return args, nil +} + func (ec *executionContext) field_Mutation_updateActivity_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -13867,8 +14180,8 @@ func (ec *executionContext) fieldContext_Mutation_deleteSupportGroup(ctx context return fc, nil } -func (ec *executionContext) _Mutation_createComponent(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createComponent(ctx, field) +func (ec *executionContext) _Mutation_addServiceToSupportGroup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_addServiceToSupportGroup(ctx, field) if err != nil { return graphql.Null } @@ -13881,7 +14194,7 @@ func (ec *executionContext) _Mutation_createComponent(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateComponent(rctx, fc.Args["input"].(model.ComponentInput)) + return ec.resolvers.Mutation().AddServiceToSupportGroup(rctx, fc.Args["supportGroupId"].(string), fc.Args["serviceId"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -13893,12 +14206,12 @@ func (ec *executionContext) _Mutation_createComponent(ctx context.Context, field } return graphql.Null } - res := resTmp.(*model.Component) + res := resTmp.(*model.SupportGroup) fc.Result = res - return ec.marshalNComponent2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐComponent(ctx, field.Selections, res) + return ec.marshalNSupportGroup2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐSupportGroup(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createComponent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_addServiceToSupportGroup(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -13907,15 +14220,15 @@ func (ec *executionContext) fieldContext_Mutation_createComponent(ctx context.Co Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Component_id(ctx, field) + return ec.fieldContext_SupportGroup_id(ctx, field) case "name": - return ec.fieldContext_Component_name(ctx, field) - case "type": - return ec.fieldContext_Component_type(ctx, field) - case "componentVersions": - return ec.fieldContext_Component_componentVersions(ctx, field) + return ec.fieldContext_SupportGroup_name(ctx, field) + case "users": + return ec.fieldContext_SupportGroup_users(ctx, field) + case "services": + return ec.fieldContext_SupportGroup_services(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Component", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SupportGroup", field.Name) }, } defer func() { @@ -13925,15 +14238,15 @@ func (ec *executionContext) fieldContext_Mutation_createComponent(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createComponent_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_addServiceToSupportGroup_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateComponent(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateComponent(ctx, field) +func (ec *executionContext) _Mutation_removeServiceFromSupportGroup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_removeServiceFromSupportGroup(ctx, field) if err != nil { return graphql.Null } @@ -13946,7 +14259,7 @@ func (ec *executionContext) _Mutation_updateComponent(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateComponent(rctx, fc.Args["id"].(string), fc.Args["input"].(model.ComponentInput)) + return ec.resolvers.Mutation().RemoveServiceFromSupportGroup(rctx, fc.Args["supportGroupId"].(string), fc.Args["serviceId"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -13958,12 +14271,12 @@ func (ec *executionContext) _Mutation_updateComponent(ctx context.Context, field } return graphql.Null } - res := resTmp.(*model.Component) + res := resTmp.(*model.SupportGroup) fc.Result = res - return ec.marshalNComponent2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐComponent(ctx, field.Selections, res) + return ec.marshalNSupportGroup2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐSupportGroup(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateComponent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_removeServiceFromSupportGroup(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -13972,15 +14285,15 @@ func (ec *executionContext) fieldContext_Mutation_updateComponent(ctx context.Co Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Component_id(ctx, field) + return ec.fieldContext_SupportGroup_id(ctx, field) case "name": - return ec.fieldContext_Component_name(ctx, field) - case "type": - return ec.fieldContext_Component_type(ctx, field) - case "componentVersions": - return ec.fieldContext_Component_componentVersions(ctx, field) + return ec.fieldContext_SupportGroup_name(ctx, field) + case "users": + return ec.fieldContext_SupportGroup_users(ctx, field) + case "services": + return ec.fieldContext_SupportGroup_services(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Component", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SupportGroup", field.Name) }, } defer func() { @@ -13990,15 +14303,15 @@ func (ec *executionContext) fieldContext_Mutation_updateComponent(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateComponent_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_removeServiceFromSupportGroup_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteComponent(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteComponent(ctx, field) +func (ec *executionContext) _Mutation_createComponent(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createComponent(ctx, field) if err != nil { return graphql.Null } @@ -14011,7 +14324,7 @@ func (ec *executionContext) _Mutation_deleteComponent(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteComponent(rctx, fc.Args["id"].(string)) + return ec.resolvers.Mutation().CreateComponent(rctx, fc.Args["input"].(model.ComponentInput)) }) if err != nil { ec.Error(ctx, err) @@ -14023,28 +14336,158 @@ func (ec *executionContext) _Mutation_deleteComponent(ctx context.Context, field } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.Component) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNComponent2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐComponent(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteComponent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createComponent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) + switch field.Name { + case "id": + return ec.fieldContext_Component_id(ctx, field) + case "name": + return ec.fieldContext_Component_name(ctx, field) + case "type": + return ec.fieldContext_Component_type(ctx, field) + case "componentVersions": + return ec.fieldContext_Component_componentVersions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Component", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createComponent_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_updateComponent(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateComponent(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateComponent(rctx, fc.Args["id"].(string), fc.Args["input"].(model.ComponentInput)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Component) + fc.Result = res + return ec.marshalNComponent2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐComponent(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateComponent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Component_id(ctx, field) + case "name": + return ec.fieldContext_Component_name(ctx, field) + case "type": + return ec.fieldContext_Component_type(ctx, field) + case "componentVersions": + return ec.fieldContext_Component_componentVersions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Component", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateComponent_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteComponent(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteComponent(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteComponent(rctx, fc.Args["id"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteComponent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_deleteComponent_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err @@ -14342,7 +14785,271 @@ func (ec *executionContext) _Mutation_updateComponentVersion(ctx context.Context }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateComponentVersion(rctx, fc.Args["id"].(string), fc.Args["input"].(model.ComponentVersionInput)) + return ec.resolvers.Mutation().UpdateComponentVersion(rctx, fc.Args["id"].(string), fc.Args["input"].(model.ComponentVersionInput)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.ComponentVersion) + fc.Result = res + return ec.marshalNComponentVersion2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐComponentVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateComponentVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_ComponentVersion_id(ctx, field) + case "version": + return ec.fieldContext_ComponentVersion_version(ctx, field) + case "componentId": + return ec.fieldContext_ComponentVersion_componentId(ctx, field) + case "component": + return ec.fieldContext_ComponentVersion_component(ctx, field) + case "issues": + return ec.fieldContext_ComponentVersion_issues(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ComponentVersion", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateComponentVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteComponentVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteComponentVersion(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteComponentVersion(rctx, fc.Args["id"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteComponentVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteComponentVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_createService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createService(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateService(rctx, fc.Args["input"].(model.ServiceInput)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Service) + fc.Result = res + return ec.marshalNService2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Service_id(ctx, field) + case "name": + return ec.fieldContext_Service_name(ctx, field) + case "owners": + return ec.fieldContext_Service_owners(ctx, field) + case "supportGroups": + return ec.fieldContext_Service_supportGroups(ctx, field) + case "activities": + return ec.fieldContext_Service_activities(ctx, field) + case "issueRepositories": + return ec.fieldContext_Service_issueRepositories(ctx, field) + case "componentInstances": + return ec.fieldContext_Service_componentInstances(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Service", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_updateService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateService(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateService(rctx, fc.Args["id"].(string), fc.Args["input"].(model.ServiceInput)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Service) + fc.Result = res + return ec.marshalNService2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Service_id(ctx, field) + case "name": + return ec.fieldContext_Service_name(ctx, field) + case "owners": + return ec.fieldContext_Service_owners(ctx, field) + case "supportGroups": + return ec.fieldContext_Service_supportGroups(ctx, field) + case "activities": + return ec.fieldContext_Service_activities(ctx, field) + case "issueRepositories": + return ec.fieldContext_Service_issueRepositories(ctx, field) + case "componentInstances": + return ec.fieldContext_Service_componentInstances(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Service", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteService(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteService(rctx, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -14354,31 +15061,19 @@ func (ec *executionContext) _Mutation_updateComponentVersion(ctx context.Context } return graphql.Null } - res := resTmp.(*model.ComponentVersion) + res := resTmp.(string) fc.Result = res - return ec.marshalNComponentVersion2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐComponentVersion(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateComponentVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_ComponentVersion_id(ctx, field) - case "version": - return ec.fieldContext_ComponentVersion_version(ctx, field) - case "componentId": - return ec.fieldContext_ComponentVersion_componentId(ctx, field) - case "component": - return ec.fieldContext_ComponentVersion_component(ctx, field) - case "issues": - return ec.fieldContext_ComponentVersion_issues(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ComponentVersion", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } defer func() { @@ -14388,15 +15083,15 @@ func (ec *executionContext) fieldContext_Mutation_updateComponentVersion(ctx con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateComponentVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteComponentVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteComponentVersion(ctx, field) +func (ec *executionContext) _Mutation_addOwnerToService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_addOwnerToService(ctx, field) if err != nil { return graphql.Null } @@ -14409,7 +15104,7 @@ func (ec *executionContext) _Mutation_deleteComponentVersion(ctx context.Context }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteComponentVersion(rctx, fc.Args["id"].(string)) + return ec.resolvers.Mutation().AddOwnerToService(rctx, fc.Args["serviceId"].(string), fc.Args["userId"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -14421,19 +15116,35 @@ func (ec *executionContext) _Mutation_deleteComponentVersion(ctx context.Context } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.Service) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNService2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐService(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteComponentVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_addOwnerToService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Service_id(ctx, field) + case "name": + return ec.fieldContext_Service_name(ctx, field) + case "owners": + return ec.fieldContext_Service_owners(ctx, field) + case "supportGroups": + return ec.fieldContext_Service_supportGroups(ctx, field) + case "activities": + return ec.fieldContext_Service_activities(ctx, field) + case "issueRepositories": + return ec.fieldContext_Service_issueRepositories(ctx, field) + case "componentInstances": + return ec.fieldContext_Service_componentInstances(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Service", field.Name) }, } defer func() { @@ -14443,15 +15154,15 @@ func (ec *executionContext) fieldContext_Mutation_deleteComponentVersion(ctx con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteComponentVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_addOwnerToService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createService(ctx, field) +func (ec *executionContext) _Mutation_removeOwnerFromService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_removeOwnerFromService(ctx, field) if err != nil { return graphql.Null } @@ -14464,7 +15175,7 @@ func (ec *executionContext) _Mutation_createService(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateService(rctx, fc.Args["input"].(model.ServiceInput)) + return ec.resolvers.Mutation().RemoveOwnerFromService(rctx, fc.Args["serviceId"].(string), fc.Args["userId"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -14481,7 +15192,7 @@ func (ec *executionContext) _Mutation_createService(ctx context.Context, field g return ec.marshalNService2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐService(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_removeOwnerFromService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -14514,15 +15225,15 @@ func (ec *executionContext) fieldContext_Mutation_createService(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_removeOwnerFromService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateService(ctx, field) +func (ec *executionContext) _Mutation_addIssueRepositoryToService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_addIssueRepositoryToService(ctx, field) if err != nil { return graphql.Null } @@ -14535,7 +15246,7 @@ func (ec *executionContext) _Mutation_updateService(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateService(rctx, fc.Args["id"].(string), fc.Args["input"].(model.ServiceInput)) + return ec.resolvers.Mutation().AddIssueRepositoryToService(rctx, fc.Args["serviceId"].(string), fc.Args["issueRepositoryId"].(string), fc.Args["priority"].(int)) }) if err != nil { ec.Error(ctx, err) @@ -14552,7 +15263,7 @@ func (ec *executionContext) _Mutation_updateService(ctx context.Context, field g return ec.marshalNService2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐService(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_addIssueRepositoryToService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -14585,15 +15296,15 @@ func (ec *executionContext) fieldContext_Mutation_updateService(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_addIssueRepositoryToService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteService(ctx, field) +func (ec *executionContext) _Mutation_removeIssueRepositoryFromService(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_removeIssueRepositoryFromService(ctx, field) if err != nil { return graphql.Null } @@ -14606,7 +15317,7 @@ func (ec *executionContext) _Mutation_deleteService(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteService(rctx, fc.Args["id"].(string)) + return ec.resolvers.Mutation().RemoveIssueRepositoryFromService(rctx, fc.Args["serviceId"].(string), fc.Args["issueRepositoryId"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -14618,19 +15329,35 @@ func (ec *executionContext) _Mutation_deleteService(ctx context.Context, field g } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.Service) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNService2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐService(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_removeIssueRepositoryFromService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Service_id(ctx, field) + case "name": + return ec.fieldContext_Service_name(ctx, field) + case "owners": + return ec.fieldContext_Service_owners(ctx, field) + case "supportGroups": + return ec.fieldContext_Service_supportGroups(ctx, field) + case "activities": + return ec.fieldContext_Service_activities(ctx, field) + case "issueRepositories": + return ec.fieldContext_Service_issueRepositories(ctx, field) + case "componentInstances": + return ec.fieldContext_Service_componentInstances(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Service", field.Name) }, } defer func() { @@ -14640,7 +15367,7 @@ func (ec *executionContext) fieldContext_Mutation_deleteService(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_removeIssueRepositoryFromService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -16086,6 +16813,144 @@ func (ec *executionContext) fieldContext_Mutation_deleteActivity(ctx context.Con return fc, nil } +func (ec *executionContext) _Mutation_addServiceToActivity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_addServiceToActivity(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().AddServiceToActivity(rctx, fc.Args["activityId"].(string), fc.Args["serviceId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Activity) + fc.Result = res + return ec.marshalNActivity2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐActivity(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_addServiceToActivity(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Activity_id(ctx, field) + case "status": + return ec.fieldContext_Activity_status(ctx, field) + case "services": + return ec.fieldContext_Activity_services(ctx, field) + case "issues": + return ec.fieldContext_Activity_issues(ctx, field) + case "evidences": + return ec.fieldContext_Activity_evidences(ctx, field) + case "issueMatchChanges": + return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_addServiceToActivity_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_removeServiceFromActivity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_removeServiceFromActivity(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RemoveServiceFromActivity(rctx, fc.Args["activityId"].(string), fc.Args["serviceId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Activity) + fc.Result = res + return ec.marshalNActivity2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐActivity(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_removeServiceFromActivity(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Activity_id(ctx, field) + case "status": + return ec.fieldContext_Activity_status(ctx, field) + case "services": + return ec.fieldContext_Activity_services(ctx, field) + case "issues": + return ec.fieldContext_Activity_issues(ctx, field) + case "evidences": + return ec.fieldContext_Activity_evidences(ctx, field) + case "issueMatchChanges": + return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_removeServiceFromActivity_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Page_after(ctx context.Context, field graphql.CollectedField, obj *model.Page) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Page_after(ctx, field) if err != nil { @@ -24957,6 +25822,20 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "addServiceToSupportGroup": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_addServiceToSupportGroup(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "removeServiceFromSupportGroup": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_removeServiceFromSupportGroup(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "createComponent": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createComponent(ctx, field) @@ -25041,6 +25920,34 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "addOwnerToService": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_addOwnerToService(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "removeOwnerFromService": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_removeOwnerFromService(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "addIssueRepositoryToService": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_addIssueRepositoryToService(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "removeIssueRepositoryFromService": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_removeIssueRepositoryFromService(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "createIssueRepository": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createIssueRepository(ctx, field) @@ -25188,6 +26095,20 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "addServiceToActivity": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_addServiceToActivity(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "removeServiceFromActivity": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_removeServiceFromActivity(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/internal/api/graphql/graph/queryCollection/activity/addService.graphql b/internal/api/graphql/graph/queryCollection/activity/addService.graphql new file mode 100644 index 00000000..09036fac --- /dev/null +++ b/internal/api/graphql/graph/queryCollection/activity/addService.graphql @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +mutation ($activityId: ID!, $serviceId: ID!) { + addServiceToActivity ( + activityId: $activityId, + serviceId: $serviceId + ) { + id + services { + edges { + node { + id + name + } + } + } + } +} \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/activity/removeService.graphql b/internal/api/graphql/graph/queryCollection/activity/removeService.graphql new file mode 100644 index 00000000..c0fb433f --- /dev/null +++ b/internal/api/graphql/graph/queryCollection/activity/removeService.graphql @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +mutation ($activityId: ID!, $serviceId: ID!) { + removeServiceFromActivity ( + serviceId: $serviceId, + activityId: $activityId + ) { + id + services { + edges { + node { + id + name + } + } + } + } +} \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/service/addIssueRepository.graphql b/internal/api/graphql/graph/queryCollection/service/addIssueRepository.graphql new file mode 100644 index 00000000..86d82b10 --- /dev/null +++ b/internal/api/graphql/graph/queryCollection/service/addIssueRepository.graphql @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +mutation ($serviceId: ID!, $issueRepositoryId: ID!, $priority: Int!) { + addIssueRepositoryToService ( + serviceId: $serviceId, + issueRepositoryId: $issueRepositoryId, + priority: $priority + ) { + id + name + issueRepositories { + edges { + node { + id + name + } + } + } + } +} \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/service/addOwner.graphql b/internal/api/graphql/graph/queryCollection/service/addOwner.graphql new file mode 100644 index 00000000..91cc9485 --- /dev/null +++ b/internal/api/graphql/graph/queryCollection/service/addOwner.graphql @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +mutation ($serviceId: ID!, $userId: ID!) { + addOwnerToService ( + serviceId: $serviceId, + userId: $userId + ) { + id + name + owners { + edges { + node { + id + name + } + } + } + } +} \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/service/removeIssueRepository.graphql b/internal/api/graphql/graph/queryCollection/service/removeIssueRepository.graphql new file mode 100644 index 00000000..a9da692c --- /dev/null +++ b/internal/api/graphql/graph/queryCollection/service/removeIssueRepository.graphql @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +mutation ($serviceId: ID!, $issueRepositoryId: ID!) { + removeIssueRepositoryFromService ( + serviceId: $serviceId, + issueRepositoryId: $issueRepositoryId + ) { + id + name + issueRepositories { + edges { + node { + id + name + } + } + } + } +} \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/service/removeOwner.graphql b/internal/api/graphql/graph/queryCollection/service/removeOwner.graphql new file mode 100644 index 00000000..484950ca --- /dev/null +++ b/internal/api/graphql/graph/queryCollection/service/removeOwner.graphql @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +mutation ($serviceId: ID!, $userId: ID!) { + removeOwnerFromService ( + serviceId: $serviceId, + userId: $userId + ) { + id + name + owners{ + edges { + node { + id + name + } + } + } + } +} \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/supportGroup/addService.graphql b/internal/api/graphql/graph/queryCollection/supportGroup/addService.graphql new file mode 100644 index 00000000..a305a241 --- /dev/null +++ b/internal/api/graphql/graph/queryCollection/supportGroup/addService.graphql @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +mutation ($supportGroupId: ID!, $serviceId: ID!) { + addServiceToSupportGroup ( + supportGroupId: $supportGroupId, + serviceId: $serviceId + ) { + id + name + services { + edges { + node { + id + name + } + } + } + } +} \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/supportGroup/removeService.graphql b/internal/api/graphql/graph/queryCollection/supportGroup/removeService.graphql new file mode 100644 index 00000000..fcdca46a --- /dev/null +++ b/internal/api/graphql/graph/queryCollection/supportGroup/removeService.graphql @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +mutation ($supportGroupId: ID!, $serviceId: ID!) { + removeServiceFromSupportGroup ( + serviceId: $serviceId, + supportGroupId: $supportGroupId + ) { + id + name + services { + edges { + node { + id + name + } + } + } + } +} \ No newline at end of file diff --git a/internal/api/graphql/graph/resolver/mutation.go b/internal/api/graphql/graph/resolver/mutation.go index 8a5fdc70..c1696402 100644 --- a/internal/api/graphql/graph/resolver/mutation.go +++ b/internal/api/graphql/graph/resolver/mutation.go @@ -95,6 +95,50 @@ func (r *mutationResolver) DeleteSupportGroup(ctx context.Context, id string) (s return id, nil } +// AddServiceToSupportGroup is the resolver for the addServiceToSupportGroup field. +func (r *mutationResolver) AddServiceToSupportGroup(ctx context.Context, supportGroupID string, serviceID string) (*model.SupportGroup, error) { + supportGroupIdInt, err := baseResolver.ParseCursor(&supportGroupID) + if err != nil { + return nil, baseResolver.NewResolverError("AddServiceToSupportGroupMutationResolver", "Internal Error - when adding service to supportGroup") + } + + serviceIdInt, err := baseResolver.ParseCursor(&serviceID) + if err != nil { + return nil, baseResolver.NewResolverError("AddServiceToSupportGroupMutationResolver", "Internal Error - when adding service to supportGroup") + } + + supportGroup, err := r.App.AddServiceToSupportGroup(*supportGroupIdInt, *serviceIdInt) + + if err != nil { + return nil, baseResolver.NewResolverError("AddServiceToSupportGroupMutationResolver", "Internal Error - when adding service to supportGroup") + } + + sg := model.NewSupportGroup(supportGroup) + return &sg, nil +} + +// RemoveServiceFromSupportGroup is the resolver for the removeServiceFromSupportGroup field. +func (r *mutationResolver) RemoveServiceFromSupportGroup(ctx context.Context, supportGroupID string, serviceID string) (*model.SupportGroup, error) { + supportGroupIdInt, err := baseResolver.ParseCursor(&supportGroupID) + if err != nil { + return nil, baseResolver.NewResolverError("RemoveServiceFromSupportGroupMutationResolver", "Internal Error - when removing service from supportGroup") + } + + serviceIdInt, err := baseResolver.ParseCursor(&serviceID) + if err != nil { + return nil, baseResolver.NewResolverError("RemoveServiceFromSupportGroupMutationResolver", "Internal Error - when removing service from supportGroup") + } + + supportGroup, err := r.App.RemoveServiceFromSupportGroup(*supportGroupIdInt, *serviceIdInt) + + if err != nil { + return nil, baseResolver.NewResolverError("RemoveServiceFromSupportGroupMutationResolver", "Internal Error - when removing service from supportGroup") + } + + sg := model.NewSupportGroup(supportGroup) + return &sg, nil +} + // CreateComponent is the resolver for the createComponent field. func (r *mutationResolver) CreateComponent(ctx context.Context, input model.ComponentInput) (*model.Component, error) { component := model.NewComponentEntity(&input) @@ -255,6 +299,94 @@ func (r *mutationResolver) DeleteService(ctx context.Context, id string) (string return id, nil } +// AddOwnerToService is the resolver for the addOwnerToService field. +func (r *mutationResolver) AddOwnerToService(ctx context.Context, serviceID string, userID string) (*model.Service, error) { + serviceIdInt, err := baseResolver.ParseCursor(&serviceID) + if err != nil { + return nil, baseResolver.NewResolverError("AddOwnerToServiceMutationResolver", "Internal Error - when adding owner to service") + } + + userIdInt, err := baseResolver.ParseCursor(&userID) + if err != nil { + return nil, baseResolver.NewResolverError("AddOwnerToServiceMutationResolver", "Internal Error - when adding owner to service") + } + + service, err := r.App.AddOwnerToService(*serviceIdInt, *userIdInt) + + if err != nil { + return nil, baseResolver.NewResolverError("AddOwnerToServiceMutationResolver", "Internal Error - when adding owner to service") + } + + s := model.NewService(service) + return &s, nil +} + +// RemoveOwnerFromService is the resolver for the removeOwnerFromService field. +func (r *mutationResolver) RemoveOwnerFromService(ctx context.Context, serviceID string, userID string) (*model.Service, error) { + serviceIdInt, err := baseResolver.ParseCursor(&serviceID) + if err != nil { + return nil, baseResolver.NewResolverError("RemoveOwnerFromServiceMutationResolver", "Internal Error - when removing owner from service") + } + + userIdInt, err := baseResolver.ParseCursor(&userID) + if err != nil { + return nil, baseResolver.NewResolverError("RemoveOwnerFromServiceMutationResolver", "Internal Error - when removing owner from service") + } + + service, err := r.App.RemoveOwnerFromService(*serviceIdInt, *userIdInt) + + if err != nil { + return nil, baseResolver.NewResolverError("RemoveOwnerFromServiceMutationResolver", "Internal Error - when removing owner from service") + } + + s := model.NewService(service) + return &s, nil +} + +// AddIssueRepositoryToService is the resolver for the addIssueRepositoryToService field. +func (r *mutationResolver) AddIssueRepositoryToService(ctx context.Context, serviceID string, issueRepositoryID string, priority int) (*model.Service, error) { + serviceIdInt, err := baseResolver.ParseCursor(&serviceID) + if err != nil { + return nil, baseResolver.NewResolverError("AddIssueRepositoryToServiceMutationResolver", "Internal Error - when adding IssueRepository to service") + } + + issueRepositoryIdInt, err := baseResolver.ParseCursor(&issueRepositoryID) + if err != nil { + return nil, baseResolver.NewResolverError("AddIssueRepositoryToServiceMutationResolver", "Internal Error - when adding IssueRepository to service") + } + + service, err := r.App.AddIssueRepositoryToService(*serviceIdInt, *issueRepositoryIdInt, int64(priority)) + + if err != nil { + return nil, baseResolver.NewResolverError("AddIssueRepositoryToServiceMutationResolver", "Internal Error - when adding IssueRepository to service") + } + + s := model.NewService(service) + return &s, nil +} + +// RemoveIssueRepositoryFromService is the resolver for the removeIssueRepositoryFromService field. +func (r *mutationResolver) RemoveIssueRepositoryFromService(ctx context.Context, serviceID string, issueRepositoryID string) (*model.Service, error) { + serviceIdInt, err := baseResolver.ParseCursor(&serviceID) + if err != nil { + return nil, baseResolver.NewResolverError("RemoveIssueRepositoryFromServiceMutationResolver", "Internal Error - when removing IssueRepository from service") + } + + issueRepositoryIdInt, err := baseResolver.ParseCursor(&issueRepositoryID) + if err != nil { + return nil, baseResolver.NewResolverError("RemoveIssueRepositoryFromServiceMutationResolver", "Internal Error - when removing IssueRepository from service") + } + + service, err := r.App.RemoveIssueRepositoryFromService(*serviceIdInt, *issueRepositoryIdInt) + + if err != nil { + return nil, baseResolver.NewResolverError("RemoveIssueRepositoryFromServiceMutationResolver", "Internal Error - when removing IssueRepository from service") + } + + s := model.NewService(service) + return &s, nil +} + // CreateIssueRepository is the resolver for the createIssueRepository field. func (r *mutationResolver) CreateIssueRepository(ctx context.Context, input model.IssueRepositoryInput) (*model.IssueRepository, error) { issueRepository := model.NewIssueRepositoryEntity(&input) @@ -535,6 +667,50 @@ func (r *mutationResolver) DeleteActivity(ctx context.Context, id string) (strin return id, nil } +// AddServiceToActivity is the resolver for the addServiceToActivity field. +func (r *mutationResolver) AddServiceToActivity(ctx context.Context, activityID string, serviceID string) (*model.Activity, error) { + activityIdInt, err := baseResolver.ParseCursor(&activityID) + if err != nil { + return nil, baseResolver.NewResolverError("AddServiceToActivityMutationResolver", "Internal Error - when adding service to activity") + } + + serviceIdInt, err := baseResolver.ParseCursor(&serviceID) + if err != nil { + return nil, baseResolver.NewResolverError("AddServiceToActivityMutationResolver", "Internal Error - when adding service to activity") + } + + activity, err := r.App.AddServiceToActivity(*activityIdInt, *serviceIdInt) + + if err != nil { + return nil, baseResolver.NewResolverError("AddServiceToActivityMutationResolver", "Internal Error - when adding service to activity") + } + + a := model.NewActivity(activity) + return &a, nil +} + +// RemoveServiceFromActivity is the resolver for the removeServiceFromActivity field. +func (r *mutationResolver) RemoveServiceFromActivity(ctx context.Context, activityID string, serviceID string) (*model.Activity, error) { + activityIdInt, err := baseResolver.ParseCursor(&activityID) + if err != nil { + return nil, baseResolver.NewResolverError("RemoveServiceFromActivityMutationResolver", "Internal Error - when removing service from activity") + } + + serviceIdInt, err := baseResolver.ParseCursor(&serviceID) + if err != nil { + return nil, baseResolver.NewResolverError("RemoveServiceFromActivityMutationResolver", "Internal Error - when removing service from activity") + } + + activity, err := r.App.RemoveServiceFromActivity(*activityIdInt, *serviceIdInt) + + if err != nil { + return nil, baseResolver.NewResolverError("RemoveServiceFromActivityMutationResolver", "Internal Error - when removing service from activity") + } + + a := model.NewActivity(activity) + return &a, nil +} + // Mutation returns graph.MutationResolver implementation. func (r *Resolver) Mutation() graph.MutationResolver { return &mutationResolver{r} } diff --git a/internal/api/graphql/graph/schema/mutation.graphqls b/internal/api/graphql/graph/schema/mutation.graphqls index 8273c7bb..4b466c1b 100644 --- a/internal/api/graphql/graph/schema/mutation.graphqls +++ b/internal/api/graphql/graph/schema/mutation.graphqls @@ -9,6 +9,8 @@ type Mutation { createSupportGroup(input: SupportGroupInput!): SupportGroup! updateSupportGroup(id: ID!, input: SupportGroupInput!): SupportGroup! deleteSupportGroup(id: ID!): String! + addServiceToSupportGroup(supportGroupId: ID!, serviceId: ID!): SupportGroup! + removeServiceFromSupportGroup(supportGroupId: ID!, serviceId: ID!): SupportGroup! createComponent(input: ComponentInput!): Component! updateComponent(id: ID!, input: ComponentInput!): Component! @@ -25,6 +27,10 @@ type Mutation { createService(input: ServiceInput!): Service! updateService(id: ID!, input: ServiceInput!): Service! deleteService(id: ID!): String! + addOwnerToService(serviceId: ID!, userId: ID!): Service! + removeOwnerFromService(serviceId: ID!, userId: ID!): Service! + addIssueRepositoryToService(serviceId: ID!, issueRepositoryId: ID!, priority: Int!): Service! + removeIssueRepositoryFromService(serviceId: ID!, issueRepositoryId: ID!): Service! createIssueRepository(input: IssueRepositoryInput!): IssueRepository! updateIssueRepository(id: ID!, input: IssueRepositoryInput!): IssueRepository! @@ -53,4 +59,6 @@ type Mutation { createActivity(input: ActivityInput!): Activity! updateActivity(id: ID!, input: ActivityInput!): Activity! deleteActivity(id: ID!): String! + addServiceToActivity(activityId: ID!, serviceId: ID!): Activity! + removeServiceFromActivity(activityId: ID!, serviceId: ID!): Activity! } \ No newline at end of file diff --git a/internal/app/activity.go b/internal/app/activity.go index 215becc6..d1862473 100644 --- a/internal/app/activity.go +++ b/internal/app/activity.go @@ -28,6 +28,26 @@ func (h *HeurekaApp) getActivityResults(filter *entity.ActivityFilter) ([]entity return activityResults, nil } +func (h *HeurekaApp) GetActivity(activityId int64) (*entity.Activity, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.GetActivity", + "id": activityId, + }) + activityFilter := entity.ActivityFilter{Id: []*int64{&activityId}} + activities, err := h.ListActivities(&activityFilter, &entity.ListOptions{}) + + if err != nil { + l.Error(err) + return nil, heurekaError("Internal error while retrieving activities.") + } + + if len(activities.Elements) != 1 { + return nil, heurekaError(fmt.Sprintf("Activity %d not found.", activityId)) + } + + return activities.Elements[0].Activity, nil +} + func (h *HeurekaApp) ListActivities(filter *entity.ActivityFilter, options *entity.ListOptions) (*entity.List[entity.ActivityResult], error) { var count int64 var pageInfo *entity.PageInfo @@ -99,33 +119,55 @@ func (h *HeurekaApp) UpdateActivity(activity *entity.Activity) (*entity.Activity return nil, heurekaError("Internal error while updating activity.") } - activityResult, err := h.ListActivities(&entity.ActivityFilter{Id: []*int64{&activity.Id}}, &entity.ListOptions{}) + return h.GetActivity(activity.Id) +} + +func (h *HeurekaApp) DeleteActivity(id int64) error { + l := logrus.WithFields(logrus.Fields{ + "event": "app.DeleteActivity", + "id": id, + }) + + err := h.database.DeleteActivity(id) if err != nil { l.Error(err) - return nil, heurekaError("Internal error while retrieving updated activity.") + return heurekaError("Internal error while deleting activity.") } - if len(activityResult.Elements) != 1 { + return nil +} + +func (h *HeurekaApp) AddServiceToActivity(activityId, serviceId int64) (*entity.Activity, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.AddServiceToActivity", + "activityId": activityId, + "serviceId": serviceId, + }) + + err := h.database.AddServiceToActivity(activityId, serviceId) + + if err != nil { l.Error(err) - return nil, heurekaError("Multiple activities found.") + return nil, heurekaError("Internal error while adding service to activity.") } - return activityResult.Elements[0].Activity, nil + return h.GetActivity(activityId) } -func (h *HeurekaApp) DeleteActivity(id int64) error { +func (h *HeurekaApp) RemoveServiceFromActivity(activityId, serviceId int64) (*entity.Activity, error) { l := logrus.WithFields(logrus.Fields{ - "event": "app.DeleteActivity", - "id": id, + "event": "app.RemoveServiceFromActivity", + "activityId": activityId, + "serviceId": serviceId, }) - err := h.database.DeleteActivity(id) + err := h.database.RemoveServiceFromActivity(activityId, serviceId) if err != nil { l.Error(err) - return heurekaError("Internal error while deleting activity.") + return nil, heurekaError("Internal error while removing service from activity.") } - return nil + return h.GetActivity(activityId) } diff --git a/internal/app/activity_test.go b/internal/app/activity_test.go index 94e43893..5236d59e 100644 --- a/internal/app/activity_test.go +++ b/internal/app/activity_test.go @@ -191,3 +191,47 @@ var _ = Describe("When deleting Activity", Label("app", "DeleteActivity"), func( Expect(activities.Elements).To(BeEmpty(), "no error should be thrown") }) }) + +var _ = Describe("When modifying Service and Activity", Label("app", "ServiceActivity"), func() { + var ( + db *mocks.MockDatabase + heureka app.Heureka + service entity.Service + activity entity.Activity + filter *entity.ActivityFilter + ) + + BeforeEach(func() { + db = mocks.NewMockDatabase(GinkgoT()) + service = test.NewFakeServiceEntity() + activity = test.NewFakeActivityEntity() + first := 10 + var after int64 + after = 0 + filter = &entity.ActivityFilter{ + Paginated: entity.Paginated{ + First: &first, + After: &after, + }, + Id: []*int64{&activity.Id}, + } + }) + + It("adds service to activity", func() { + db.On("AddServiceToActivity", activity.Id, service.Id).Return(nil) + db.On("GetActivities", filter).Return([]entity.Activity{activity}, nil) + heureka = app.NewHeurekaApp(db) + activity, err := heureka.AddServiceToActivity(activity.Id, service.Id) + Expect(err).To(BeNil(), "no error should be thrown") + Expect(activity).NotTo(BeNil(), "activity should be returned") + }) + + It("removes service from activity", func() { + db.On("RemoveServiceFromActivity", activity.Id, service.Id).Return(nil) + db.On("GetActivities", filter).Return([]entity.Activity{activity}, nil) + heureka = app.NewHeurekaApp(db) + activity, err := heureka.RemoveServiceFromActivity(activity.Id, service.Id) + Expect(err).To(BeNil(), "no error should be thrown") + Expect(activity).NotTo(BeNil(), "activity should be returned") + }) +}) diff --git a/internal/app/interface.go b/internal/app/interface.go index a9594f4e..5602369a 100644 --- a/internal/app/interface.go +++ b/internal/app/interface.go @@ -37,6 +37,10 @@ type Heureka interface { CreateService(*entity.Service) (*entity.Service, error) UpdateService(*entity.Service) (*entity.Service, error) DeleteService(int64) error + AddOwnerToService(int64, int64) (*entity.Service, error) + RemoveOwnerFromService(int64, int64) (*entity.Service, error) + AddIssueRepositoryToService(int64, int64, int64) (*entity.Service, error) + RemoveIssueRepositoryFromService(int64, int64) (*entity.Service, error) ListUsers(*entity.UserFilter, *entity.ListOptions) (*entity.List[entity.UserResult], error) CreateUser(*entity.User) (*entity.User, error) @@ -47,6 +51,8 @@ type Heureka interface { CreateSupportGroup(*entity.SupportGroup) (*entity.SupportGroup, error) UpdateSupportGroup(*entity.SupportGroup) (*entity.SupportGroup, error) DeleteSupportGroup(int64) error + AddServiceToSupportGroup(int64, int64) (*entity.SupportGroup, error) + RemoveServiceFromSupportGroup(int64, int64) (*entity.SupportGroup, error) ListComponentInstances(*entity.ComponentInstanceFilter, *entity.ListOptions) (*entity.List[entity.ComponentInstanceResult], error) CreateComponentInstance(*entity.ComponentInstance) (*entity.ComponentInstance, error) @@ -57,6 +63,8 @@ type Heureka interface { CreateActivity(*entity.Activity) (*entity.Activity, error) UpdateActivity(*entity.Activity) (*entity.Activity, error) DeleteActivity(int64) error + AddServiceToActivity(int64, int64) (*entity.Activity, error) + RemoveServiceFromActivity(int64, int64) (*entity.Activity, error) ListEvidences(*entity.EvidenceFilter, *entity.ListOptions) (*entity.List[entity.EvidenceResult], error) CreateEvidence(*entity.Evidence) (*entity.Evidence, error) diff --git a/internal/app/service.go b/internal/app/service.go index 28d44714..eca04d25 100644 --- a/internal/app/service.go +++ b/internal/app/service.go @@ -28,6 +28,26 @@ func (h *HeurekaApp) getServiceResults(filter *entity.ServiceFilter) ([]entity.S return serviceResults, nil } +func (h *HeurekaApp) GetService(serviceId int64) (*entity.Service, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.GetService", + "id": serviceId, + }) + serviceFilter := entity.ServiceFilter{Id: []*int64{&serviceId}} + services, err := h.ListServices(&serviceFilter, &entity.ListOptions{}) + + if err != nil { + l.Error(err) + return nil, heurekaError("Internal error while retrieving services.") + } + + if len(services.Elements) != 1 { + return nil, heurekaError(fmt.Sprintf("Service %d not found.", serviceId)) + } + + return services.Elements[0].Service, nil +} + func (h *HeurekaApp) ListServices(filter *entity.ServiceFilter, options *entity.ListOptions) (*entity.List[entity.ServiceResult], error) { var count int64 var pageInfo *entity.PageInfo @@ -116,33 +136,89 @@ func (h *HeurekaApp) UpdateService(service *entity.Service) (*entity.Service, er return nil, heurekaError("Internal error while updating service.") } - serviceResult, err := h.ListServices(&entity.ServiceFilter{Id: []*int64{&service.Id}}, &entity.ListOptions{}) + return h.GetService(service.Id) +} + +func (h *HeurekaApp) DeleteService(id int64) error { + l := logrus.WithFields(logrus.Fields{ + "event": "app.DeleteService", + "id": id, + }) + + err := h.database.DeleteService(id) if err != nil { l.Error(err) - return nil, heurekaError("Internal error while retrieving updated service.") + return heurekaError("Internal error while deleting service.") } - if len(serviceResult.Elements) != 1 { + return nil +} + +func (h *HeurekaApp) AddOwnerToService(serviceId, ownerId int64) (*entity.Service, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.AddOwnerToService", + "serviceId": serviceId, + "ownerId": ownerId, + }) + + err := h.database.AddOwnerToService(serviceId, ownerId) + + if err != nil { l.Error(err) - return nil, heurekaError("Multiple services found.") + return nil, heurekaError("Internal error while adding owner to service.") } - return serviceResult.Elements[0].Service, nil + return h.GetService(serviceId) } -func (h *HeurekaApp) DeleteService(id int64) error { +func (h *HeurekaApp) RemoveOwnerFromService(serviceId, ownerId int64) (*entity.Service, error) { l := logrus.WithFields(logrus.Fields{ - "event": "app.DeleteService", - "id": id, + "event": "app.RemoveOwnerFromService", + "serviceId": serviceId, + "ownerId": ownerId, }) - err := h.database.DeleteService(id) + err := h.database.RemoveOwnerFromService(serviceId, ownerId) if err != nil { l.Error(err) - return heurekaError("Internal error while deleting service.") + return nil, heurekaError("Internal error while removing owner from service.") } - return nil + return h.GetService(serviceId) +} + +func (h *HeurekaApp) AddIssueRepositoryToService(serviceId, issueRepositoryId int64, priority int64) (*entity.Service, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.AddIssueRepositoryToService", + "serviceId": serviceId, + "issueRepositoryId": issueRepositoryId, + }) + + err := h.database.AddIssueRepositoryToService(serviceId, issueRepositoryId, priority) + + if err != nil { + l.Error(err) + return nil, heurekaError("Internal error while adding issue repository to service.") + } + + return h.GetService(serviceId) +} + +func (h *HeurekaApp) RemoveIssueRepositoryFromService(serviceId, issueRepositoryId int64) (*entity.Service, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.RemoveIssueRepositoryFromService", + "serviceId": serviceId, + "issueRepositoryId": issueRepositoryId, + }) + + err := h.database.RemoveIssueRepositoryFromService(serviceId, issueRepositoryId) + + if err != nil { + l.Error(err) + return nil, heurekaError("Internal error while removing issue repository from service.") + } + + return h.GetService(serviceId) } diff --git a/internal/app/service_test.go b/internal/app/service_test.go index 38e13661..863cea89 100644 --- a/internal/app/service_test.go +++ b/internal/app/service_test.go @@ -192,6 +192,96 @@ var _ = Describe("When deleting Service", Label("app", "DeleteService"), func() filter.Id = []*int64{&id} services, err := heureka.ListServices(filter, &entity.ListOptions{}) Expect(err).To(BeNil(), "no error should be thrown") - Expect(services.Elements).To(BeEmpty(), "no error should be thrown") + Expect(services.Elements).To(BeEmpty(), "no services should be found") + }) +}) + +var _ = Describe("When modifying owner and Service", Label("app", "OwnerService"), func() { + var ( + db *mocks.MockDatabase + heureka app.Heureka + service entity.Service + owner entity.User + filter *entity.ServiceFilter + ) + + BeforeEach(func() { + db = mocks.NewMockDatabase(GinkgoT()) + service = test.NewFakeServiceEntity() + owner = test.NewFakeUserEntity() + first := 10 + var after int64 + after = 0 + filter = &entity.ServiceFilter{ + Paginated: entity.Paginated{ + First: &first, + After: &after, + }, + Id: []*int64{&service.Id}, + } + }) + + It("adds owner to service", func() { + db.On("AddOwnerToService", service.Id, owner.Id).Return(nil) + db.On("GetServices", filter).Return([]entity.Service{service}, nil) + heureka = app.NewHeurekaApp(db) + service, err := heureka.AddOwnerToService(service.Id, owner.Id) + Expect(err).To(BeNil(), "no error should be thrown") + Expect(service).NotTo(BeNil(), "service should be returned") + }) + + It("removes owner from service", func() { + db.On("RemoveOwnerFromService", service.Id, owner.Id).Return(nil) + db.On("GetServices", filter).Return([]entity.Service{service}, nil) + heureka = app.NewHeurekaApp(db) + service, err := heureka.RemoveOwnerFromService(service.Id, owner.Id) + Expect(err).To(BeNil(), "no error should be thrown") + Expect(service).NotTo(BeNil(), "service should be returned") + }) +}) + +var _ = Describe("When modifying issueRepository and Service", Label("app", "IssueRepositoryService"), func() { + var ( + db *mocks.MockDatabase + heureka app.Heureka + service entity.Service + issueRepository entity.IssueRepository + filter *entity.ServiceFilter + priority int64 + ) + + BeforeEach(func() { + db = mocks.NewMockDatabase(GinkgoT()) + service = test.NewFakeServiceEntity() + issueRepository = test.NewFakeIssueRepositoryEntity() + first := 10 + var after int64 + after = 0 + filter = &entity.ServiceFilter{ + Paginated: entity.Paginated{ + First: &first, + After: &after, + }, + Id: []*int64{&service.Id}, + } + priority = 1 + }) + + It("adds issueRepository to service", func() { + db.On("AddIssueRepositoryToService", service.Id, issueRepository.Id, priority).Return(nil) + db.On("GetServices", filter).Return([]entity.Service{service}, nil) + heureka = app.NewHeurekaApp(db) + service, err := heureka.AddIssueRepositoryToService(service.Id, issueRepository.Id, priority) + Expect(err).To(BeNil(), "no error should be thrown") + Expect(service).NotTo(BeNil(), "service should be returned") + }) + + It("removes issueRepository from service", func() { + db.On("RemoveIssueRepositoryFromService", service.Id, issueRepository.Id).Return(nil) + db.On("GetServices", filter).Return([]entity.Service{service}, nil) + heureka = app.NewHeurekaApp(db) + service, err := heureka.RemoveIssueRepositoryFromService(service.Id, issueRepository.Id) + Expect(err).To(BeNil(), "no error should be thrown") + Expect(service).NotTo(BeNil(), "service should be returned") }) }) diff --git a/internal/app/support_group.go b/internal/app/support_group.go index 6664985b..5de1481b 100644 --- a/internal/app/support_group.go +++ b/internal/app/support_group.go @@ -28,6 +28,26 @@ func (h *HeurekaApp) getSupportGroupResults(filter *entity.SupportGroupFilter) ( return supportGroupResults, nil } +func (h *HeurekaApp) GetSupportGroup(supportGroupId int64) (*entity.SupportGroup, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.GetSupportGroup", + "id": supportGroupId, + }) + supportGroupFilter := entity.SupportGroupFilter{Id: []*int64{&supportGroupId}} + supportGroups, err := h.ListSupportGroups(&supportGroupFilter, &entity.ListOptions{}) + + if err != nil { + l.Error(err) + return nil, heurekaError("Internal error while retrieving supportGroup.") + } + + if len(supportGroups.Elements) != 1 { + return nil, heurekaError(fmt.Sprintf("SupportGroup %d not found.", supportGroupId)) + } + + return supportGroups.Elements[0].SupportGroup, nil +} + func (h *HeurekaApp) ListSupportGroups(filter *entity.SupportGroupFilter, options *entity.ListOptions) (*entity.List[entity.SupportGroupResult], error) { var count int64 var pageInfo *entity.PageInfo @@ -114,34 +134,55 @@ func (h *HeurekaApp) UpdateSupportGroup(supportGroup *entity.SupportGroup) (*ent l.Error(err) return nil, heurekaError("Internal error while updating supportGroup.") } + return h.GetSupportGroup(supportGroup.Id) +} + +func (h *HeurekaApp) DeleteSupportGroup(id int64) error { + l := logrus.WithFields(logrus.Fields{ + "event": "app.DeleteSupportGroup", + "id": id, + }) - supportGroupResult, err := h.ListSupportGroups(&entity.SupportGroupFilter{Id: []*int64{&supportGroup.Id}}, &entity.ListOptions{}) + err := h.database.DeleteSupportGroup(id) if err != nil { l.Error(err) - return nil, heurekaError("Internal error while retrieving updated supportGroup.") + return heurekaError("Internal error while deleting supportGroup.") } - if len(supportGroupResult.Elements) != 1 { + return nil +} + +func (h *HeurekaApp) AddServiceToSupportGroup(supportGroupId int64, serviceId int64) (*entity.SupportGroup, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.AddServiceToSupportGroup", + "serviceId": serviceId, + "supportGroupId": supportGroupId, + }) + + err := h.database.AddServiceToSupportGroup(supportGroupId, serviceId) + + if err != nil { l.Error(err) - return nil, heurekaError("Multiple supportGroups found.") + return nil, heurekaError("Internal error while adding service to supportGroup.") } - return supportGroupResult.Elements[0].SupportGroup, nil + return h.GetSupportGroup(supportGroupId) } -func (h *HeurekaApp) DeleteSupportGroup(id int64) error { +func (h *HeurekaApp) RemoveServiceFromSupportGroup(supportGroupId int64, serviceId int64) (*entity.SupportGroup, error) { l := logrus.WithFields(logrus.Fields{ - "event": "app.DeleteSupportGroup", - "id": id, + "event": "app.RemoveServiceFromSupportGroup", + "serviceId": serviceId, + "supportGroupId": supportGroupId, }) - err := h.database.DeleteSupportGroup(id) + err := h.database.RemoveServiceFromSupportGroup(supportGroupId, serviceId) if err != nil { l.Error(err) - return heurekaError("Internal error while deleting supportGroup.") + return nil, heurekaError("Internal error while removing service from supportGroup.") } - return nil + return h.GetSupportGroup(supportGroupId) } diff --git a/internal/app/support_group_test.go b/internal/app/support_group_test.go index 66cf20a4..0509d878 100644 --- a/internal/app/support_group_test.go +++ b/internal/app/support_group_test.go @@ -191,3 +191,47 @@ var _ = Describe("When deleting SupportGroup", Label("app", "DeleteSupportGroup" Expect(supportGroups.Elements).To(BeEmpty(), "no error should be thrown") }) }) + +var _ = Describe("When modifying Service and SupportGroup", Label("app", "ServiceSupportGroup"), func() { + var ( + db *mocks.MockDatabase + heureka app.Heureka + service entity.Service + supportGroup entity.SupportGroup + filter *entity.SupportGroupFilter + ) + + BeforeEach(func() { + db = mocks.NewMockDatabase(GinkgoT()) + service = test.NewFakeServiceEntity() + supportGroup = test.NewFakeSupportGroupEntity() + first := 10 + var after int64 + after = 0 + filter = &entity.SupportGroupFilter{ + Paginated: entity.Paginated{ + First: &first, + After: &after, + }, + Id: []*int64{&supportGroup.Id}, + } + }) + + It("adds service to supportGroup", func() { + db.On("AddServiceToSupportGroup", supportGroup.Id, service.Id).Return(nil) + db.On("GetSupportGroups", filter).Return([]entity.SupportGroup{supportGroup}, nil) + heureka = app.NewHeurekaApp(db) + supportGroup, err := heureka.AddServiceToSupportGroup(supportGroup.Id, service.Id) + Expect(err).To(BeNil(), "no error should be thrown") + Expect(supportGroup).NotTo(BeNil(), "supportGroup should be returned") + }) + + It("removes service from supportGroup", func() { + db.On("RemoveServiceFromSupportGroup", supportGroup.Id, service.Id).Return(nil) + db.On("GetSupportGroups", filter).Return([]entity.SupportGroup{supportGroup}, nil) + heureka = app.NewHeurekaApp(db) + supportGroup, err := heureka.RemoveServiceFromSupportGroup(supportGroup.Id, service.Id) + Expect(err).To(BeNil(), "no error should be thrown") + Expect(supportGroup).NotTo(BeNil(), "supportGroup should be returned") + }) +}) diff --git a/internal/database/interface.go b/internal/database/interface.go index 423d4c55..725f95a6 100644 --- a/internal/database/interface.go +++ b/internal/database/interface.go @@ -48,6 +48,10 @@ type Database interface { CreateService(*entity.Service) (*entity.Service, error) UpdateService(*entity.Service) error DeleteService(int64) error + AddOwnerToService(int64, int64) error + RemoveOwnerFromService(int64, int64) error + AddIssueRepositoryToService(int64, int64, int64) error + RemoveIssueRepositoryFromService(int64, int64) error GetUsers(*entity.UserFilter) ([]entity.User, error) GetAllUserIds(*entity.UserFilter) ([]int64, error) @@ -62,6 +66,8 @@ type Database interface { CreateSupportGroup(*entity.SupportGroup) (*entity.SupportGroup, error) UpdateSupportGroup(*entity.SupportGroup) error DeleteSupportGroup(int64) error + AddServiceToSupportGroup(int64, int64) error + RemoveServiceFromSupportGroup(int64, int64) error GetComponentInstances(*entity.ComponentInstanceFilter) ([]entity.ComponentInstance, error) GetAllComponentInstanceIds(*entity.ComponentInstanceFilter) ([]int64, error) @@ -76,6 +82,8 @@ type Database interface { CreateActivity(*entity.Activity) (*entity.Activity, error) UpdateActivity(*entity.Activity) error DeleteActivity(int64) error + AddServiceToActivity(int64, int64) error + RemoveServiceFromActivity(int64, int64) error GetEvidences(*entity.EvidenceFilter) ([]entity.Evidence, error) GetAllEvidenceIds(*entity.EvidenceFilter) ([]int64, error) diff --git a/internal/database/mariadb/activity.go b/internal/database/mariadb/activity.go index 20572358..804551fa 100644 --- a/internal/database/mariadb/activity.go +++ b/internal/database/mariadb/activity.go @@ -272,3 +272,53 @@ func (s *SqlDatabase) DeleteActivity(id int64) error { return err } + +func (s *SqlDatabase) AddServiceToActivity(activityId int64, serviceId int64) error { + l := logrus.WithFields(logrus.Fields{ + "serviceId": serviceId, + "activityId": activityId, + "event": "database.AddServiceToActivity", + }) + + query := ` + INSERT INTO ActivityHasService ( + activityhasservice_service_id, + activityhasservice_activity_id + ) VALUES ( + :service_id, + :activity_id + ) + ` + + args := map[string]interface{}{ + "service_id": serviceId, + "activity_id": activityId, + } + + _, err := performExec(s, query, args, l) + + return err +} + +func (s *SqlDatabase) RemoveServiceFromActivity(activityId int64, serviceId int64) error { + l := logrus.WithFields(logrus.Fields{ + "serviceId": serviceId, + "activityId": activityId, + "event": "database.RemoveServiceFromActivity", + }) + + query := ` + DELETE FROM ActivityHasService + WHERE activityhasservice_service_id = :service_id + AND activityhasservice_activity_id = :activity_id + ` + + args := map[string]interface{}{ + "service_id": serviceId, + "activity_id": activityId, + } + + _, err := performExec(s, query, args, l) + + return err +} diff --git a/internal/database/mariadb/activity_test.go b/internal/database/mariadb/activity_test.go index 65ef0f6b..46db51d3 100644 --- a/internal/database/mariadb/activity_test.go +++ b/internal/database/mariadb/activity_test.go @@ -507,4 +507,69 @@ var _ = Describe("Activity", Label("database", "Activity"), func() { }) }) }) + When("Add Service To Activity", Label("AddServiceToActivity"), func() { + Context("and we have 10 activities in the database", func() { + var seedCollection *test.SeedCollection + var newServiceRow mariadb.ServiceRow + var newService entity.Service + var service *entity.Service + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + newServiceRow = test.NewFakeService() + newService = newServiceRow.AsService() + service, _ = db.CreateService(&newService) + }) + It("can add service correctly", func() { + activity := seedCollection.ActivityRows[0].AsActivity() + + err := db.AddServiceToActivity(activity.Id, service.Id) + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + activityFilter := &entity.ActivityFilter{ + ServiceId: []*int64{&service.Id}, + } + + a, err := db.GetActivities(activityFilter) + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + By("returning activity", func() { + Expect(len(a)).To(BeEquivalentTo(1)) + }) + }) + }) + }) + When("Remove Service From Activity", Label("RemoveServiceFromActivity"), func() { + Context("and we have 10 Activities in the database", func() { + var seedCollection *test.SeedCollection + var activityHasServiceRow mariadb.ActivityHasServiceRow + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + activityHasServiceRow = seedCollection.ActivityHasServiceRows[0] + }) + It("can remove service correctly", func() { + err := db.RemoveServiceFromActivity(activityHasServiceRow.ActivityId.Int64, activityHasServiceRow.ServiceId.Int64) + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + activityFilter := &entity.ActivityFilter{ + ServiceId: []*int64{&activityHasServiceRow.ServiceId.Int64}, + } + + activities, err := db.GetActivities(activityFilter) + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + for _, a := range activities { + Expect(a.Id).ToNot(BeEquivalentTo(activityHasServiceRow.ActivityId.Int64)) + } + }) + }) + }) }) diff --git a/internal/database/mariadb/entity.go b/internal/database/mariadb/entity.go index 52ddd929..638df461 100644 --- a/internal/database/mariadb/entity.go +++ b/internal/database/mariadb/entity.go @@ -443,7 +443,7 @@ func (bsr *BaseServiceRow) AsBaseService() entity.BaseService { return entity.BaseService{ Id: GetInt64Value(bsr.Id), Name: GetStringValue(bsr.Name), - Owner: []entity.User{}, + Owners: []entity.User{}, Activities: []entity.Activity{}, CreatedAt: GetTimeValue(bsr.CreatedAt), DeletedAt: GetTimeValue(bsr.DeletedAt), @@ -463,7 +463,7 @@ func (sr *ServiceRow) AsService() entity.Service { BaseService: entity.BaseService{ Id: GetInt64Value(sr.Id), Name: GetStringValue(sr.Name), - Owner: []entity.User{}, + Owners: []entity.User{}, Activities: []entity.Activity{}, CreatedAt: GetTimeValue(sr.BaseServiceRow.CreatedAt), DeletedAt: GetTimeValue(sr.BaseServiceRow.DeletedAt), diff --git a/internal/database/mariadb/service.go b/internal/database/mariadb/service.go index ea8fdfdb..6a5f29a7 100644 --- a/internal/database/mariadb/service.go +++ b/internal/database/mariadb/service.go @@ -318,3 +318,106 @@ func (s *SqlDatabase) DeleteService(id int64) error { return err } + +func (s *SqlDatabase) AddOwnerToService(serviceId int64, userId int64) error { + l := logrus.WithFields(logrus.Fields{ + "serviceId": serviceId, + "userId": userId, + "event": "database.AddOwnerToService", + }) + + query := ` + INSERT INTO Owner ( + owner_service_id, + owner_user_id + ) VALUES ( + :service_id, + :user_id + ) + ` + + args := map[string]interface{}{ + "service_id": serviceId, + "user_id": userId, + } + + _, err := performExec(s, query, args, l) + + return err +} + +func (s *SqlDatabase) RemoveOwnerFromService(serviceId int64, userId int64) error { + l := logrus.WithFields(logrus.Fields{ + "serviceId": serviceId, + "userId": userId, + "event": "database.RemoveOwnerFromService", + }) + + query := ` + DELETE FROM Owner + WHERE owner_service_id = :service_id + AND owner_user_id = :user_id + ` + + args := map[string]interface{}{ + "service_id": serviceId, + "user_id": userId, + } + + _, err := performExec(s, query, args, l) + + return err +} + +func (s *SqlDatabase) AddIssueRepositoryToService(serviceId int64, issueRepositoryId int64, priority int64) error { + l := logrus.WithFields(logrus.Fields{ + "serviceId": serviceId, + "issueRepositoryId": issueRepositoryId, + "event": "database.AddIssueRepositoryToService", + }) + + query := ` + INSERT INTO IssueRepositoryService ( + issuerepositoryservice_service_id, + issuerepositoryservice_issue_repository_id, + issuerepositoryservice_priority + ) VALUES ( + :service_id, + :issue_repository_id, + :priority + ) + ` + + args := map[string]interface{}{ + "service_id": serviceId, + "issue_repository_id": issueRepositoryId, + "priority": priority, + } + + _, err := performExec(s, query, args, l) + + return err +} + +func (s *SqlDatabase) RemoveIssueRepositoryFromService(serviceId int64, issueRepositoryId int64) error { + l := logrus.WithFields(logrus.Fields{ + "serviceId": serviceId, + "issueRepositoryId": issueRepositoryId, + "event": "database.RemoveIssueRepositoryFromService", + }) + + query := ` + DELETE FROM IssueRepositoryService + WHERE issuerepositoryservice_service_id = :service_id + AND issuerepositoryservice_issue_repository_id = :issue_repository_id + ` + + args := map[string]interface{}{ + "service_id": serviceId, + "issue_repository_id": issueRepositoryId, + } + + _, err := performExec(s, query, args, l) + + return err +} diff --git a/internal/database/mariadb/service_test.go b/internal/database/mariadb/service_test.go index 92423437..02a9a056 100644 --- a/internal/database/mariadb/service_test.go +++ b/internal/database/mariadb/service_test.go @@ -606,4 +606,135 @@ var _ = Describe("Service", Label("database", "Service"), func() { }) }) }) + When("Add Owner To Service", Label("AddOwnerToService"), func() { + Context("and we have 10 Services in the database", func() { + var seedCollection *test.SeedCollection + var newOwnerRow mariadb.UserRow + var newOwner entity.User + var owner *entity.User + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + newOwnerRow = test.NewFakeUser() + newOwner = newOwnerRow.AsUser() + owner, _ = db.CreateUser(&newOwner) + }) + It("can add owner correctly", func() { + service := seedCollection.ServiceRows[0].AsService() + + err := db.AddOwnerToService(service.Id, owner.Id) + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + serviceFilter := &entity.ServiceFilter{ + OwnerId: []*int64{&owner.Id}, + } + + s, err := db.GetServices(serviceFilter) + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + By("returning service", func() { + Expect(len(s)).To(BeEquivalentTo(1)) + }) + }) + }) + }) + When("Remove Owner From Service", Label("RemoveOwnerFromService"), func() { + Context("and we have 10 Services in the database", func() { + var seedCollection *test.SeedCollection + var ownerRow mariadb.OwnerRow + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + ownerRow = seedCollection.OwnerRows[0] + }) + It("can remove owner correctly", func() { + err := db.RemoveOwnerFromService(ownerRow.ServiceId.Int64, ownerRow.UserId.Int64) + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + serviceFilter := &entity.ServiceFilter{ + OwnerId: []*int64{&ownerRow.UserId.Int64}, + } + + services, err := db.GetServices(serviceFilter) + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + for _, s := range services { + Expect(s.Id).ToNot(BeEquivalentTo(ownerRow.ServiceId.Int64)) + } + }) + }) + }) + When("Add Issue Repository To Service", Label("AddIssueRepositoryToService"), func() { + Context("and we have 10 Services in the database", func() { + var seedCollection *test.SeedCollection + var newIssueRepositoryRow mariadb.IssueRepositoryRow + var newIssueRepository entity.IssueRepository + var issueRepository *entity.IssueRepository + var priority int64 = 1 + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + newIssueRepositoryRow = test.NewFakeIssueRepository() + newIssueRepository = newIssueRepositoryRow.AsIssueRepository() + issueRepository, _ = db.CreateIssueRepository(&newIssueRepository) + }) + It("can add issue repository correctly", func() { + service := seedCollection.ServiceRows[0].AsService() + + err := db.AddIssueRepositoryToService(service.Id, issueRepository.Id, priority) + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + serviceFilter := &entity.ServiceFilter{ + IssueRepositoryId: []*int64{&issueRepository.Id}, + } + + s, err := db.GetServices(serviceFilter) + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + By("returning service", func() { + Expect(len(s)).To(BeEquivalentTo(1)) + }) + }) + }) + }) + When("Remove Issue Repository From Service", Label("RemoveIssueRepositoryFromService"), func() { + Context("and we have 10 Services in the database", func() { + var seedCollection *test.SeedCollection + var issueRepositoryServiceRow mariadb.IssueRepositoryServiceRow + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + issueRepositoryServiceRow = seedCollection.IssueRepositoryServiceRows[0] + }) + It("can remove issue repository correctly", func() { + err := db.RemoveIssueRepositoryFromService(issueRepositoryServiceRow.ServiceId.Int64, issueRepositoryServiceRow.IssueRepositoryId.Int64) + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + serviceFilter := &entity.ServiceFilter{ + IssueRepositoryId: []*int64{&issueRepositoryServiceRow.IssueRepositoryId.Int64}, + } + + services, err := db.GetServices(serviceFilter) + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + for _, s := range services { + Expect(s.Id).ToNot(BeEquivalentTo(issueRepositoryServiceRow.ServiceId.Int64)) + } + }) + }) + }) }) diff --git a/internal/database/mariadb/support_group.go b/internal/database/mariadb/support_group.go index a7f67b6c..3b718fb3 100644 --- a/internal/database/mariadb/support_group.go +++ b/internal/database/mariadb/support_group.go @@ -270,3 +270,53 @@ func (s *SqlDatabase) DeleteSupportGroup(id int64) error { return err } + +func (s *SqlDatabase) AddServiceToSupportGroup(supportGroupId int64, serviceId int64) error { + l := logrus.WithFields(logrus.Fields{ + "serviceId": serviceId, + "supportGroupId": supportGroupId, + "event": "database.AddServiceToSupportGroup", + }) + + query := ` + INSERT INTO SupportGroupService ( + supportgroupservice_service_id, + supportgroupservice_support_group_id + ) VALUES ( + :service_id, + :support_group_id + ) + ` + + args := map[string]interface{}{ + "service_id": serviceId, + "support_group_id": supportGroupId, + } + + _, err := performExec(s, query, args, l) + + return err +} + +func (s *SqlDatabase) RemoveServiceFromSupportGroup(supportGroupId int64, serviceId int64) error { + l := logrus.WithFields(logrus.Fields{ + "serviceId": serviceId, + "supportGroupId": supportGroupId, + "event": "database.RemoveServiceFromSupportGroup", + }) + + query := ` + DELETE FROM SupportGroupService + WHERE supportgroupservice_service_id = :service_id + AND supportgroupservice_support_group_id = :support_group_id + ` + + args := map[string]interface{}{ + "service_id": serviceId, + "support_group_id": supportGroupId, + } + + _, err := performExec(s, query, args, l) + + return err +} diff --git a/internal/database/mariadb/support_group_test.go b/internal/database/mariadb/support_group_test.go index af867ac0..d908c670 100644 --- a/internal/database/mariadb/support_group_test.go +++ b/internal/database/mariadb/support_group_test.go @@ -408,4 +408,69 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { }) }) }) + When("Add Service To SupportGroup", Label("AddServiceToSupportGroup"), func() { + Context("and we have 10 SupportGroups in the database", func() { + var seedCollection *test.SeedCollection + var newServiceRow mariadb.ServiceRow + var newService entity.Service + var service *entity.Service + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + newServiceRow = test.NewFakeService() + newService = newServiceRow.AsService() + service, _ = db.CreateService(&newService) + }) + It("can add service correctly", func() { + supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup() + + err := db.AddServiceToSupportGroup(supportGroup.Id, service.Id) + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + supportGroupFilter := &entity.SupportGroupFilter{ + ServiceId: []*int64{&service.Id}, + } + + sg, err := db.GetSupportGroups(supportGroupFilter) + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + By("returning supportGroup", func() { + Expect(len(sg)).To(BeEquivalentTo(1)) + }) + }) + }) + }) + When("Remove Service From SupportGroup", Label("RemoveServiceFromSupportGroup"), func() { + Context("and we have 10 SupportGroups in the database", func() { + var seedCollection *test.SeedCollection + var supportGroupServiceRow mariadb.SupportGroupServiceRow + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + supportGroupServiceRow = seedCollection.SupportGroupServiceRows[0] + }) + It("can remove service correctly", func() { + err := db.RemoveServiceFromSupportGroup(supportGroupServiceRow.SupportGroupId.Int64, supportGroupServiceRow.ServiceId.Int64) + + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + supportGroupFilter := &entity.SupportGroupFilter{ + ServiceId: []*int64{&supportGroupServiceRow.ServiceId.Int64}, + } + + supportGroups, err := db.GetSupportGroups(supportGroupFilter) + By("throwing no error", func() { + Expect(err).To(BeNil()) + }) + + for _, sg := range supportGroups { + Expect(sg.Id).ToNot(BeEquivalentTo(supportGroupServiceRow.SupportGroupId.Int64)) + } + }) + }) + }) }) diff --git a/internal/e2e/activity_query_test.go b/internal/e2e/activity_query_test.go index f081132b..8b56807b 100644 --- a/internal/e2e/activity_query_test.go +++ b/internal/e2e/activity_query_test.go @@ -16,8 +16,10 @@ import ( "github.com/machinebox/graphql" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/samber/lo" "github.com/sirupsen/logrus" "github.wdf.sap.corp/cc/heureka/internal/api/graphql/graph/model" + "github.wdf.sap.corp/cc/heureka/internal/database/mariadb" "github.wdf.sap.corp/cc/heureka/internal/database/mariadb/test" "github.wdf.sap.corp/cc/heureka/internal/server" ) @@ -369,3 +371,118 @@ var _ = Describe("Deleting Activity via API", Label("e2e", "Activities"), func() }) }) }) + +var _ = Describe("Modifying Services of Activity via API", Label("e2e", "ServiceActivity"), func() { + + var seeder *test.DatabaseSeeder + var s *server.Server + var cfg util.Config + + BeforeEach(func() { + var err error + _ = dbm.NewTestSchema() + seeder, err = test.NewDatabaseSeeder(dbm.DbConfig()) + Expect(err).To(BeNil(), "Database Seeder Setup should work") + + cfg = dbm.DbConfig() + cfg.Port = util2.GetRandomFreePort() + s = server.NewServer(cfg) + + s.NonBlockingStart() + }) + + AfterEach(func() { + s.BlockingStop() + }) + + When("the database has 10 entries", func() { + var seedCollection *test.SeedCollection + + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + }) + + Context("and a mutation query is performed", func() { + It("adds service to activity", Label("addService.graphql"), func() { + // create a queryCollection (safe to share across requests) + client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) + + //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? + b, err := os.ReadFile("../api/graphql/graph/queryCollection/activity/addService.graphql") + + Expect(err).To(BeNil()) + str := string(b) + req := graphql.NewRequest(str) + + activity := seedCollection.ActivityRows[0].AsActivity() + serviceIds := lo.FilterMap(seedCollection.ActivityHasServiceRows, func(row mariadb.ActivityHasServiceRow, _ int) (int64, bool) { + if row.ActivityId.Int64 == activity.Id { + return row.ServiceId.Int64, true + } + return 0, false + }) + + serviceRow, _ := lo.Find(seedCollection.ServiceRows, func(row mariadb.BaseServiceRow) bool { + return !lo.Contains(serviceIds, row.Id.Int64) + }) + + req.Var("activityId", fmt.Sprintf("%d", activity.Id)) + req.Var("serviceId", fmt.Sprintf("%d", serviceRow.Id.Int64)) + + req.Header.Set("Cache-Control", "no-cache") + ctx := context.Background() + + var respData struct { + Activity model.Activity `json:"addServiceToActivity"` + } + if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { + logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") + } + + _, found := lo.Find(respData.Activity.Services.Edges, func(edge *model.ServiceEdge) bool { + return edge.Node.ID == fmt.Sprintf("%d", serviceRow.Id.Int64) + }) + + Expect(respData.Activity.ID).To(Equal(fmt.Sprintf("%d", activity.Id))) + Expect(found).To(BeTrue()) + }) + It("removes service from activity", Label("removeService.graphql"), func() { + // create a queryCollection (safe to share across requests) + client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) + + //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? + b, err := os.ReadFile("../api/graphql/graph/queryCollection/activity/removeService.graphql") + + Expect(err).To(BeNil()) + str := string(b) + req := graphql.NewRequest(str) + + activity := seedCollection.ActivityRows[0].AsActivity() + + serviceRow, _ := lo.Find(seedCollection.ActivityHasServiceRows, func(row mariadb.ActivityHasServiceRow) bool { + return row.ActivityId.Int64 == activity.Id + }) + + req.Var("activityId", fmt.Sprintf("%d", activity.Id)) + req.Var("serviceId", fmt.Sprintf("%d", serviceRow.ServiceId.Int64)) + + req.Header.Set("Cache-Control", "no-cache") + ctx := context.Background() + + var respData struct { + Activity model.Activity `json:"removeServiceFromActivity"` + } + if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { + logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") + } + + _, found := lo.Find(respData.Activity.Services.Edges, func(edge *model.ServiceEdge) bool { + return edge.Node.ID == fmt.Sprintf("%d", serviceRow.ServiceId.Int64) + }) + + Expect(respData.Activity.ID).To(Equal(fmt.Sprintf("%d", activity.Id))) + Expect(found).To(BeFalse()) + }) + }) + }) +}) diff --git a/internal/e2e/service_query_test.go b/internal/e2e/service_query_test.go index e4523d7f..e82553ac 100644 --- a/internal/e2e/service_query_test.go +++ b/internal/e2e/service_query_test.go @@ -414,3 +414,236 @@ var _ = Describe("Deleting Service via API", Label("e2e", "Services"), func() { }) }) }) + +var _ = Describe("Modifying Owner of Service via API", Label("e2e", "Services"), func() { + + var seeder *test.DatabaseSeeder + var s *server.Server + var cfg util.Config + + BeforeEach(func() { + var err error + _ = dbm.NewTestSchema() + seeder, err = test.NewDatabaseSeeder(dbm.DbConfig()) + Expect(err).To(BeNil(), "Database Seeder Setup should work") + + cfg = dbm.DbConfig() + cfg.Port = util2.GetRandomFreePort() + s = server.NewServer(cfg) + + s.NonBlockingStart() + }) + + AfterEach(func() { + s.BlockingStop() + }) + + When("the database has 10 entries", func() { + var seedCollection *test.SeedCollection + + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + }) + + Context("and a mutation query is performed", func() { + It("adds owner to service", Label("addOwner.graphql"), func() { + // create a queryCollection (safe to share across requests) + client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) + + //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? + b, err := os.ReadFile("../api/graphql/graph/queryCollection/service/addOwner.graphql") + + Expect(err).To(BeNil()) + str := string(b) + req := graphql.NewRequest(str) + + service := seedCollection.ServiceRows[0].AsService() + ownerIds := lo.FilterMap(seedCollection.OwnerRows, func(row mariadb.OwnerRow, _ int) (int64, bool) { + if row.ServiceId.Int64 == service.Id { + return row.UserId.Int64, true + } + return 0, false + }) + + ownerRow, _ := lo.Find(seedCollection.UserRows, func(row mariadb.UserRow) bool { + return !lo.Contains(ownerIds, row.Id.Int64) + }) + + req.Var("serviceId", fmt.Sprintf("%d", service.Id)) + req.Var("userId", fmt.Sprintf("%d", ownerRow.Id.Int64)) + + req.Header.Set("Cache-Control", "no-cache") + ctx := context.Background() + + var respData struct { + Service model.Service `json:"addOwnerToService"` + } + if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { + logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") + } + + _, found := lo.Find(respData.Service.Owners.Edges, func(edge *model.UserEdge) bool { + return edge.Node.ID == fmt.Sprintf("%d", ownerRow.Id.Int64) + }) + + Expect(respData.Service.ID).To(Equal(fmt.Sprintf("%d", service.Id))) + Expect(found).To(BeTrue()) + }) + It("removes owner from service", Label("removeOwner.graphql"), func() { + // create a queryCollection (safe to share across requests) + client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) + + //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? + b, err := os.ReadFile("../api/graphql/graph/queryCollection/service/removeOwner.graphql") + + Expect(err).To(BeNil()) + str := string(b) + req := graphql.NewRequest(str) + + service := seedCollection.ServiceRows[0].AsService() + + ownerRow, _ := lo.Find(seedCollection.OwnerRows, func(row mariadb.OwnerRow) bool { + return row.ServiceId.Int64 == service.Id + }) + + req.Var("serviceId", fmt.Sprintf("%d", service.Id)) + req.Var("userId", fmt.Sprintf("%d", ownerRow.UserId.Int64)) + + req.Header.Set("Cache-Control", "no-cache") + ctx := context.Background() + + var respData struct { + Service model.Service `json:"removeOwnerFromService"` + } + if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { + logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") + } + + _, found := lo.Find(respData.Service.Owners.Edges, func(edge *model.UserEdge) bool { + return edge.Node.ID == fmt.Sprintf("%d", ownerRow.UserId.Int64) + }) + + Expect(respData.Service.ID).To(Equal(fmt.Sprintf("%d", service.Id))) + Expect(found).To(BeFalse()) + }) + }) + }) +}) + +var _ = Describe("Modifying IssueRepository of Service via API", Label("e2e", "Services"), func() { + + var seeder *test.DatabaseSeeder + var s *server.Server + var cfg util.Config + var priority int64 + + BeforeEach(func() { + var err error + _ = dbm.NewTestSchema() + seeder, err = test.NewDatabaseSeeder(dbm.DbConfig()) + Expect(err).To(BeNil(), "Database Seeder Setup should work") + + cfg = dbm.DbConfig() + cfg.Port = util2.GetRandomFreePort() + s = server.NewServer(cfg) + + s.NonBlockingStart() + }) + + AfterEach(func() { + s.BlockingStop() + }) + + When("the database has 10 entries", func() { + var seedCollection *test.SeedCollection + + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + priority = 1 + }) + + Context("and a mutation query is performed", func() { + It("adds issueRepository to service", Label("addIssueRepository.graphql"), func() { + // create a queryCollection (safe to share across requests) + client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) + + //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? + b, err := os.ReadFile("../api/graphql/graph/queryCollection/service/addIssueRepository.graphql") + + Expect(err).To(BeNil()) + str := string(b) + req := graphql.NewRequest(str) + + service := seedCollection.ServiceRows[0].AsService() + issueRepositoryIds := lo.FilterMap(seedCollection.IssueRepositoryServiceRows, func(row mariadb.IssueRepositoryServiceRow, _ int) (int64, bool) { + if row.ServiceId.Int64 == service.Id { + return row.IssueRepositoryId.Int64, true + } + return 0, false + }) + + issueRepositoryRow, _ := lo.Find(seedCollection.IssueRepositoryRows, func(row mariadb.BaseIssueRepositoryRow) bool { + return !lo.Contains(issueRepositoryIds, row.Id.Int64) + }) + + req.Var("serviceId", fmt.Sprintf("%d", service.Id)) + req.Var("issueRepositoryId", fmt.Sprintf("%d", issueRepositoryRow.Id.Int64)) + req.Var("priority", fmt.Sprintf("%d", priority)) + + req.Header.Set("Cache-Control", "no-cache") + ctx := context.Background() + + var respData struct { + Service model.Service `json:"addIssueRepositoryToService"` + } + if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { + logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") + } + + _, found := lo.Find(respData.Service.IssueRepositories.Edges, func(edge *model.IssueRepositoryEdge) bool { + return edge.Node.ID == fmt.Sprintf("%d", issueRepositoryRow.Id.Int64) + }) + + Expect(respData.Service.ID).To(Equal(fmt.Sprintf("%d", service.Id))) + Expect(found).To(BeTrue()) + }) + It("removes issueRepository from service", Label("removeIssueRepository.graphql"), func() { + // create a queryCollection (safe to share across requests) + client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) + + //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? + b, err := os.ReadFile("../api/graphql/graph/queryCollection/service/removeIssueRepository.graphql") + + Expect(err).To(BeNil()) + str := string(b) + req := graphql.NewRequest(str) + + service := seedCollection.ServiceRows[0].AsService() + + issueRepositoryRow, _ := lo.Find(seedCollection.IssueRepositoryServiceRows, func(row mariadb.IssueRepositoryServiceRow) bool { + return row.ServiceId.Int64 == service.Id + }) + + req.Var("serviceId", fmt.Sprintf("%d", service.Id)) + req.Var("issueRepositoryId", fmt.Sprintf("%d", issueRepositoryRow.IssueRepositoryId.Int64)) + + req.Header.Set("Cache-Control", "no-cache") + ctx := context.Background() + + var respData struct { + Service model.Service `json:"removeIssueRepositoryFromService"` + } + if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { + logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") + } + + _, found := lo.Find(respData.Service.IssueRepositories.Edges, func(edge *model.IssueRepositoryEdge) bool { + return edge.Node.ID == fmt.Sprintf("%d", issueRepositoryRow.IssueRepositoryId.Int64) + }) + + Expect(respData.Service.ID).To(Equal(fmt.Sprintf("%d", service.Id))) + Expect(found).To(BeFalse()) + }) + }) + }) +}) diff --git a/internal/e2e/support_group_query_test.go b/internal/e2e/support_group_query_test.go index 65e021f9..9dfae409 100644 --- a/internal/e2e/support_group_query_test.go +++ b/internal/e2e/support_group_query_test.go @@ -403,3 +403,118 @@ var _ = Describe("Deleting SupportGroup via API", Label("e2e", "SupportGroups"), }) }) }) + +var _ = Describe("Modifying Services of SupportGroup via API", Label("e2e", "SupportGroups"), func() { + + var seeder *test.DatabaseSeeder + var s *server.Server + var cfg util.Config + + BeforeEach(func() { + var err error + _ = dbm.NewTestSchema() + seeder, err = test.NewDatabaseSeeder(dbm.DbConfig()) + Expect(err).To(BeNil(), "Database Seeder Setup should work") + + cfg = dbm.DbConfig() + cfg.Port = util2.GetRandomFreePort() + s = server.NewServer(cfg) + + s.NonBlockingStart() + }) + + AfterEach(func() { + s.BlockingStop() + }) + + When("the database has 10 entries", func() { + var seedCollection *test.SeedCollection + + BeforeEach(func() { + seedCollection = seeder.SeedDbWithNFakeData(10) + }) + + Context("and a mutation query is performed", func() { + It("adds service to supportGroup", Label("addService.graphql"), func() { + // create a queryCollection (safe to share across requests) + client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) + + //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? + b, err := os.ReadFile("../api/graphql/graph/queryCollection/supportGroup/addService.graphql") + + Expect(err).To(BeNil()) + str := string(b) + req := graphql.NewRequest(str) + + supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup() + serviceIds := lo.FilterMap(seedCollection.SupportGroupServiceRows, func(row mariadb.SupportGroupServiceRow, _ int) (int64, bool) { + if row.SupportGroupId.Int64 == supportGroup.Id { + return row.ServiceId.Int64, true + } + return 0, false + }) + + serviceRow, _ := lo.Find(seedCollection.ServiceRows, func(row mariadb.BaseServiceRow) bool { + return !lo.Contains(serviceIds, row.Id.Int64) + }) + + req.Var("supportGroupId", fmt.Sprintf("%d", supportGroup.Id)) + req.Var("serviceId", fmt.Sprintf("%d", serviceRow.Id.Int64)) + + req.Header.Set("Cache-Control", "no-cache") + ctx := context.Background() + + var respData struct { + SupportGroup model.SupportGroup `json:"addServiceToSupportGroup"` + } + if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { + logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") + } + + _, found := lo.Find(respData.SupportGroup.Services.Edges, func(edge *model.ServiceEdge) bool { + return edge.Node.ID == fmt.Sprintf("%d", serviceRow.Id.Int64) + }) + + Expect(respData.SupportGroup.ID).To(Equal(fmt.Sprintf("%d", supportGroup.Id))) + Expect(found).To(BeTrue()) + }) + It("removes service from supportGroup", Label("removeService.graphql"), func() { + // create a queryCollection (safe to share across requests) + client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) + + //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? + b, err := os.ReadFile("../api/graphql/graph/queryCollection/supportGroup/removeService.graphql") + + Expect(err).To(BeNil()) + str := string(b) + req := graphql.NewRequest(str) + + supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup() + + serviceRow, _ := lo.Find(seedCollection.SupportGroupServiceRows, func(row mariadb.SupportGroupServiceRow) bool { + return row.SupportGroupId.Int64 == supportGroup.Id + }) + + req.Var("supportGroupId", fmt.Sprintf("%d", supportGroup.Id)) + req.Var("serviceId", fmt.Sprintf("%d", serviceRow.ServiceId.Int64)) + + req.Header.Set("Cache-Control", "no-cache") + ctx := context.Background() + + var respData struct { + SupportGroup model.SupportGroup `json:"removeServiceFromSupportGroup"` + } + if err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) }); err != nil { + logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") + } + + _, found := lo.Find(respData.SupportGroup.Services.Edges, func(edge *model.ServiceEdge) bool { + return edge.Node.ID == fmt.Sprintf("%d", serviceRow.ServiceId.Int64) + }) + + Expect(respData.SupportGroup.ID).To(Equal(fmt.Sprintf("%d", supportGroup.Id))) + Expect(found).To(BeFalse()) + }) + }) + }) +}) diff --git a/internal/entity/service.go b/internal/entity/service.go index f3851da6..d163014a 100644 --- a/internal/entity/service.go +++ b/internal/entity/service.go @@ -10,7 +10,7 @@ type BaseService struct { Name string `json:"name"` SupportGroup *SupportGroup `json:"support_group,omitempty"` SupportGroupId int64 `db:"service_support_group_id"` - Owner []User `json:"owners,omitempty"` + Owners []User `json:"owners,omitempty"` Activities []Activity `json:"activities,omitempty"` Priority int64 `json:"priority"` CreatedAt time.Time `json:"created_at"` diff --git a/internal/entity/test/service.go b/internal/entity/test/service.go index 02f4ded8..657a3975 100644 --- a/internal/entity/test/service.go +++ b/internal/entity/test/service.go @@ -15,7 +15,7 @@ func NewFakeServiceEntity() entity.Service { Name: gofakeit.Name(), SupportGroup: nil, Activities: nil, - Owner: nil, + Owners: nil, CreatedAt: gofakeit.Date(), DeletedAt: gofakeit.Date(), UpdatedAt: gofakeit.Date(), diff --git a/internal/mocks/mock_Database.go b/internal/mocks/mock_Database.go index 34b46c25..b116dff4 100644 --- a/internal/mocks/mock_Database.go +++ b/internal/mocks/mock_Database.go @@ -23,6 +23,195 @@ func (_m *MockDatabase) EXPECT() *MockDatabase_Expecter { return &MockDatabase_Expecter{mock: &_m.Mock} } +// AddIssueRepositoryToService provides a mock function with given fields: _a0, _a1, _a2 +func (_m *MockDatabase) AddIssueRepositoryToService(_a0 int64, _a1 int64, _a2 int64) error { + ret := _m.Called(_a0, _a1, _a2) + + if len(ret) == 0 { + panic("no return value specified for AddIssueRepositoryToService") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64, int64) error); ok { + r0 = rf(_a0, _a1, _a2) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDatabase_AddIssueRepositoryToService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddIssueRepositoryToService' +type MockDatabase_AddIssueRepositoryToService_Call struct { + *mock.Call +} + +// AddIssueRepositoryToService is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +// - _a2 int64 +func (_e *MockDatabase_Expecter) AddIssueRepositoryToService(_a0 interface{}, _a1 interface{}, _a2 interface{}) *MockDatabase_AddIssueRepositoryToService_Call { + return &MockDatabase_AddIssueRepositoryToService_Call{Call: _e.mock.On("AddIssueRepositoryToService", _a0, _a1, _a2)} +} + +func (_c *MockDatabase_AddIssueRepositoryToService_Call) Run(run func(_a0 int64, _a1 int64, _a2 int64)) *MockDatabase_AddIssueRepositoryToService_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64), args[2].(int64)) + }) + return _c +} + +func (_c *MockDatabase_AddIssueRepositoryToService_Call) Return(_a0 error) *MockDatabase_AddIssueRepositoryToService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDatabase_AddIssueRepositoryToService_Call) RunAndReturn(run func(int64, int64, int64) error) *MockDatabase_AddIssueRepositoryToService_Call { + _c.Call.Return(run) + return _c +} + +// AddOwnerToService provides a mock function with given fields: _a0, _a1 +func (_m *MockDatabase) AddOwnerToService(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for AddOwnerToService") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDatabase_AddOwnerToService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddOwnerToService' +type MockDatabase_AddOwnerToService_Call struct { + *mock.Call +} + +// AddOwnerToService is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockDatabase_Expecter) AddOwnerToService(_a0 interface{}, _a1 interface{}) *MockDatabase_AddOwnerToService_Call { + return &MockDatabase_AddOwnerToService_Call{Call: _e.mock.On("AddOwnerToService", _a0, _a1)} +} + +func (_c *MockDatabase_AddOwnerToService_Call) Run(run func(_a0 int64, _a1 int64)) *MockDatabase_AddOwnerToService_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockDatabase_AddOwnerToService_Call) Return(_a0 error) *MockDatabase_AddOwnerToService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDatabase_AddOwnerToService_Call) RunAndReturn(run func(int64, int64) error) *MockDatabase_AddOwnerToService_Call { + _c.Call.Return(run) + return _c +} + +// AddServiceToActivity provides a mock function with given fields: _a0, _a1 +func (_m *MockDatabase) AddServiceToActivity(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for AddServiceToActivity") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDatabase_AddServiceToActivity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddServiceToActivity' +type MockDatabase_AddServiceToActivity_Call struct { + *mock.Call +} + +// AddServiceToActivity is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockDatabase_Expecter) AddServiceToActivity(_a0 interface{}, _a1 interface{}) *MockDatabase_AddServiceToActivity_Call { + return &MockDatabase_AddServiceToActivity_Call{Call: _e.mock.On("AddServiceToActivity", _a0, _a1)} +} + +func (_c *MockDatabase_AddServiceToActivity_Call) Run(run func(_a0 int64, _a1 int64)) *MockDatabase_AddServiceToActivity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockDatabase_AddServiceToActivity_Call) Return(_a0 error) *MockDatabase_AddServiceToActivity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDatabase_AddServiceToActivity_Call) RunAndReturn(run func(int64, int64) error) *MockDatabase_AddServiceToActivity_Call { + _c.Call.Return(run) + return _c +} + +// AddServiceToSupportGroup provides a mock function with given fields: _a0, _a1 +func (_m *MockDatabase) AddServiceToSupportGroup(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for AddServiceToSupportGroup") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDatabase_AddServiceToSupportGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddServiceToSupportGroup' +type MockDatabase_AddServiceToSupportGroup_Call struct { + *mock.Call +} + +// AddServiceToSupportGroup is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockDatabase_Expecter) AddServiceToSupportGroup(_a0 interface{}, _a1 interface{}) *MockDatabase_AddServiceToSupportGroup_Call { + return &MockDatabase_AddServiceToSupportGroup_Call{Call: _e.mock.On("AddServiceToSupportGroup", _a0, _a1)} +} + +func (_c *MockDatabase_AddServiceToSupportGroup_Call) Run(run func(_a0 int64, _a1 int64)) *MockDatabase_AddServiceToSupportGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockDatabase_AddServiceToSupportGroup_Call) Return(_a0 error) *MockDatabase_AddServiceToSupportGroup_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDatabase_AddServiceToSupportGroup_Call) RunAndReturn(run func(int64, int64) error) *MockDatabase_AddServiceToSupportGroup_Call { + _c.Call.Return(run) + return _c +} + // CloseConnection provides a mock function with given fields: func (_m *MockDatabase) CloseConnection() error { ret := _m.Called() @@ -3714,6 +3903,194 @@ func (_c *MockDatabase_GetUsers_Call) RunAndReturn(run func(*entity.UserFilter) return _c } +// RemoveIssueRepositoryFromService provides a mock function with given fields: _a0, _a1 +func (_m *MockDatabase) RemoveIssueRepositoryFromService(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for RemoveIssueRepositoryFromService") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDatabase_RemoveIssueRepositoryFromService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveIssueRepositoryFromService' +type MockDatabase_RemoveIssueRepositoryFromService_Call struct { + *mock.Call +} + +// RemoveIssueRepositoryFromService is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockDatabase_Expecter) RemoveIssueRepositoryFromService(_a0 interface{}, _a1 interface{}) *MockDatabase_RemoveIssueRepositoryFromService_Call { + return &MockDatabase_RemoveIssueRepositoryFromService_Call{Call: _e.mock.On("RemoveIssueRepositoryFromService", _a0, _a1)} +} + +func (_c *MockDatabase_RemoveIssueRepositoryFromService_Call) Run(run func(_a0 int64, _a1 int64)) *MockDatabase_RemoveIssueRepositoryFromService_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockDatabase_RemoveIssueRepositoryFromService_Call) Return(_a0 error) *MockDatabase_RemoveIssueRepositoryFromService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDatabase_RemoveIssueRepositoryFromService_Call) RunAndReturn(run func(int64, int64) error) *MockDatabase_RemoveIssueRepositoryFromService_Call { + _c.Call.Return(run) + return _c +} + +// RemoveOwnerFromService provides a mock function with given fields: _a0, _a1 +func (_m *MockDatabase) RemoveOwnerFromService(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for RemoveOwnerFromService") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDatabase_RemoveOwnerFromService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveOwnerFromService' +type MockDatabase_RemoveOwnerFromService_Call struct { + *mock.Call +} + +// RemoveOwnerFromService is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockDatabase_Expecter) RemoveOwnerFromService(_a0 interface{}, _a1 interface{}) *MockDatabase_RemoveOwnerFromService_Call { + return &MockDatabase_RemoveOwnerFromService_Call{Call: _e.mock.On("RemoveOwnerFromService", _a0, _a1)} +} + +func (_c *MockDatabase_RemoveOwnerFromService_Call) Run(run func(_a0 int64, _a1 int64)) *MockDatabase_RemoveOwnerFromService_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockDatabase_RemoveOwnerFromService_Call) Return(_a0 error) *MockDatabase_RemoveOwnerFromService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDatabase_RemoveOwnerFromService_Call) RunAndReturn(run func(int64, int64) error) *MockDatabase_RemoveOwnerFromService_Call { + _c.Call.Return(run) + return _c +} + +// RemoveServiceFromActivity provides a mock function with given fields: _a0, _a1 +func (_m *MockDatabase) RemoveServiceFromActivity(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for RemoveServiceFromActivity") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDatabase_RemoveServiceFromActivity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveServiceFromActivity' +type MockDatabase_RemoveServiceFromActivity_Call struct { + *mock.Call +} + +// RemoveServiceFromActivity is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockDatabase_Expecter) RemoveServiceFromActivity(_a0 interface{}, _a1 interface{}) *MockDatabase_RemoveServiceFromActivity_Call { + return &MockDatabase_RemoveServiceFromActivity_Call{Call: _e.mock.On("RemoveServiceFromActivity", _a0, _a1)} +} + +func (_c *MockDatabase_RemoveServiceFromActivity_Call) Run(run func(_a0 int64, _a1 int64)) *MockDatabase_RemoveServiceFromActivity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockDatabase_RemoveServiceFromActivity_Call) Return(_a0 error) *MockDatabase_RemoveServiceFromActivity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDatabase_RemoveServiceFromActivity_Call) RunAndReturn(run func(int64, int64) error) *MockDatabase_RemoveServiceFromActivity_Call { + _c.Call.Return(run) + return _c +} + +// RemoveServiceFromSupportGroup provides a mock function with given fields: _a0, _a1 +func (_m *MockDatabase) RemoveServiceFromSupportGroup(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for RemoveServiceFromSupportGroup") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDatabase_RemoveServiceFromSupportGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveServiceFromSupportGroup' +type MockDatabase_RemoveServiceFromSupportGroup_Call struct { + *mock.Call +} + +// RemoveServiceFromSupportGroup is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockDatabase_Expecter) RemoveServiceFromSupportGroup(_a0 interface{}, _a1 interface{}) *MockDatabase_RemoveServiceFromSupportGroup_Call { + return &MockDatabase_RemoveServiceFromSupportGroup_Call{Call: _e.mock.On("RemoveServiceFromSupportGroup", _a0, _a1)} +} + +func (_c *MockDatabase_RemoveServiceFromSupportGroup_Call) Run(run func(_a0 int64, _a1 int64)) *MockDatabase_RemoveServiceFromSupportGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockDatabase_RemoveServiceFromSupportGroup_Call) Return(_a0 error) *MockDatabase_RemoveServiceFromSupportGroup_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDatabase_RemoveServiceFromSupportGroup_Call) RunAndReturn(run func(int64, int64) error) *MockDatabase_RemoveServiceFromSupportGroup_Call { + _c.Call.Return(run) + return _c +} + // UpdateActivity provides a mock function with given fields: _a0 func (_m *MockDatabase) UpdateActivity(_a0 *entity.Activity) error { ret := _m.Called(_a0) diff --git a/internal/mocks/mock_Heureka.go b/internal/mocks/mock_Heureka.go index 8a525c21..fb804c8c 100644 --- a/internal/mocks/mock_Heureka.go +++ b/internal/mocks/mock_Heureka.go @@ -23,6 +23,100 @@ func (_m *MockHeureka) EXPECT() *MockHeureka_Expecter { return &MockHeureka_Expecter{mock: &_m.Mock} } +// AddIssueRepositoryToService provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) AddIssueRepositoryToService(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for AddIssueRepositoryToService") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockHeureka_AddIssueRepositoryToService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddIssueRepositoryToService' +type MockHeureka_AddIssueRepositoryToService_Call struct { + *mock.Call +} + +// AddIssueRepositoryToService is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockHeureka_Expecter) AddIssueRepositoryToService(_a0 interface{}, _a1 interface{}) *MockHeureka_AddIssueRepositoryToService_Call { + return &MockHeureka_AddIssueRepositoryToService_Call{Call: _e.mock.On("AddIssueRepositoryToService", _a0, _a1)} +} + +func (_c *MockHeureka_AddIssueRepositoryToService_Call) Run(run func(_a0 int64, _a1 int64)) *MockHeureka_AddIssueRepositoryToService_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockHeureka_AddIssueRepositoryToService_Call) Return(_a0 error) *MockHeureka_AddIssueRepositoryToService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHeureka_AddIssueRepositoryToService_Call) RunAndReturn(run func(int64, int64) error) *MockHeureka_AddIssueRepositoryToService_Call { + _c.Call.Return(run) + return _c +} + +// AddOwnerToService provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) AddOwnerToService(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for AddOwnerToService") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockHeureka_AddOwnerToService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddOwnerToService' +type MockHeureka_AddOwnerToService_Call struct { + *mock.Call +} + +// AddOwnerToService is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockHeureka_Expecter) AddOwnerToService(_a0 interface{}, _a1 interface{}) *MockHeureka_AddOwnerToService_Call { + return &MockHeureka_AddOwnerToService_Call{Call: _e.mock.On("AddOwnerToService", _a0, _a1)} +} + +func (_c *MockHeureka_AddOwnerToService_Call) Run(run func(_a0 int64, _a1 int64)) *MockHeureka_AddOwnerToService_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockHeureka_AddOwnerToService_Call) Return(_a0 error) *MockHeureka_AddOwnerToService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHeureka_AddOwnerToService_Call) RunAndReturn(run func(int64, int64) error) *MockHeureka_AddOwnerToService_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) @@ -429,6 +523,64 @@ func (_c *MockHeureka_CreateIssueMatch_Call) RunAndReturn(run func(*entity.Issue return _c } +// CreateIssueMatchChange provides a mock function with given fields: _a0 +func (_m *MockHeureka) CreateIssueMatchChange(_a0 *entity.IssueMatchChange) (*entity.IssueMatchChange, error) { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for CreateIssueMatchChange") + } + + var r0 *entity.IssueMatchChange + var r1 error + if rf, ok := ret.Get(0).(func(*entity.IssueMatchChange) (*entity.IssueMatchChange, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(*entity.IssueMatchChange) *entity.IssueMatchChange); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*entity.IssueMatchChange) + } + } + + if rf, ok := ret.Get(1).(func(*entity.IssueMatchChange) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHeureka_CreateIssueMatchChange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateIssueMatchChange' +type MockHeureka_CreateIssueMatchChange_Call struct { + *mock.Call +} + +// CreateIssueMatchChange is a helper method to define mock.On call +// - _a0 *entity.IssueMatchChange +func (_e *MockHeureka_Expecter) CreateIssueMatchChange(_a0 interface{}) *MockHeureka_CreateIssueMatchChange_Call { + return &MockHeureka_CreateIssueMatchChange_Call{Call: _e.mock.On("CreateIssueMatchChange", _a0)} +} + +func (_c *MockHeureka_CreateIssueMatchChange_Call) Run(run func(_a0 *entity.IssueMatchChange)) *MockHeureka_CreateIssueMatchChange_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*entity.IssueMatchChange)) + }) + return _c +} + +func (_c *MockHeureka_CreateIssueMatchChange_Call) Return(_a0 *entity.IssueMatchChange, _a1 error) *MockHeureka_CreateIssueMatchChange_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHeureka_CreateIssueMatchChange_Call) RunAndReturn(run func(*entity.IssueMatchChange) (*entity.IssueMatchChange, error)) *MockHeureka_CreateIssueMatchChange_Call { + _c.Call.Return(run) + return _c +} + // CreateIssueRepository provides a mock function with given fields: _a0 func (_m *MockHeureka) CreateIssueRepository(_a0 *entity.IssueRepository) (*entity.IssueRepository, error) { ret := _m.Called(_a0) @@ -1041,6 +1193,52 @@ func (_c *MockHeureka_DeleteIssueMatch_Call) RunAndReturn(run func(int64) error) return _c } +// DeleteIssueMatchChange provides a mock function with given fields: _a0 +func (_m *MockHeureka) DeleteIssueMatchChange(_a0 int64) error { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for DeleteIssueMatchChange") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockHeureka_DeleteIssueMatchChange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteIssueMatchChange' +type MockHeureka_DeleteIssueMatchChange_Call struct { + *mock.Call +} + +// DeleteIssueMatchChange is a helper method to define mock.On call +// - _a0 int64 +func (_e *MockHeureka_Expecter) DeleteIssueMatchChange(_a0 interface{}) *MockHeureka_DeleteIssueMatchChange_Call { + return &MockHeureka_DeleteIssueMatchChange_Call{Call: _e.mock.On("DeleteIssueMatchChange", _a0)} +} + +func (_c *MockHeureka_DeleteIssueMatchChange_Call) Run(run func(_a0 int64)) *MockHeureka_DeleteIssueMatchChange_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64)) + }) + return _c +} + +func (_c *MockHeureka_DeleteIssueMatchChange_Call) Return(_a0 error) *MockHeureka_DeleteIssueMatchChange_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHeureka_DeleteIssueMatchChange_Call) RunAndReturn(run func(int64) error) *MockHeureka_DeleteIssueMatchChange_Call { + _c.Call.Return(run) + return _c +} + // DeleteIssueRepository provides a mock function with given fields: _a0 func (_m *MockHeureka) DeleteIssueRepository(_a0 int64) error { ret := _m.Called(_a0) @@ -2155,6 +2353,100 @@ func (_c *MockHeureka_ListUsers_Call) RunAndReturn(run func(*entity.UserFilter, return _c } +// RemoveIssueRepositoryFromService provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) RemoveIssueRepositoryFromService(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for RemoveIssueRepositoryFromService") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockHeureka_RemoveIssueRepositoryFromService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveIssueRepositoryFromService' +type MockHeureka_RemoveIssueRepositoryFromService_Call struct { + *mock.Call +} + +// RemoveIssueRepositoryFromService is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockHeureka_Expecter) RemoveIssueRepositoryFromService(_a0 interface{}, _a1 interface{}) *MockHeureka_RemoveIssueRepositoryFromService_Call { + return &MockHeureka_RemoveIssueRepositoryFromService_Call{Call: _e.mock.On("RemoveIssueRepositoryFromService", _a0, _a1)} +} + +func (_c *MockHeureka_RemoveIssueRepositoryFromService_Call) Run(run func(_a0 int64, _a1 int64)) *MockHeureka_RemoveIssueRepositoryFromService_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockHeureka_RemoveIssueRepositoryFromService_Call) Return(_a0 error) *MockHeureka_RemoveIssueRepositoryFromService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHeureka_RemoveIssueRepositoryFromService_Call) RunAndReturn(run func(int64, int64) error) *MockHeureka_RemoveIssueRepositoryFromService_Call { + _c.Call.Return(run) + return _c +} + +// RemoveOwnerFromService provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) RemoveOwnerFromService(_a0 int64, _a1 int64) error { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for RemoveOwnerFromService") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int64, int64) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockHeureka_RemoveOwnerFromService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveOwnerFromService' +type MockHeureka_RemoveOwnerFromService_Call struct { + *mock.Call +} + +// RemoveOwnerFromService is a helper method to define mock.On call +// - _a0 int64 +// - _a1 int64 +func (_e *MockHeureka_Expecter) RemoveOwnerFromService(_a0 interface{}, _a1 interface{}) *MockHeureka_RemoveOwnerFromService_Call { + return &MockHeureka_RemoveOwnerFromService_Call{Call: _e.mock.On("RemoveOwnerFromService", _a0, _a1)} +} + +func (_c *MockHeureka_RemoveOwnerFromService_Call) Run(run func(_a0 int64, _a1 int64)) *MockHeureka_RemoveOwnerFromService_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int64), args[1].(int64)) + }) + return _c +} + +func (_c *MockHeureka_RemoveOwnerFromService_Call) Return(_a0 error) *MockHeureka_RemoveOwnerFromService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHeureka_RemoveOwnerFromService_Call) RunAndReturn(run func(int64, int64) error) *MockHeureka_RemoveOwnerFromService_Call { + _c.Call.Return(run) + return _c +} + // Shutdown provides a mock function with given fields: func (_m *MockHeureka) Shutdown() error { ret := _m.Called() @@ -2606,6 +2898,64 @@ func (_c *MockHeureka_UpdateIssueMatch_Call) RunAndReturn(run func(*entity.Issue return _c } +// UpdateIssueMatchChange provides a mock function with given fields: _a0 +func (_m *MockHeureka) UpdateIssueMatchChange(_a0 *entity.IssueMatchChange) (*entity.IssueMatchChange, error) { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for UpdateIssueMatchChange") + } + + var r0 *entity.IssueMatchChange + var r1 error + if rf, ok := ret.Get(0).(func(*entity.IssueMatchChange) (*entity.IssueMatchChange, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(*entity.IssueMatchChange) *entity.IssueMatchChange); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*entity.IssueMatchChange) + } + } + + if rf, ok := ret.Get(1).(func(*entity.IssueMatchChange) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHeureka_UpdateIssueMatchChange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateIssueMatchChange' +type MockHeureka_UpdateIssueMatchChange_Call struct { + *mock.Call +} + +// UpdateIssueMatchChange is a helper method to define mock.On call +// - _a0 *entity.IssueMatchChange +func (_e *MockHeureka_Expecter) UpdateIssueMatchChange(_a0 interface{}) *MockHeureka_UpdateIssueMatchChange_Call { + return &MockHeureka_UpdateIssueMatchChange_Call{Call: _e.mock.On("UpdateIssueMatchChange", _a0)} +} + +func (_c *MockHeureka_UpdateIssueMatchChange_Call) Run(run func(_a0 *entity.IssueMatchChange)) *MockHeureka_UpdateIssueMatchChange_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*entity.IssueMatchChange)) + }) + return _c +} + +func (_c *MockHeureka_UpdateIssueMatchChange_Call) Return(_a0 *entity.IssueMatchChange, _a1 error) *MockHeureka_UpdateIssueMatchChange_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHeureka_UpdateIssueMatchChange_Call) RunAndReturn(run func(*entity.IssueMatchChange) (*entity.IssueMatchChange, error)) *MockHeureka_UpdateIssueMatchChange_Call { + _c.Call.Return(run) + return _c +} + // UpdateIssueRepository provides a mock function with given fields: _a0 func (_m *MockHeureka) UpdateIssueRepository(_a0 *entity.IssueRepository) (*entity.IssueRepository, error) { ret := _m.Called(_a0) From 17ea8c406868a56d6641883879210ecb3dd1d52f Mon Sep 17 00:00:00 2001 From: Michael Reimsbach Date: Thu, 11 Jul 2024 15:20:43 +0200 Subject: [PATCH 2/2] feat(service): add mutations for relations --- internal/app/activity_test.go | 2 +- internal/app/interface.go | 3 +++ internal/app/service_test.go | 2 +- internal/app/support_group_test.go | 2 +- internal/e2e/activity_query_test.go | 3 +++ internal/e2e/service_query_test.go | 4 +++- internal/e2e/support_group_query_test.go | 3 +++ 7 files changed, 15 insertions(+), 4 deletions(-) diff --git a/internal/app/activity_test.go b/internal/app/activity_test.go index 5236d59e..0405fbcb 100644 --- a/internal/app/activity_test.go +++ b/internal/app/activity_test.go @@ -192,7 +192,7 @@ var _ = Describe("When deleting Activity", Label("app", "DeleteActivity"), func( }) }) -var _ = Describe("When modifying Service and Activity", Label("app", "ServiceActivity"), func() { +var _ = Describe("When modifying relationship of Service and Activity", Label("app", "ServiceActivityRelationship"), func() { var ( db *mocks.MockDatabase heureka app.Heureka diff --git a/internal/app/interface.go b/internal/app/interface.go index 5602369a..3c45055f 100644 --- a/internal/app/interface.go +++ b/internal/app/interface.go @@ -34,6 +34,7 @@ type Heureka interface { DeleteIssueMatchChange(int64) error ListServices(*entity.ServiceFilter, *entity.ListOptions) (*entity.List[entity.ServiceResult], error) + GetService(int64) (*entity.Service, error) CreateService(*entity.Service) (*entity.Service, error) UpdateService(*entity.Service) (*entity.Service, error) DeleteService(int64) error @@ -48,6 +49,7 @@ type Heureka interface { DeleteUser(int64) error ListSupportGroups(*entity.SupportGroupFilter, *entity.ListOptions) (*entity.List[entity.SupportGroupResult], error) + GetSupportGroup(int64) (*entity.SupportGroup, error) CreateSupportGroup(*entity.SupportGroup) (*entity.SupportGroup, error) UpdateSupportGroup(*entity.SupportGroup) (*entity.SupportGroup, error) DeleteSupportGroup(int64) error @@ -60,6 +62,7 @@ type Heureka interface { DeleteComponentInstance(int64) error ListActivities(*entity.ActivityFilter, *entity.ListOptions) (*entity.List[entity.ActivityResult], error) + GetActivity(int64) (*entity.Activity, error) CreateActivity(*entity.Activity) (*entity.Activity, error) UpdateActivity(*entity.Activity) (*entity.Activity, error) DeleteActivity(int64) error diff --git a/internal/app/service_test.go b/internal/app/service_test.go index 863cea89..5dfb822f 100644 --- a/internal/app/service_test.go +++ b/internal/app/service_test.go @@ -240,7 +240,7 @@ var _ = Describe("When modifying owner and Service", Label("app", "OwnerService" }) }) -var _ = Describe("When modifying issueRepository and Service", Label("app", "IssueRepositoryService"), func() { +var _ = Describe("When modifying relationship of issueRepository and Service", Label("app", "IssueRepositoryServiceRelationship"), func() { var ( db *mocks.MockDatabase heureka app.Heureka diff --git a/internal/app/support_group_test.go b/internal/app/support_group_test.go index 0509d878..123ea685 100644 --- a/internal/app/support_group_test.go +++ b/internal/app/support_group_test.go @@ -192,7 +192,7 @@ var _ = Describe("When deleting SupportGroup", Label("app", "DeleteSupportGroup" }) }) -var _ = Describe("When modifying Service and SupportGroup", Label("app", "ServiceSupportGroup"), func() { +var _ = Describe("When modifying relationship of Service and SupportGroup", Label("app", "ServiceSupportGroupRelationship"), func() { var ( db *mocks.MockDatabase heureka app.Heureka diff --git a/internal/e2e/activity_query_test.go b/internal/e2e/activity_query_test.go index 8b56807b..6a4183eb 100644 --- a/internal/e2e/activity_query_test.go +++ b/internal/e2e/activity_query_test.go @@ -415,6 +415,7 @@ var _ = Describe("Modifying Services of Activity via API", Label("e2e", "Service req := graphql.NewRequest(str) activity := seedCollection.ActivityRows[0].AsActivity() + // find all services that are assigned to the activity serviceIds := lo.FilterMap(seedCollection.ActivityHasServiceRows, func(row mariadb.ActivityHasServiceRow, _ int) (int64, bool) { if row.ActivityId.Int64 == activity.Id { return row.ServiceId.Int64, true @@ -422,6 +423,7 @@ var _ = Describe("Modifying Services of Activity via API", Label("e2e", "Service return 0, false }) + // find a service that is not assigned to the activity serviceRow, _ := lo.Find(seedCollection.ServiceRows, func(row mariadb.BaseServiceRow) bool { return !lo.Contains(serviceIds, row.Id.Int64) }) @@ -459,6 +461,7 @@ var _ = Describe("Modifying Services of Activity via API", Label("e2e", "Service activity := seedCollection.ActivityRows[0].AsActivity() + // find a service that is assigned to the activity serviceRow, _ := lo.Find(seedCollection.ActivityHasServiceRows, func(row mariadb.ActivityHasServiceRow) bool { return row.ActivityId.Int64 == activity.Id }) diff --git a/internal/e2e/service_query_test.go b/internal/e2e/service_query_test.go index e82553ac..e805837b 100644 --- a/internal/e2e/service_query_test.go +++ b/internal/e2e/service_query_test.go @@ -575,13 +575,14 @@ var _ = Describe("Modifying IssueRepository of Service via API", Label("e2e", "S req := graphql.NewRequest(str) service := seedCollection.ServiceRows[0].AsService() + // find all issueRepositories that are attached to the service issueRepositoryIds := lo.FilterMap(seedCollection.IssueRepositoryServiceRows, func(row mariadb.IssueRepositoryServiceRow, _ int) (int64, bool) { if row.ServiceId.Int64 == service.Id { return row.IssueRepositoryId.Int64, true } return 0, false }) - + // find an issueRepository that is not attached to the service issueRepositoryRow, _ := lo.Find(seedCollection.IssueRepositoryRows, func(row mariadb.BaseIssueRepositoryRow) bool { return !lo.Contains(issueRepositoryIds, row.Id.Int64) }) @@ -620,6 +621,7 @@ var _ = Describe("Modifying IssueRepository of Service via API", Label("e2e", "S service := seedCollection.ServiceRows[0].AsService() + // find an issueRepository that is attached to the service issueRepositoryRow, _ := lo.Find(seedCollection.IssueRepositoryServiceRows, func(row mariadb.IssueRepositoryServiceRow) bool { return row.ServiceId.Int64 == service.Id }) diff --git a/internal/e2e/support_group_query_test.go b/internal/e2e/support_group_query_test.go index 9dfae409..267054d9 100644 --- a/internal/e2e/support_group_query_test.go +++ b/internal/e2e/support_group_query_test.go @@ -447,6 +447,7 @@ var _ = Describe("Modifying Services of SupportGroup via API", Label("e2e", "Sup req := graphql.NewRequest(str) supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup() + // find all services that are attached to the supportGroup serviceIds := lo.FilterMap(seedCollection.SupportGroupServiceRows, func(row mariadb.SupportGroupServiceRow, _ int) (int64, bool) { if row.SupportGroupId.Int64 == supportGroup.Id { return row.ServiceId.Int64, true @@ -454,6 +455,7 @@ var _ = Describe("Modifying Services of SupportGroup via API", Label("e2e", "Sup return 0, false }) + // find a service that is not attached to the supportGroup serviceRow, _ := lo.Find(seedCollection.ServiceRows, func(row mariadb.BaseServiceRow) bool { return !lo.Contains(serviceIds, row.Id.Int64) }) @@ -491,6 +493,7 @@ var _ = Describe("Modifying Services of SupportGroup via API", Label("e2e", "Sup supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup() + // find a service that is attached to the supportGroup serviceRow, _ := lo.Find(seedCollection.SupportGroupServiceRows, func(row mariadb.SupportGroupServiceRow) bool { return row.SupportGroupId.Int64 == supportGroup.Id })