Skip to content

Commit

Permalink
chore: purge usecase interactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Feb 21, 2024
1 parent a985fb5 commit 111a55e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 176 deletions.
10 changes: 5 additions & 5 deletions pkg/clinical/presentation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/savannahghi/clinical/pkg/clinical/presentation/graph"
"github.com/savannahghi/clinical/pkg/clinical/presentation/graph/generated"
"github.com/savannahghi/clinical/pkg/clinical/presentation/rest"
"github.com/savannahghi/clinical/pkg/clinical/usecases"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
"github.com/savannahghi/serverutils"
"google.golang.org/api/healthcare/v1"
)
Expand Down Expand Up @@ -122,13 +122,13 @@ func StartServer(

infrastructure := infrastructure.NewInfrastructureInteractor(baseExtension, fhir, ocl, upload, pubsubSvc, advantageSvc)

usecases := usecases.NewUsecasesInteractor(infrastructure)
usecases := clinical.NewUseCasesClinicalImpl(infrastructure)

r := gin.Default()

memoryStore := persist.NewMemoryStore(60 * time.Minute)

SetupRoutes(r, memoryStore, authclient, usecases, infrastructure)
SetupRoutes(r, memoryStore, authclient, *usecases, infrastructure)

addr := fmt.Sprintf(":%d", port)

Expand All @@ -137,7 +137,7 @@ func StartServer(
}
}

func SetupRoutes(r *gin.Engine, cacheStore persist.CacheStore, authclient *authutils.Client, usecases usecases.Interactor, infra infrastructure.Infrastructure) {
func SetupRoutes(r *gin.Engine, cacheStore persist.CacheStore, authclient *authutils.Client, usecases clinical.UseCasesClinicalImpl, infra infrastructure.Infrastructure) {
r.Use(cors.New(cors.Config{
AllowOrigins: ClinicalAllowedOrigins,
AllowMethods: []string{http.MethodPut, http.MethodPatch, http.MethodGet, http.MethodPost, http.MethodDelete, http.MethodOptions},
Expand Down Expand Up @@ -206,7 +206,7 @@ func SetupRoutes(r *gin.Engine, cacheStore persist.CacheStore, authclient *authu
}

// GQLHandler sets up a GraphQL resolver
func GQLHandler(service usecases.Interactor) gin.HandlerFunc {
func GQLHandler(service clinical.UseCasesClinicalImpl) gin.HandlerFunc {
resolver, err := graph.NewResolver(service)
if err != nil {
log.Panicf("failed to start graph resolver: %s", err)
Expand Down
50 changes: 25 additions & 25 deletions pkg/clinical/presentation/graph/clinical.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/clinical/presentation/graph/resolver.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package graph

import (
"github.com/savannahghi/clinical/pkg/clinical/usecases"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
)

//go:generate go run github.com/99designs/gqlgen

// Resolver wires up the resolvers needed for the clinical services
type Resolver struct {
usecases usecases.Interactor
usecases clinical.UseCasesClinicalImpl
}

// NewResolver initializes a working top leve Resolver that has been initialized
// with all necessary dependencies
func NewResolver(usecases usecases.Interactor) (*Resolver, error) {
func NewResolver(usecases clinical.UseCasesClinicalImpl) (*Resolver, error) {
return &Resolver{
usecases: usecases,
}, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/clinical/presentation/rest/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/savannahghi/clinical/pkg/clinical/application/utils"
"github.com/savannahghi/clinical/pkg/clinical/domain"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/advantage"
"github.com/savannahghi/clinical/pkg/clinical/usecases"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
"github.com/savannahghi/errorcodeutil"
"github.com/savannahghi/pubsubtools"
"github.com/savannahghi/serverutils"
Expand All @@ -26,13 +26,13 @@ type BaseExtension interface {

// PresentationHandlersImpl represents the usecase implementation object
type PresentationHandlersImpl struct {
usecases usecases.Interactor
usecases clinical.UseCasesClinicalImpl
baseExt BaseExtension
advantageService advantage.AdvantageService
}

// NewPresentationHandlers initializes a new rest handlers usecase
func NewPresentationHandlers(usecases usecases.Interactor, extension BaseExtension, advantageSvc advantage.AdvantageService) *PresentationHandlersImpl {
func NewPresentationHandlers(usecases clinical.UseCasesClinicalImpl, extension BaseExtension, advantageSvc advantage.AdvantageService) *PresentationHandlersImpl {
return &PresentationHandlersImpl{
usecases: usecases,
baseExt: extension,
Expand Down
6 changes: 3 additions & 3 deletions pkg/clinical/presentation/rest/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
fakePubSubMock "github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/pubsub/mock"
fakeUploadMock "github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/upload/mock"
"github.com/savannahghi/clinical/pkg/clinical/presentation"
"github.com/savannahghi/clinical/pkg/clinical/usecases"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
"github.com/savannahghi/interserviceclient"
"github.com/savannahghi/pubsubtools"
"github.com/savannahghi/serverutils"
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestPresentationHandlersImpl_ReceivePubSubPushMessage(t *testing.T) {
fakePubSub := fakePubSubMock.NewPubSubServiceMock()
fakeAdvantage := fakeAdvantageMock.NewFakeAdvantageMock()
infra := infrastructure.NewInfrastructureInteractor(fakeExt, fakeFHIR, fakeOCL, fakeUpload, fakePubSub, fakeAdvantage)
usecases := usecases.NewUsecasesInteractor(infra)
usecases := clinical.NewUseCasesClinicalImpl(infra)

if tt.name == "happy case: publish create patient message" {
msg := dto.PatientPubSubMessage{
Expand Down Expand Up @@ -685,7 +685,7 @@ func TestPresentationHandlersImpl_ReceivePubSubPushMessage(t *testing.T) {
req.Header.Add(k, v)
}

presentation.SetupRoutes(engine, testMemoryStore, authclient, usecases, infra)
presentation.SetupRoutes(engine, testMemoryStore, authclient, *usecases, infra)
engine.ServeHTTP(w, req)

resp := w.Result()
Expand Down
Loading

0 comments on commit 111a55e

Please sign in to comment.