mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Replacing CGREvent with *CGRevent when inherited for SupplierService
This commit is contained in:
committed by
Dan Christian Bogos
parent
eaeddd581b
commit
bdc57998f0
@@ -132,7 +132,7 @@ func testV1SplSFromFolder(t *testing.T) {
|
||||
|
||||
func testV1SplSGetWeightSuppliers(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetWeightSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -172,7 +172,7 @@ func testV1SplSGetWeightSuppliers(t *testing.T) {
|
||||
|
||||
func testV1SplSGetLeastCostSuppliers(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetLeastCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -228,7 +228,7 @@ func testV1SplSGetLeastCostSuppliers(t *testing.T) {
|
||||
func testV1SplSGetLeastCostSuppliersWithMaxCost(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
MaxCost: "0.30",
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetLeastCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -276,7 +276,7 @@ func testV1SplSGetLeastCostSuppliersWithMaxCost(t *testing.T) {
|
||||
func testV1SplSGetLeastCostSuppliersWithMaxCostNotFound(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
MaxCost: "0.001",
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetLeastCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -298,7 +298,7 @@ func testV1SplSGetLeastCostSuppliersWithMaxCostNotFound(t *testing.T) {
|
||||
func testV1SplSGetLeastCostSuppliersWithMaxCost2(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
MaxCost: utils.MetaEventCost,
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetLeastCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -346,7 +346,7 @@ func testV1SplSGetLeastCostSuppliersWithMaxCost2(t *testing.T) {
|
||||
|
||||
func testV1SplSGetHighestCostSuppliers(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetHighestCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -402,7 +402,7 @@ func testV1SplSGetHighestCostSuppliers(t *testing.T) {
|
||||
func testV1SplSGetLeastCostSuppliersErr(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
IgnoreErrors: true,
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetHighestCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -546,7 +546,7 @@ func testV1SplSPolulateStatsForQOS(t *testing.T) {
|
||||
|
||||
func testV1SplSGetQOSSuppliers(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetQOSSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -577,7 +577,7 @@ func testV1SplSGetQOSSuppliers(t *testing.T) {
|
||||
|
||||
func testV1SplSGetQOSSuppliers2(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetQOSSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -608,7 +608,7 @@ func testV1SplSGetQOSSuppliers2(t *testing.T) {
|
||||
|
||||
func testV1SplSGetQOSSuppliers3(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetQOSSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -639,7 +639,7 @@ func testV1SplSGetQOSSuppliers3(t *testing.T) {
|
||||
|
||||
func testV1SplSGetQOSSuppliersFiltred(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetQOSSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -670,7 +670,7 @@ func testV1SplSGetQOSSuppliersFiltred(t *testing.T) {
|
||||
|
||||
func testV1SplSGetQOSSuppliersFiltred2(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetQOSSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -705,7 +705,7 @@ func testV1SplSGetQOSSuppliersFiltred2(t *testing.T) {
|
||||
|
||||
func testV1SplSGetSupplierWithoutFilter(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetSupplierWithoutFilter",
|
||||
Event: map[string]interface{}{
|
||||
|
||||
@@ -59,7 +59,7 @@ func (dS *DispatcherService) SupplierSv1GetSuppliers(args *engine.ArgsGetSupplie
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&args.CGREvent, utils.MetaSuppliers, routeID,
|
||||
return dS.Dispatch(args.CGREvent, utils.MetaSuppliers, routeID,
|
||||
utils.SupplierSv1GetSuppliers, args, reply)
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ func testDspSupGetSupFailover(t *testing.T) {
|
||||
},
|
||||
}
|
||||
args := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
@@ -183,7 +183,7 @@ func testDspSupGetSupFailover(t *testing.T) {
|
||||
func testDspSupTestAuthKey(t *testing.T) {
|
||||
var rpl *engine.SortedSuppliers
|
||||
args := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
@@ -233,7 +233,7 @@ func testDspSupTestAuthKey2(t *testing.T) {
|
||||
},
|
||||
}
|
||||
args := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
@@ -299,7 +299,7 @@ func testDspSupGetSupRoundRobin(t *testing.T) {
|
||||
},
|
||||
}
|
||||
args := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
|
||||
@@ -418,7 +418,7 @@ func (spS *SupplierService) sortedSuppliersForEvent(args *ArgsGetSuppliers) (sor
|
||||
args.CGREvent.Event[utils.Usage] = time.Duration(time.Minute) // make sure we have default set for Usage
|
||||
}
|
||||
var splPrfls []*SupplierProfile
|
||||
if splPrfls, err = spS.matchingSupplierProfilesForEvent(&args.CGREvent, true); err != nil {
|
||||
if splPrfls, err = spS.matchingSupplierProfilesForEvent(args.CGREvent, true); err != nil {
|
||||
return
|
||||
}
|
||||
splPrfl := splPrfls[0]
|
||||
@@ -428,7 +428,7 @@ func (spS *SupplierService) sortedSuppliersForEvent(args *ArgsGetSuppliers) (sor
|
||||
}
|
||||
extraOpts.sortingParameters = splPrfl.SortingParameters // populate sortingParameters in extraOpts
|
||||
sortedSuppliers, err := spS.sorter.SortSuppliers(splPrfl.ID, splPrfl.Sorting,
|
||||
splPrfl.Suppliers, &args.CGREvent, extraOpts)
|
||||
splPrfl.Suppliers, args.CGREvent, extraOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -449,7 +449,7 @@ func (spS *SupplierService) sortedSuppliersForEvent(args *ArgsGetSuppliers) (sor
|
||||
type ArgsGetSuppliers struct {
|
||||
IgnoreErrors bool
|
||||
MaxCost string // toDo: try with interface{} here
|
||||
utils.CGREvent
|
||||
*utils.CGREvent
|
||||
utils.Paginator
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
@@ -461,7 +461,7 @@ func (args *ArgsGetSuppliers) asOptsGetSuppliers() (opts *optsGetSuppliers, err
|
||||
utils.Destination, utils.SetupTime, utils.Usage}); err != nil {
|
||||
return
|
||||
}
|
||||
cd, err := NewCallDescriptorFromCGREvent(&args.CGREvent,
|
||||
cd, err := NewCallDescriptorFromCGREvent(args.CGREvent,
|
||||
config.CgrConfig().GeneralCfg().DefaultTimezone)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -488,7 +488,10 @@ type optsGetSuppliers struct {
|
||||
|
||||
// V1GetSupplierProfilesForEvent returns the list of valid supplier IDs
|
||||
func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *SortedSuppliers) (err error) {
|
||||
if missing := utils.MissingStructFields(&args.CGREvent, []string{"Tenant", "ID"}); len(missing) != 0 {
|
||||
if args.CGREvent == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.Event)
|
||||
}
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{"Tenant", "ID"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
} else if args.CGREvent.Event == nil {
|
||||
return utils.NewErrMandatoryIeMissing("Event")
|
||||
@@ -496,13 +499,13 @@ func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *Sorted
|
||||
if spS.attributeS != nil {
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSuppliers),
|
||||
CGREvent: &args.CGREvent,
|
||||
CGREvent: args.CGREvent,
|
||||
ArgDispatcher: args.ArgDispatcher,
|
||||
}
|
||||
var rplyEv AttrSProcessEventReply
|
||||
if err := spS.attributeS.Call(utils.AttributeSv1ProcessEvent,
|
||||
attrArgs, &rplyEv); err == nil && len(rplyEv.AlteredFields) != 0 {
|
||||
args.CGREvent = *rplyEv.CGREvent
|
||||
args.CGREvent = rplyEv.CGREvent
|
||||
} else if err.Error() != utils.ErrNotFound.Error() {
|
||||
return utils.NewErrAttributeS(err)
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ var (
|
||||
}
|
||||
argsGetSuppliers = []*ArgsGetSuppliers{
|
||||
{ //matching SupplierProfile1
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "utils.CGREvent1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -143,7 +143,7 @@ var (
|
||||
},
|
||||
},
|
||||
{ //matching SupplierProfile2
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "utils.CGREvent1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -156,7 +156,7 @@ var (
|
||||
},
|
||||
},
|
||||
{ //matching SupplierProfilePrefix
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "utils.CGREvent1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -165,7 +165,7 @@ var (
|
||||
},
|
||||
},
|
||||
{ //matching
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "CGR",
|
||||
Event: map[string]interface{}{
|
||||
@@ -386,7 +386,7 @@ func TestSuppliersCache(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSuppliersmatchingSupplierProfilesForEvent(t *testing.T) {
|
||||
sprf, err := splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[0].CGREvent, true)
|
||||
sprf, err := splService.matchingSupplierProfilesForEvent(argsGetSuppliers[0].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -394,7 +394,7 @@ func TestSuppliersmatchingSupplierProfilesForEvent(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[1].CGREvent, true)
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(argsGetSuppliers[1].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -402,7 +402,7 @@ func TestSuppliersmatchingSupplierProfilesForEvent(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[2].CGREvent, true)
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(argsGetSuppliers[2].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -636,7 +636,7 @@ func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) {
|
||||
|
||||
func TestSuppliersMatchWithIndexFalse(t *testing.T) {
|
||||
splService.filterS.cfg.SupplierSCfg().IndexedSelects = false
|
||||
sprf, err := splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[0].CGREvent, true)
|
||||
sprf, err := splService.matchingSupplierProfilesForEvent(argsGetSuppliers[0].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -644,7 +644,7 @@ func TestSuppliersMatchWithIndexFalse(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[1].CGREvent, true)
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(argsGetSuppliers[1].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -652,7 +652,7 @@ func TestSuppliersMatchWithIndexFalse(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[2].CGREvent, true)
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(argsGetSuppliers[2].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ func testV1SplSSetSupplierProfilesWithoutRatingPlanIDs(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", splPrf, reply)
|
||||
}
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetLeastCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -415,7 +415,7 @@ func testV1SplSPopulateResUsage(t *testing.T) {
|
||||
|
||||
func testV1SplSGetSortedSuppliers(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetSortedSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -497,7 +497,7 @@ func testV1SplSAddNewSplPrf2(t *testing.T) {
|
||||
|
||||
func testV1SplSGetSortedSuppliers2(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetSortedSuppliers2",
|
||||
Event: map[string]interface{}{
|
||||
|
||||
@@ -1838,7 +1838,7 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(clnt rpcclient.RpcClientConnection,
|
||||
sArgs := &engine.ArgsGetSuppliers{
|
||||
IgnoreErrors: args.SuppliersIgnoreErrors,
|
||||
MaxCost: args.SuppliersMaxCost,
|
||||
CGREvent: *cgrEv,
|
||||
CGREvent: cgrEv,
|
||||
Paginator: args.Paginator,
|
||||
ArgDispatcher: args.ArgDispatcher,
|
||||
}
|
||||
@@ -2714,7 +2714,7 @@ func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.RpcClientConnection,
|
||||
sArgs := &engine.ArgsGetSuppliers{
|
||||
IgnoreErrors: args.SuppliersIgnoreErrors,
|
||||
MaxCost: args.SuppliersMaxCost,
|
||||
CGREvent: *cgrEv,
|
||||
CGREvent: cgrEv,
|
||||
Paginator: args.Paginator,
|
||||
ArgDispatcher: args.ArgDispatcher,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user