mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
Merge pull request #1527 from Trial97/master
Added GetSuppliersForEvent
This commit is contained in:
@@ -337,6 +337,12 @@ func (dSup *DispatcherSupplierSv1) GetSuppliers(args *engine.ArgsGetSuppliers,
|
||||
return dSup.dSup.SupplierSv1GetSuppliers(args, reply)
|
||||
}
|
||||
|
||||
// GetSuppliersProfiles returns a list of suppliers profiles that match for Event
|
||||
func (dSup *DispatcherSupplierSv1) GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher,
|
||||
reply *[]*engine.SupplierProfile) error {
|
||||
return dSup.dSup.SupplierSv1GetSupplierProfilesForEvent(args, reply)
|
||||
}
|
||||
|
||||
func NewDispatcherAttributeSv1(dps *dispatchers.DispatcherService) *DispatcherAttributeSv1 {
|
||||
return &DispatcherAttributeSv1{dA: dps}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ type ResourceSv1Interface interface {
|
||||
|
||||
type SupplierSv1Interface interface {
|
||||
GetSuppliers(args *engine.ArgsGetSuppliers, reply *engine.SortedSuppliers) error
|
||||
GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher, reply *[]*engine.SupplierProfile) error
|
||||
Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,12 @@ func (splv1 *SupplierSv1) GetSuppliers(args *engine.ArgsGetSuppliers,
|
||||
return splv1.splS.V1GetSuppliers(args, reply)
|
||||
}
|
||||
|
||||
// GetSuppliersProfiles returns a list of suppliers profiles that match for Event
|
||||
func (splv1 *SupplierSv1) GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher,
|
||||
reply *[]*engine.SupplierProfile) error {
|
||||
return splv1.splS.V1GetSupplierProfilesForEvent(args, reply)
|
||||
}
|
||||
|
||||
func (splv1 *SupplierSv1) Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error {
|
||||
*reply = utils.Pong
|
||||
return nil
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -65,6 +66,7 @@ var sTestsSupplierSV1 = []func(t *testing.T){
|
||||
testV1SplSGetSupplierProfileIDs,
|
||||
testV1SplSUpdateSupplierProfiles,
|
||||
testV1SplSRemSupplierProfiles,
|
||||
testV1SplSGetSupplierForEvent,
|
||||
testV1SplSupplierPing,
|
||||
testV1SplSStopEngine,
|
||||
}
|
||||
@@ -878,6 +880,70 @@ func testV1SplSupplierPing(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testV1SplSGetSupplierForEvent(t *testing.T) {
|
||||
ev := &utils.CGREventWithArgDispatcher{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetHighestCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1000",
|
||||
utils.Destination: "1001",
|
||||
utils.SetupTime: "*now",
|
||||
"Subject": "TEST",
|
||||
},
|
||||
},
|
||||
}
|
||||
expected := engine.SupplierProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SPL_LCR",
|
||||
FilterIDs: []string{"FLTR_TEST"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2017, 11, 27, 00, 00, 00, 00, time.UTC),
|
||||
},
|
||||
Sorting: "*least_cost",
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*engine.Supplier{
|
||||
&engine.Supplier{
|
||||
ID: "supplier_1",
|
||||
FilterIDs: nil,
|
||||
AccountIDs: nil,
|
||||
RatingPlanIDs: []string{"RP_TEST_1"},
|
||||
ResourceIDs: nil,
|
||||
StatIDs: nil,
|
||||
Weight: 10,
|
||||
Blocker: false,
|
||||
SupplierParameters: "",
|
||||
},
|
||||
&engine.Supplier{
|
||||
ID: "supplier_2",
|
||||
FilterIDs: nil,
|
||||
AccountIDs: nil,
|
||||
RatingPlanIDs: []string{"RP_TEST_2"},
|
||||
ResourceIDs: nil,
|
||||
StatIDs: nil,
|
||||
Weight: 0,
|
||||
Blocker: false,
|
||||
SupplierParameters: "",
|
||||
},
|
||||
},
|
||||
Weight: 50,
|
||||
}
|
||||
var supProf []*engine.SupplierProfile
|
||||
if err := splSv1Rpc.Call(utils.SupplierSv1GetSupplierProfilesForEvent,
|
||||
ev, &supProf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Slice(expected.Suppliers, func(i, j int) bool {
|
||||
return expected.Suppliers[i].Weight < expected.Suppliers[j].Weight
|
||||
})
|
||||
sort.Slice(supProf[0].Suppliers, func(i, j int) bool {
|
||||
return supProf[0].Suppliers[i].Weight < supProf[0].Suppliers[j].Weight
|
||||
})
|
||||
if !reflect.DeepEqual(expected, *supProf[0]) {
|
||||
t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expected), utils.ToJSON(supProf))
|
||||
}
|
||||
}
|
||||
|
||||
func testV1SplSStopEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
65
console/supplier_profiles_for_event.go
Normal file
65
console/supplier_profiles_for_event.go
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import (
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
c := &CmdGetSupplierForEvent{
|
||||
name: "supplier_profiles_for_event",
|
||||
rpcMethod: utils.SupplierSv1GetSupplierProfilesForEvent,
|
||||
rpcParams: &utils.CGREventWithArgDispatcher{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
type CmdGetSupplierForEvent struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.CGREventWithArgDispatcher
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdGetSupplierForEvent) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdGetSupplierForEvent) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdGetSupplierForEvent) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.CGREventWithArgDispatcher{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdGetSupplierForEvent) PostprocessRpcParams() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdGetSupplierForEvent) RpcResult() interface{} {
|
||||
atr := []*engine.SupplierProfile{}
|
||||
return &atr
|
||||
}
|
||||
@@ -6,7 +6,7 @@ cgrates.org,ATTR_API_ATTR_FAKE_AUTH,*auth,*string:~APIKey:12345,,,APIMethods,*co
|
||||
cgrates.org,ATTR_API_ATTR_AUTH,*auth,*string:~APIKey:attr12345,,,APIMethods,*constant,AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent,false,20
|
||||
cgrates.org,ATTR_API_CHRG_AUTH,*auth,*string:~APIKey:chrg12345,,,APIMethods,*constant,ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent,false,20
|
||||
cgrates.org,ATTR_API_THR_AUTH,*auth,*string:~APIKey:thr12345,,,APIMethods,*constant,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs,false,20
|
||||
cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~APIKey:sup12345,,,APIMethods,*constant,SupplierSv1.Ping&SupplierSv1.GetSuppliers,false,20
|
||||
cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~APIKey:sup12345,,,APIMethods,*constant,SupplierSv1.Ping&SupplierSv1.GetSuppliers&SupplierSv1.GetSupplierProfilesForEvent,false,20
|
||||
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:~APIKey:stat12345,,,APIMethods,*constant,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,false,20
|
||||
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~APIKey:res12345,,,APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,false,20
|
||||
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:~APIKey:ses12345,,,APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessEvent&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession,false,20
|
||||
|
||||
|
@@ -53,3 +53,19 @@ func (dS *DispatcherService) SupplierSv1GetSuppliers(args *engine.ArgsGetSupplie
|
||||
return dS.Dispatch(&args.CGREvent, utils.MetaSuppliers, args.RouteID,
|
||||
utils.SupplierSv1GetSuppliers, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) SupplierSv1GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher,
|
||||
reply *[]*engine.SupplierProfile) (err error) {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
|
||||
}
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.SupplierSv1GetSupplierProfilesForEvent,
|
||||
args.CGREvent.Tenant,
|
||||
args.APIKey, args.CGREvent.Time); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(args.CGREvent, utils.MetaSuppliers, args.RouteID,
|
||||
utils.SupplierSv1GetSupplierProfilesForEvent, args, reply)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package dispatchers
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -37,6 +38,7 @@ var sTestsDspSup = []func(t *testing.T){
|
||||
testDspSupPing,
|
||||
testDspSupTestAuthKey,
|
||||
testDspSupTestAuthKey2,
|
||||
testDspSupGetSupplierForEvent,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
@@ -322,3 +324,71 @@ func testDspSupGetSupRoundRobin(t *testing.T) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRpl), utils.ToJSON(rpl))
|
||||
}
|
||||
}
|
||||
|
||||
func testDspSupGetSupplierForEvent(t *testing.T) {
|
||||
ev := &utils.CGREventWithArgDispatcher{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetHighestCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.Subject: "1002",
|
||||
utils.Destination: "1001",
|
||||
utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC),
|
||||
utils.Usage: "1m20s",
|
||||
},
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("sup12345"),
|
||||
},
|
||||
}
|
||||
expected := engine.SupplierProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SPL_ACNT_1002",
|
||||
FilterIDs: []string{"FLTR_ACNT_1002"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2017, 11, 27, 00, 00, 00, 00, time.UTC),
|
||||
},
|
||||
Sorting: "*least_cost",
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*engine.Supplier{
|
||||
&engine.Supplier{
|
||||
ID: "supplier1",
|
||||
FilterIDs: nil,
|
||||
AccountIDs: nil,
|
||||
RatingPlanIDs: []string{"RP_1002_LOW"},
|
||||
ResourceIDs: nil,
|
||||
StatIDs: nil,
|
||||
Weight: 10,
|
||||
Blocker: false,
|
||||
SupplierParameters: "",
|
||||
},
|
||||
&engine.Supplier{
|
||||
ID: "supplier2",
|
||||
FilterIDs: nil,
|
||||
AccountIDs: nil,
|
||||
RatingPlanIDs: []string{"RP_1002"},
|
||||
ResourceIDs: nil,
|
||||
StatIDs: nil,
|
||||
Weight: 20,
|
||||
Blocker: false,
|
||||
SupplierParameters: "",
|
||||
},
|
||||
},
|
||||
Weight: 10,
|
||||
}
|
||||
var supProf []*engine.SupplierProfile
|
||||
if err := dispEngine.RCP.Call(utils.SupplierSv1GetSupplierProfilesForEvent,
|
||||
ev, &supProf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Slice(expected.Suppliers, func(i, j int) bool {
|
||||
return expected.Suppliers[i].Weight < expected.Suppliers[j].Weight
|
||||
})
|
||||
sort.Slice(supProf[0].Suppliers, func(i, j int) bool {
|
||||
return supProf[0].Suppliers[i].Weight < supProf[0].Suppliers[j].Weight
|
||||
})
|
||||
if !reflect.DeepEqual(expected, *supProf[0]) {
|
||||
t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expected), utils.ToJSON(supProf))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,12 +125,15 @@ func (spS *SupplierService) Shutdown() error {
|
||||
}
|
||||
|
||||
// matchingSupplierProfilesForEvent returns ordered list of matching resources which are active by the time of the call
|
||||
func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent) (matchingLP *SupplierProfile, err error) {
|
||||
func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent, singleResult bool) (matchingSLP []*SupplierProfile, err error) {
|
||||
sPrflIDs, err := MatchingItemIDsForEvent(ev.Event, spS.stringIndexedFields, spS.prefixIndexedFields,
|
||||
spS.dm, utils.CacheSupplierFilterIndexes, ev.Tenant, spS.filterS.cfg.SupplierSCfg().IndexedSelects)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if singleResult {
|
||||
matchingSLP = make([]*SupplierProfile, 1)
|
||||
}
|
||||
for lpID := range sPrflIDs {
|
||||
splPrfl, err := spS.dm.GetSupplierProfile(ev.Tenant, lpID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
@@ -149,12 +152,23 @@ func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent)
|
||||
} else if !pass {
|
||||
continue
|
||||
}
|
||||
if matchingLP == nil || matchingLP.Weight < splPrfl.Weight {
|
||||
matchingLP = splPrfl
|
||||
if singleResult {
|
||||
if matchingSLP[0] == nil || matchingSLP[0].Weight < splPrfl.Weight {
|
||||
matchingSLP[0] = splPrfl
|
||||
}
|
||||
} else {
|
||||
matchingSLP = append(matchingSLP, splPrfl)
|
||||
}
|
||||
}
|
||||
if matchingLP == nil {
|
||||
return nil, utils.ErrNotFound
|
||||
if singleResult {
|
||||
if matchingSLP[0] == nil {
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
} else {
|
||||
if len(matchingSLP) == 0 {
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
sort.Slice(matchingSLP, func(i, j int) bool { return matchingSLP[i].Weight < matchingSLP[j].Weight })
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -402,10 +416,11 @@ func (spS *SupplierService) sortedSuppliersForEvent(args *ArgsGetSuppliers) (sor
|
||||
if _, has := args.CGREvent.Event[utils.Usage]; !has {
|
||||
args.CGREvent.Event[utils.Usage] = time.Duration(time.Minute) // make sure we have default set for Usage
|
||||
}
|
||||
var splPrfl *SupplierProfile
|
||||
if splPrfl, err = spS.matchingSupplierProfilesForEvent(&args.CGREvent); err != nil {
|
||||
var splPrfls []*SupplierProfile
|
||||
if splPrfls, err = spS.matchingSupplierProfilesForEvent(&args.CGREvent, true); err != nil {
|
||||
return
|
||||
}
|
||||
splPrfl := splPrfls[0]
|
||||
extraOpts, err := args.asOptsGetSuppliers() // convert suppliers arguments into internal options used to limit data
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -469,7 +484,7 @@ type optsGetSuppliers struct {
|
||||
sortingParameters []string //used for QOS strategy
|
||||
}
|
||||
|
||||
// V1GetSuppliersForEvent returns the list of valid supplier IDs
|
||||
// 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 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
@@ -500,3 +515,21 @@ func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *Sorted
|
||||
*reply = *sSps
|
||||
return
|
||||
}
|
||||
|
||||
// V1GetSupplierProfiles returns the list of valid supplier profiles
|
||||
func (spS *SupplierService) V1GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher, reply *[]*SupplierProfile) (err error) {
|
||||
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")
|
||||
}
|
||||
sPs, err := spS.matchingSupplierProfilesForEvent(args.CGREvent, false)
|
||||
if err != nil {
|
||||
if err != utils.ErrNotFound {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
*reply = sPs
|
||||
return
|
||||
}
|
||||
|
||||
@@ -386,28 +386,28 @@ func TestSuppliersCache(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSuppliersmatchingSupplierProfilesForEvent(t *testing.T) {
|
||||
sprf, err := splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[0].CGREvent)
|
||||
sprf, err := splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[0].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(sppTest[0], sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf)
|
||||
if !reflect.DeepEqual(sppTest[0], sprf[0]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[1].CGREvent)
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[1].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(sppTest[1], sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf)
|
||||
if !reflect.DeepEqual(sppTest[1], sprf[0]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[2].CGREvent)
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[2].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(sppTest[2], sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[2], sprf)
|
||||
if !reflect.DeepEqual(sppTest[2], sprf[0]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[2], sprf[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,27 +630,27 @@ func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) {
|
||||
|
||||
func TestSuppliersMatchWithIndexFalse(t *testing.T) {
|
||||
splService.filterS.cfg.SupplierSCfg().IndexedSelects = false
|
||||
sprf, err := splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[0].CGREvent)
|
||||
sprf, err := splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[0].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(sppTest[0], sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf)
|
||||
if !reflect.DeepEqual(sppTest[0], sprf[0]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[1].CGREvent)
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[1].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(sppTest[1], sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf)
|
||||
if !reflect.DeepEqual(sppTest[1], sprf[0]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[2].CGREvent)
|
||||
sprf, err = splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[2].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(sppTest[2], sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[2], sprf)
|
||||
if !reflect.DeepEqual(sppTest[2], sprf[0]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[2], sprf[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,12 +754,13 @@ const (
|
||||
|
||||
// SupplierS APIs
|
||||
const (
|
||||
SupplierSv1GetSuppliers = "SupplierSv1.GetSuppliers"
|
||||
SupplierSv1Ping = "SupplierSv1.Ping"
|
||||
ApierV1GetSupplierProfile = "ApierV1.GetSupplierProfile"
|
||||
ApierV1GetSupplierProfileIDs = "ApierV1.GetSupplierProfileIDs"
|
||||
ApierV1RemoveSupplierProfile = "ApierV1.RemoveSupplierProfile"
|
||||
ApierV1SetSupplierProfile = "ApierV1.SetSupplierProfile"
|
||||
SupplierSv1GetSuppliers = "SupplierSv1.GetSuppliers"
|
||||
SupplierSv1GetSupplierProfilesForEvent = "SupplierSv1.GetSupplierProfilesForEvent"
|
||||
SupplierSv1Ping = "SupplierSv1.Ping"
|
||||
ApierV1GetSupplierProfile = "ApierV1.GetSupplierProfile"
|
||||
ApierV1GetSupplierProfileIDs = "ApierV1.GetSupplierProfileIDs"
|
||||
ApierV1RemoveSupplierProfile = "ApierV1.RemoveSupplierProfile"
|
||||
ApierV1SetSupplierProfile = "ApierV1.SetSupplierProfile"
|
||||
)
|
||||
|
||||
// AttributeS APIs
|
||||
|
||||
Reference in New Issue
Block a user