mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
Update unit tests after renaming
This commit is contained in:
committed by
Dan Christian Bogos
parent
7c1157f394
commit
d683ab48fb
@@ -25,60 +25,60 @@ import (
|
||||
)
|
||||
|
||||
func TestLibSuppliersSortCost(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.1,
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.1,
|
||||
utils.Weight: 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.05,
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
},
|
||||
}
|
||||
sSpls.SortLeastCost()
|
||||
eOrderedSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
eOrderedSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.05,
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.1,
|
||||
utils.Weight: 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.1,
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -88,55 +88,55 @@ func TestLibSuppliersSortCost(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortWeight(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
func TestLibRoutesSortWeight(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 10.5,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
},
|
||||
}
|
||||
sSpls.SortWeight()
|
||||
eOrderedSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
eOrderedSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 10.5,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -146,24 +146,24 @@ func TestLibSuppliersSortWeight(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortedSuppliersDigest(t *testing.T) {
|
||||
eSpls := SortedSuppliers{
|
||||
func TestSortedRoutesDigest(t *testing.T) {
|
||||
eSpls := SortedRoutes{
|
||||
ProfileID: "SPL_WEIGHT_1",
|
||||
Sorting: utils.MetaWeight,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 10.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -174,24 +174,24 @@ func TestSortedSuppliersDigest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortedSuppliersDigest2(t *testing.T) {
|
||||
eSpls := SortedSuppliers{
|
||||
func TestSortedRoutesDigest2(t *testing.T) {
|
||||
eSpls := SortedRoutes{
|
||||
ProfileID: "SPL_WEIGHT_1",
|
||||
Sorting: utils.MetaWeight,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 30.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -202,11 +202,11 @@ func TestSortedSuppliersDigest2(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortedSuppliersDigest3(t *testing.T) {
|
||||
eSpls := SortedSuppliers{
|
||||
ProfileID: "SPL_WEIGHT_1",
|
||||
Sorting: utils.MetaWeight,
|
||||
SortedSuppliers: []*SortedSupplier{},
|
||||
func TestSortedRoutesDigest3(t *testing.T) {
|
||||
eSpls := SortedRoutes{
|
||||
ProfileID: "SPL_WEIGHT_1",
|
||||
Sorting: utils.MetaWeight,
|
||||
SortedRoutes: []*SortedRoute{},
|
||||
}
|
||||
exp := ""
|
||||
rcv := eSpls.Digest()
|
||||
@@ -215,61 +215,61 @@ func TestSortedSuppliersDigest3(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortHighestCost(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
func TestLibRoutesSortHighestCost(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.1,
|
||||
utils.Weight: 15.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.2,
|
||||
utils.Weight: 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.05,
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
},
|
||||
}
|
||||
sSpls.SortHighestCost()
|
||||
eOrderedSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
eOrderedSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.2,
|
||||
utils.Weight: 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.1,
|
||||
utils.Weight: 15.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.05,
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -280,12 +280,12 @@ func TestLibSuppliersSortHighestCost(t *testing.T) {
|
||||
}
|
||||
|
||||
//sort based on *acd and *tcd
|
||||
func TestLibSuppliersSortQOS(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
func TestLibRoutesSortQOS(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
//the average value for supplier1 for *acd is 0.5 , *tcd 1.1
|
||||
SupplierID: "supplier1",
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.5,
|
||||
utils.Weight: 10.0,
|
||||
@@ -293,9 +293,9 @@ func TestLibSuppliersSortQOS(t *testing.T) {
|
||||
utils.MetaTCD: 1.1,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
&SortedRoute{
|
||||
//the average value for supplier2 for *acd is 0.5 , *tcd 4.1
|
||||
SupplierID: "supplier2",
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.1,
|
||||
utils.Weight: 15.0,
|
||||
@@ -303,9 +303,9 @@ func TestLibSuppliersSortQOS(t *testing.T) {
|
||||
utils.MetaTCD: 4.1,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
&SortedRoute{
|
||||
//the average value for supplier3 for *acd is 0.4 , *tcd 5.1
|
||||
SupplierID: "supplier3",
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 1.1,
|
||||
utils.Weight: 17.8,
|
||||
@@ -318,10 +318,10 @@ func TestLibSuppliersSortQOS(t *testing.T) {
|
||||
|
||||
//sort base on *acd and *tcd
|
||||
sSpls.SortQOS([]string{utils.MetaACD, utils.MetaTCD})
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier2", "supplier1", "supplier3"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
@@ -331,32 +331,32 @@ func TestLibSuppliersSortQOS(t *testing.T) {
|
||||
}
|
||||
|
||||
//sort based on *acd and *tcd
|
||||
func TestLibSuppliersSortQOS2(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
func TestLibRoutesSortQOS2(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
//the average value for supplier1 for *acd is 0.5 , *tcd 1.1
|
||||
SupplierID: "supplier1",
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 10.0,
|
||||
utils.MetaACD: 0.5,
|
||||
utils.MetaTCD: 1.1,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
&SortedRoute{
|
||||
//the worst value for supplier1 for *acd is 0.5 , *tcd 1.1
|
||||
//supplier1 and supplier2 have the same value for *acd and *tcd
|
||||
//will be sorted based on weight
|
||||
SupplierID: "supplier2",
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 17.0,
|
||||
utils.MetaACD: 0.5,
|
||||
utils.MetaTCD: 1.1,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
&SortedRoute{
|
||||
|
||||
SupplierID: "supplier3",
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.5,
|
||||
utils.Weight: 10.0,
|
||||
@@ -367,10 +367,10 @@ func TestLibSuppliersSortQOS2(t *testing.T) {
|
||||
},
|
||||
}
|
||||
sSpls.SortQOS([]string{utils.MetaACD, utils.MetaTCD})
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier3", "supplier2", "supplier1"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
@@ -380,32 +380,32 @@ func TestLibSuppliersSortQOS2(t *testing.T) {
|
||||
}
|
||||
|
||||
//sort based on *pdd
|
||||
func TestLibSuppliersSortQOS3(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
func TestLibRoutesSortQOS3(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
//the worst value for supplier1 for *pdd is 0.7 , *tcd 1.1
|
||||
//supplier1 and supplier3 have the same value for *pdd
|
||||
//will be sorted based on weight
|
||||
SupplierID: "supplier1",
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 15.0,
|
||||
utils.MetaPDD: 0.7,
|
||||
utils.MetaTCD: 1.1,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
&SortedRoute{
|
||||
//the worst value for supplier2 for *pdd is 1.2, *tcd 1.1
|
||||
SupplierID: "supplier2",
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 10.0,
|
||||
utils.MetaPDD: 1.2,
|
||||
utils.MetaTCD: 1.1,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
&SortedRoute{
|
||||
//the worst value for supplier3 for *pdd is 0.7, *tcd 10.1
|
||||
SupplierID: "supplier3",
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 10.0,
|
||||
utils.MetaPDD: 0.7,
|
||||
@@ -415,10 +415,10 @@ func TestLibSuppliersSortQOS3(t *testing.T) {
|
||||
},
|
||||
}
|
||||
sSpls.SortQOS([]string{utils.MetaPDD})
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier1", "supplier3", "supplier2"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
@@ -427,27 +427,27 @@ func TestLibSuppliersSortQOS3(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortQOS4(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
func TestLibRoutesSortQOS4(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.2,
|
||||
utils.MetaTCD: 15.0,
|
||||
utils.MetaASR: 1.2,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.2,
|
||||
utils.MetaTCD: 20.0,
|
||||
utils.MetaASR: -1.0,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.1,
|
||||
utils.MetaTCD: 10.0,
|
||||
@@ -457,10 +457,10 @@ func TestLibSuppliersSortQOS4(t *testing.T) {
|
||||
},
|
||||
}
|
||||
sSpls.SortQOS([]string{utils.MetaASR, utils.MetaACD, utils.MetaTCD})
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier1", "supplier3", "supplier2"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
@@ -469,11 +469,11 @@ func TestLibSuppliersSortQOS4(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortQOS5(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
func TestLibRoutesSortQOS5(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.2,
|
||||
utils.MetaTCD: 15.0,
|
||||
@@ -481,8 +481,8 @@ func TestLibSuppliersSortQOS5(t *testing.T) {
|
||||
utils.MetaTCC: 10.1,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.2,
|
||||
utils.MetaTCD: 20.0,
|
||||
@@ -490,8 +490,8 @@ func TestLibSuppliersSortQOS5(t *testing.T) {
|
||||
utils.MetaTCC: 10.1,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.1,
|
||||
utils.MetaTCD: 10.0,
|
||||
@@ -502,10 +502,10 @@ func TestLibSuppliersSortQOS5(t *testing.T) {
|
||||
},
|
||||
}
|
||||
sSpls.SortQOS([]string{utils.MetaTCC, utils.MetaASR, utils.MetaACD, utils.MetaTCD})
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier2", "supplier3", "supplier1"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
@@ -514,25 +514,25 @@ func TestLibSuppliersSortQOS5(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortQOS6(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
func TestLibRoutesSortQOS6(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 15.0,
|
||||
utils.MetaACD: 0.2,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 25.0,
|
||||
utils.MetaACD: 0.2,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 20.0,
|
||||
utils.MetaACD: 0.1,
|
||||
@@ -541,10 +541,10 @@ func TestLibSuppliersSortQOS6(t *testing.T) {
|
||||
},
|
||||
}
|
||||
sSpls.SortQOS([]string{utils.MetaACD})
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier2", "supplier1", "supplier3"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
@@ -553,25 +553,25 @@ func TestLibSuppliersSortQOS6(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortQOS7(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
func TestLibRoutesSortQOS7(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 15.0,
|
||||
utils.MetaACD: -1.0,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 25.0,
|
||||
utils.MetaACD: -1.0,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 20.0,
|
||||
utils.MetaACD: -1.0,
|
||||
@@ -580,10 +580,10 @@ func TestLibSuppliersSortQOS7(t *testing.T) {
|
||||
},
|
||||
}
|
||||
sSpls.SortQOS([]string{utils.MetaACD})
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier2", "supplier3", "supplier1"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
@@ -592,25 +592,25 @@ func TestLibSuppliersSortQOS7(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortQOS8(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
func TestLibRoutesSortQOS8(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 15.0,
|
||||
utils.MetaACD: -1.0,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 25.0,
|
||||
utils.MetaACD: -1.0,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 20.0,
|
||||
utils.MetaACD: 10.0,
|
||||
@@ -619,10 +619,10 @@ func TestLibSuppliersSortQOS8(t *testing.T) {
|
||||
},
|
||||
}
|
||||
sSpls.SortQOS([]string{utils.MetaACD})
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier3", "supplier2", "supplier1"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
@@ -631,27 +631,27 @@ func TestLibSuppliersSortQOS8(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortLoadDistribution(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
func TestLibRoutesSortLoadDistribution(t *testing.T) {
|
||||
sSpls := &SortedRoutes{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
&SortedRoute{
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 25.0,
|
||||
utils.Ratio: 4.0,
|
||||
utils.Load: 3.0,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 15.0,
|
||||
utils.Ratio: 10.0,
|
||||
utils.Load: 5.0,
|
||||
},
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
&SortedRoute{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 25.0,
|
||||
utils.Ratio: 1.0,
|
||||
@@ -661,10 +661,10 @@ func TestLibSuppliersSortLoadDistribution(t *testing.T) {
|
||||
},
|
||||
}
|
||||
sSpls.SortLoadDistribution()
|
||||
rcv := make([]string, len(sSpls.SortedSuppliers))
|
||||
rcv := make([]string, len(sSpls.SortedRoutes))
|
||||
eIds := []string{"supplier2", "supplier1", "supplier3"}
|
||||
for i, spl := range sSpls.SortedSuppliers {
|
||||
rcv[i] = spl.SupplierID
|
||||
for i, spl := range sSpls.SortedRoutes {
|
||||
rcv[i] = spl.RouteID
|
||||
}
|
||||
if !reflect.DeepEqual(eIds, rcv) {
|
||||
t.Errorf("Expecting: %+v, \n received: %+v",
|
||||
|
||||
@@ -254,8 +254,8 @@ cgrates.org,FLTR_ACNT_dan,*string,~*req.Account,dan,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_DE,*destinations,~*req.Destination,DST_DE,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_NL,*destinations,~*req.Destination,DST_NL,2014-07-29T15:00:00Z
|
||||
`
|
||||
SuppliersCSVContent = `
|
||||
#Tenant[0],ID[1],FilterIDs[2],ActivationInterval[3],Sorting[4],SortingParameters[5],SupplierID[6],SupplierFilterIDs[7],SupplierAccountIDs[8],SupplierRatingPlanIDs[9],SupplierResourceIDs[10],SupplierStatIDs[11],SupplierWeight[12],SupplierBlocker[13],SupplierParameters[14],Weight[15]
|
||||
RoutesCSVContent = `
|
||||
#Tenant[0],ID[1],FilterIDs[2],ActivationInterval[3],Sorting[4],SortingParameters[5],RouteID[6],RouteFilterIDs[7],RouteAccountIDs[8],RouteRatingPlanIDs[9],RouteResourceIDs[10],RouteStatIDs[11],RouteWeight[12],RouteBlocker[13],RouteParameters[14],Weight[15]
|
||||
cgrates.org,SPP_1,*string:~*req.Account:dan,2014-07-29T15:00:00Z,*least_cost,,supplier1,FLTR_ACNT_dan,Account1;Account1_1,RPL_1,ResGroup1,Stat1,10,true,param1,20
|
||||
cgrates.org,SPP_1,,,,,supplier1,,,RPL_2,ResGroup2,,10,,,
|
||||
cgrates.org,SPP_1,,,,,supplier1,FLTR_DST_DE,Account2,RPL_3,ResGroup3,Stat2,10,,,
|
||||
|
||||
@@ -41,7 +41,7 @@ func init() {
|
||||
RatingPlansCSVContent, RatingProfilesCSVContent, SharedGroupsCSVContent,
|
||||
ActionsCSVContent, ActionPlansCSVContent, ActionTriggersCSVContent, AccountActionsCSVContent,
|
||||
ResourcesCSVContent, StatsCSVContent, ThresholdsCSVContent, FiltersCSVContent,
|
||||
SuppliersCSVContent, AttributesCSVContent, ChargersCSVContent, DispatcherCSVContent,
|
||||
RoutesCSVContent, AttributesCSVContent, ChargersCSVContent, DispatcherCSVContent,
|
||||
DispatcherHostCSVContent), testTPID, "", nil, nil)
|
||||
if err != nil {
|
||||
log.Print("error when creating TpReader:", err)
|
||||
@@ -91,7 +91,7 @@ func init() {
|
||||
if err := csvr.LoadThresholds(); err != nil {
|
||||
log.Print("error in LoadThresholds:", err)
|
||||
}
|
||||
if err := csvr.LoadSupplierProfiles(); err != nil {
|
||||
if err := csvr.LoadRouteProfiles(); err != nil {
|
||||
log.Print("error in LoadSupplierProfiles:", err)
|
||||
}
|
||||
if err := csvr.LoadAttributeProfiles(); err != nil {
|
||||
@@ -1224,9 +1224,9 @@ func TestLoadFilters(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadSupplierProfiles(t *testing.T) {
|
||||
eSppProfiles := map[utils.TenantID]*utils.TPSupplierProfile{
|
||||
utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"}: &utils.TPSupplierProfile{
|
||||
func TestLoadRouteProfiles(t *testing.T) {
|
||||
eSppProfiles := map[utils.TenantID]*utils.TPRouteProfile{
|
||||
utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"}: &utils.TPRouteProfile{
|
||||
TPid: testTPID,
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SPP_1",
|
||||
@@ -1236,27 +1236,27 @@ func TestLoadSupplierProfiles(t *testing.T) {
|
||||
},
|
||||
Sorting: "*least_cost",
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*utils.TPSupplier{
|
||||
&utils.TPSupplier{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
|
||||
AccountIDs: []string{"Account1", "Account1_1", "Account2"},
|
||||
RatingPlanIDs: []string{"RPL_1", "RPL_2", "RPL_3"},
|
||||
ResourceIDs: []string{"ResGroup1", "ResGroup2", "ResGroup3", "ResGroup4"},
|
||||
StatIDs: []string{"Stat1", "Stat2", "Stat3"},
|
||||
Weight: 10,
|
||||
Blocker: true,
|
||||
SupplierParameters: "param1",
|
||||
Routes: []*utils.TPRoute{
|
||||
&utils.TPRoute{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
|
||||
AccountIDs: []string{"Account1", "Account1_1", "Account2"},
|
||||
RatingPlanIDs: []string{"RPL_1", "RPL_2", "RPL_3"},
|
||||
ResourceIDs: []string{"ResGroup1", "ResGroup2", "ResGroup3", "ResGroup4"},
|
||||
StatIDs: []string{"Stat1", "Stat2", "Stat3"},
|
||||
Weight: 10,
|
||||
Blocker: true,
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
Weight: 20,
|
||||
},
|
||||
}
|
||||
resKey := utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"}
|
||||
if len(csvr.sppProfiles) != len(eSppProfiles) {
|
||||
t.Errorf("Failed to load SupplierProfiles: %s", utils.ToIJSON(csvr.sppProfiles))
|
||||
} else if !reflect.DeepEqual(eSppProfiles[resKey], csvr.sppProfiles[resKey]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eSppProfiles[resKey], csvr.sppProfiles[resKey])
|
||||
if len(csvr.routeProfiles) != len(eSppProfiles) {
|
||||
t.Errorf("Failed to load SupplierProfiles: %s", utils.ToIJSON(csvr.routeProfiles))
|
||||
} else if !reflect.DeepEqual(eSppProfiles[resKey], csvr.routeProfiles[resKey]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eSppProfiles[resKey], csvr.routeProfiles[resKey])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -487,7 +487,7 @@ func (rpS *RouteService) sortedRoutesForEvent(args *ArgsGetRoutes) (sortedRoutes
|
||||
return
|
||||
}
|
||||
rPrfl := rPrfs[0]
|
||||
extraOpts, err := args.asOptsGetSuppliers() // convert suppliers arguments into internal options used to limit data
|
||||
extraOpts, err := args.asOptsGetRoutes() // convert suppliers arguments into internal options used to limit data
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -541,7 +541,7 @@ type ArgsGetRoutes struct {
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
|
||||
func (args *ArgsGetRoutes) asOptsGetSuppliers() (opts *optsGetRoutes, err error) {
|
||||
func (args *ArgsGetRoutes) asOptsGetRoutes() (opts *optsGetRoutes, err error) {
|
||||
opts = &optsGetRoutes{ignoreErrors: args.IgnoreErrors}
|
||||
if args.MaxCost == utils.MetaEventCost { // dynamic cost needs to be calculated from event
|
||||
if err = args.CGREvent.CheckMandatoryFields([]string{utils.Account,
|
||||
|
||||
@@ -27,113 +27,113 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
expTimeSuppliers = time.Now().Add(time.Duration(20 * time.Minute))
|
||||
splService *SupplierService
|
||||
dmSPP *DataManager
|
||||
sppTest = SupplierProfiles{
|
||||
&SupplierProfile{
|
||||
expTimeRoutes = time.Now().Add(time.Duration(20 * time.Minute))
|
||||
splService *RouteService
|
||||
dmSPP *DataManager
|
||||
sppTest = RouteProfiles{
|
||||
&RouteProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SupplierProfile1",
|
||||
ID: "RouteProfile1",
|
||||
FilterIDs: []string{"FLTR_SUPP_1"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: expTimeSuppliers,
|
||||
ExpiryTime: expTimeRoutes,
|
||||
},
|
||||
Sorting: utils.MetaWeight,
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*Supplier{
|
||||
Routes: []*Route{
|
||||
{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
Blocker: false,
|
||||
SupplierParameters: "param1",
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
Blocker: false,
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
Weight: 10,
|
||||
},
|
||||
&SupplierProfile{
|
||||
&RouteProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SupplierProfile2",
|
||||
ID: "RouteProfile2",
|
||||
FilterIDs: []string{"FLTR_SUPP_2"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: expTimeSuppliers,
|
||||
ExpiryTime: expTimeRoutes,
|
||||
},
|
||||
Sorting: utils.MetaWeight,
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*Supplier{
|
||||
Routes: []*Route{
|
||||
{
|
||||
ID: "supplier2",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 20.0,
|
||||
SupplierParameters: "param2",
|
||||
ID: "supplier2",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 20.0,
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
{
|
||||
ID: "supplier3",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
SupplierParameters: "param3",
|
||||
ID: "supplier3",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 30.0,
|
||||
Blocker: false,
|
||||
SupplierParameters: "param1",
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 30.0,
|
||||
Blocker: false,
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
Weight: 20.0,
|
||||
},
|
||||
&SupplierProfile{
|
||||
&RouteProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SupplierProfilePrefix",
|
||||
ID: "RouteProfilePrefix",
|
||||
FilterIDs: []string{"FLTR_SUPP_3"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: expTimeSuppliers,
|
||||
ExpiryTime: expTimeRoutes,
|
||||
},
|
||||
Sorting: utils.MetaWeight,
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*Supplier{
|
||||
Routes: []*Route{
|
||||
{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
Blocker: false,
|
||||
SupplierParameters: "param1",
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
Blocker: false,
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
Weight: 10,
|
||||
},
|
||||
}
|
||||
argsGetSuppliers = []*ArgsGetSuppliers{
|
||||
{ //matching SupplierProfile1
|
||||
argsGetRoutes = []*ArgsGetRoutes{
|
||||
{ //matching RouteProfile1
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "utils.CGREvent1",
|
||||
Event: map[string]interface{}{
|
||||
"Supplier": "SupplierProfile1",
|
||||
"Route": "RouteProfile1",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC),
|
||||
"UsageInterval": "1s",
|
||||
"PddInterval": "1s",
|
||||
@@ -141,12 +141,12 @@ var (
|
||||
},
|
||||
},
|
||||
},
|
||||
{ //matching SupplierProfile2
|
||||
{ //matching RouteProfile2
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "utils.CGREvent1",
|
||||
Event: map[string]interface{}{
|
||||
"Supplier": "SupplierProfile2",
|
||||
"Route": "RouteProfile2",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC),
|
||||
"UsageInterval": "1s",
|
||||
"PddInterval": "1s",
|
||||
@@ -154,12 +154,12 @@ var (
|
||||
},
|
||||
},
|
||||
},
|
||||
{ //matching SupplierProfilePrefix
|
||||
{ //matching RouteProfilePrefix
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "utils.CGREvent1",
|
||||
Event: map[string]interface{}{
|
||||
"Supplier": "SupplierProfilePrefix",
|
||||
"Route": "RouteProfilePrefix",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -176,9 +176,9 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func TestSuppliersSort(t *testing.T) {
|
||||
sprs := SupplierProfiles{
|
||||
&SupplierProfile{
|
||||
func TestRoutesSort(t *testing.T) {
|
||||
sprs := RouteProfiles{
|
||||
&RouteProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "supplierprofile1",
|
||||
FilterIDs: []string{},
|
||||
@@ -188,22 +188,22 @@ func TestSuppliersSort(t *testing.T) {
|
||||
},
|
||||
Sorting: "",
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*Supplier{
|
||||
Routes: []*Route{
|
||||
{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
Blocker: false,
|
||||
SupplierParameters: "param1",
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
Blocker: false,
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
Weight: 10,
|
||||
},
|
||||
&SupplierProfile{
|
||||
&RouteProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "supplierprofile2",
|
||||
FilterIDs: []string{},
|
||||
@@ -213,24 +213,24 @@ func TestSuppliersSort(t *testing.T) {
|
||||
},
|
||||
Sorting: "",
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*Supplier{
|
||||
Routes: []*Route{
|
||||
{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 20.0,
|
||||
Blocker: false,
|
||||
SupplierParameters: "param1",
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 20.0,
|
||||
Blocker: false,
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
Weight: 20.0,
|
||||
},
|
||||
}
|
||||
eSupplierProfile := SupplierProfiles{
|
||||
&SupplierProfile{
|
||||
eRouteProfile := RouteProfiles{
|
||||
&RouteProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "supplierprofile2",
|
||||
FilterIDs: []string{},
|
||||
@@ -240,22 +240,22 @@ func TestSuppliersSort(t *testing.T) {
|
||||
},
|
||||
Sorting: "",
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*Supplier{
|
||||
Routes: []*Route{
|
||||
{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 20.0,
|
||||
Blocker: false,
|
||||
SupplierParameters: "param1",
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 20.0,
|
||||
Blocker: false,
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
Weight: 20.0,
|
||||
},
|
||||
&SupplierProfile{
|
||||
&RouteProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "supplierprofile1",
|
||||
FilterIDs: []string{},
|
||||
@@ -265,50 +265,50 @@ func TestSuppliersSort(t *testing.T) {
|
||||
},
|
||||
Sorting: "",
|
||||
SortingParameters: []string{},
|
||||
Suppliers: []*Supplier{
|
||||
Routes: []*Route{
|
||||
{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
Blocker: false,
|
||||
SupplierParameters: "param1",
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{},
|
||||
AccountIDs: []string{},
|
||||
RatingPlanIDs: []string{},
|
||||
ResourceIDs: []string{},
|
||||
StatIDs: []string{},
|
||||
Weight: 10.0,
|
||||
Blocker: false,
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
Weight: 10.0,
|
||||
},
|
||||
}
|
||||
sprs.Sort()
|
||||
if !reflect.DeepEqual(eSupplierProfile, sprs) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eSupplierProfile, sprs)
|
||||
if !reflect.DeepEqual(eRouteProfile, sprs) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eRouteProfile, sprs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersPopulateSupplierService(t *testing.T) {
|
||||
func TestRoutesPopulateRouteService(t *testing.T) {
|
||||
defaultCfg, _ := config.NewDefaultCGRConfig()
|
||||
data := NewInternalDB(nil, nil, true, defaultCfg.DataDbCfg().Items)
|
||||
dmSPP = NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
|
||||
defaultCfg.SupplierSCfg().StringIndexedFields = nil
|
||||
defaultCfg.SupplierSCfg().PrefixIndexedFields = nil
|
||||
splService, err = NewSupplierService(dmSPP, &FilterS{
|
||||
defaultCfg.RouteCfg().StringIndexedFields = nil
|
||||
defaultCfg.RouteCfg().PrefixIndexedFields = nil
|
||||
splService, err = NewRouteService(dmSPP, &FilterS{
|
||||
dm: dmSPP, cfg: defaultCfg}, defaultCfg, nil)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersAddFilters(t *testing.T) {
|
||||
func TestRoutesAddFilters(t *testing.T) {
|
||||
fltrSupp1 := &Filter{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: "FLTR_SUPP_1",
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaString,
|
||||
Element: "~*req.Supplier",
|
||||
Values: []string{"SupplierProfile1"},
|
||||
Element: "~*req.Route",
|
||||
Values: []string{"RouteProfile1"},
|
||||
},
|
||||
{
|
||||
Type: utils.MetaGreaterOrEqual,
|
||||
@@ -329,8 +329,8 @@ func TestSuppliersAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaString,
|
||||
Element: "~*req.Supplier",
|
||||
Values: []string{"SupplierProfile2"},
|
||||
Element: "~*req.Route",
|
||||
Values: []string{"RouteProfile2"},
|
||||
},
|
||||
{
|
||||
Type: utils.MetaGreaterOrEqual,
|
||||
@@ -351,23 +351,23 @@ func TestSuppliersAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaPrefix,
|
||||
Element: "~*req.Supplier",
|
||||
Values: []string{"SupplierProfilePrefix"},
|
||||
Element: "~*req.Route",
|
||||
Values: []string{"RouteProfilePrefix"},
|
||||
},
|
||||
},
|
||||
}
|
||||
dmSPP.SetFilter(fltrSupp3)
|
||||
}
|
||||
|
||||
func TestSuppliersCache(t *testing.T) {
|
||||
func TestRoutesCache(t *testing.T) {
|
||||
for _, spp := range sppTest {
|
||||
if err = dmSPP.SetSupplierProfile(spp, true); err != nil {
|
||||
if err = dmSPP.SetRouteProfile(spp, true); err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
}
|
||||
//Test each supplier profile from cache
|
||||
for _, spp := range sppTest {
|
||||
if tempSpp, err := dmSPP.GetSupplierProfile(spp.Tenant,
|
||||
if tempSpp, err := dmSPP.GetRouteProfile(spp.Tenant,
|
||||
spp.ID, true, true, utils.NonTransactional); err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
} else if !reflect.DeepEqual(spp, tempSpp) {
|
||||
@@ -376,8 +376,8 @@ func TestSuppliersCache(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) {
|
||||
sprf, err := splService.matchingRouteProfilesForEvent(argsGetSuppliers[0].CGREvent, true)
|
||||
func TestRoutesmatchingRouteProfilesForEvent(t *testing.T) {
|
||||
sprf, err := splService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -385,7 +385,7 @@ func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[1].CGREvent, true)
|
||||
sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -393,7 +393,7 @@ func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[2].CGREvent, true)
|
||||
sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -402,189 +402,189 @@ func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersSortedForEvent(t *testing.T) {
|
||||
eFirstSupplierProfile := &SortedSuppliers{
|
||||
ProfileID: "SupplierProfile1",
|
||||
func TestRoutesSortedForEvent(t *testing.T) {
|
||||
eFirstRouteProfile := &SortedRoutes{
|
||||
ProfileID: "RouteProfile1",
|
||||
Sorting: utils.MetaWeight,
|
||||
Count: 1,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
{
|
||||
SupplierID: "supplier1",
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 10.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
}
|
||||
sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[0])
|
||||
sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[0])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf)
|
||||
if !reflect.DeepEqual(eFirstRouteProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eFirstRouteProfile, sprf)
|
||||
}
|
||||
|
||||
eFirstSupplierProfile = &SortedSuppliers{
|
||||
ProfileID: "SupplierProfile2",
|
||||
eFirstRouteProfile = &SortedRoutes{
|
||||
ProfileID: "RouteProfile2",
|
||||
Sorting: utils.MetaWeight,
|
||||
Count: 3,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
{
|
||||
SupplierID: "supplier1",
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 30.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
{
|
||||
SupplierID: "supplier2",
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
{
|
||||
SupplierID: "supplier3",
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 10.0,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
sprf, err = splService.sortedSuppliersForEvent(argsGetSuppliers[1])
|
||||
sprf, err = splService.sortedRoutesForEvent(argsGetRoutes[1])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf)
|
||||
if !reflect.DeepEqual(eFirstRouteProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eFirstRouteProfile, sprf)
|
||||
}
|
||||
|
||||
eFirstSupplierProfile = &SortedSuppliers{
|
||||
ProfileID: "SupplierProfilePrefix",
|
||||
eFirstRouteProfile = &SortedRoutes{
|
||||
ProfileID: "RouteProfilePrefix",
|
||||
Sorting: utils.MetaWeight,
|
||||
Count: 1,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
{
|
||||
SupplierID: "supplier1",
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 10.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
sprf, err = splService.sortedSuppliersForEvent(argsGetSuppliers[2])
|
||||
sprf, err = splService.sortedRoutesForEvent(argsGetRoutes[2])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf)
|
||||
if !reflect.DeepEqual(eFirstRouteProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eFirstRouteProfile, sprf)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersSortedForEventWithLimit(t *testing.T) {
|
||||
eFirstSupplierProfile := &SortedSuppliers{
|
||||
ProfileID: "SupplierProfile2",
|
||||
func TestRoutesSortedForEventWithLimit(t *testing.T) {
|
||||
eFirstRouteProfile := &SortedRoutes{
|
||||
ProfileID: "RouteProfile2",
|
||||
Sorting: utils.MetaWeight,
|
||||
Count: 2,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
{
|
||||
SupplierID: "supplier1",
|
||||
RouteID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 30.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
RouteParameters: "param1",
|
||||
},
|
||||
{
|
||||
SupplierID: "supplier2",
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
},
|
||||
}
|
||||
argsGetSuppliers[1].Paginator = utils.Paginator{
|
||||
argsGetRoutes[1].Paginator = utils.Paginator{
|
||||
Limit: utils.IntPointer(2),
|
||||
}
|
||||
sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1])
|
||||
sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf)
|
||||
if !reflect.DeepEqual(eFirstRouteProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eFirstRouteProfile, sprf)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersSortedForEventWithOffset(t *testing.T) {
|
||||
eFirstSupplierProfile := &SortedSuppliers{
|
||||
ProfileID: "SupplierProfile2",
|
||||
func TestRoutesSortedForEventWithOffset(t *testing.T) {
|
||||
eFirstRouteProfile := &SortedRoutes{
|
||||
ProfileID: "RouteProfile2",
|
||||
Sorting: utils.MetaWeight,
|
||||
Count: 1,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
{
|
||||
SupplierID: "supplier3",
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 10.0,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
RouteParameters: "param3",
|
||||
},
|
||||
},
|
||||
}
|
||||
argsGetSuppliers[1].Paginator = utils.Paginator{
|
||||
argsGetRoutes[1].Paginator = utils.Paginator{
|
||||
Offset: utils.IntPointer(2),
|
||||
}
|
||||
sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1])
|
||||
sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstSupplierProfile), utils.ToJSON(sprf))
|
||||
if !reflect.DeepEqual(eFirstRouteProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstRouteProfile), utils.ToJSON(sprf))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersSortedForEventWithLimitAndOffset(t *testing.T) {
|
||||
eFirstSupplierProfile := &SortedSuppliers{
|
||||
ProfileID: "SupplierProfile2",
|
||||
func TestRoutesSortedForEventWithLimitAndOffset(t *testing.T) {
|
||||
eFirstRouteProfile := &SortedRoutes{
|
||||
ProfileID: "RouteProfile2",
|
||||
Sorting: utils.MetaWeight,
|
||||
Count: 1,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
SortedRoutes: []*SortedRoute{
|
||||
{
|
||||
SupplierID: "supplier2",
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
RouteParameters: "param2",
|
||||
},
|
||||
},
|
||||
}
|
||||
argsGetSuppliers[1].Paginator = utils.Paginator{
|
||||
argsGetRoutes[1].Paginator = utils.Paginator{
|
||||
Limit: utils.IntPointer(1),
|
||||
Offset: utils.IntPointer(1),
|
||||
}
|
||||
sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1])
|
||||
sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstSupplierProfile), utils.ToJSON(sprf))
|
||||
if !reflect.DeepEqual(eFirstRouteProfile, sprf) {
|
||||
t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstRouteProfile), utils.ToJSON(sprf))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersAsOptsGetSuppliers(t *testing.T) {
|
||||
s := &ArgsGetSuppliers{
|
||||
func TestRoutesAsOptsGetRoutes(t *testing.T) {
|
||||
s := &ArgsGetRoutes{
|
||||
IgnoreErrors: true,
|
||||
MaxCost: "10.0",
|
||||
}
|
||||
spl := &optsGetSuppliers{
|
||||
spl := &optsGetRoutes{
|
||||
ignoreErrors: true,
|
||||
maxCost: 10.0,
|
||||
}
|
||||
sprf, err := s.asOptsGetSuppliers()
|
||||
sprf, err := s.asOptsGetRoutes()
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -593,14 +593,14 @@ func TestSuppliersAsOptsGetSuppliers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersAsOptsGetSuppliersIgnoreErrors(t *testing.T) {
|
||||
s := &ArgsGetSuppliers{
|
||||
func TestRoutesAsOptsGetRoutesIgnoreErrors(t *testing.T) {
|
||||
s := &ArgsGetRoutes{
|
||||
IgnoreErrors: true,
|
||||
}
|
||||
spl := &optsGetSuppliers{
|
||||
spl := &optsGetRoutes{
|
||||
ignoreErrors: true,
|
||||
}
|
||||
sprf, err := s.asOptsGetSuppliers()
|
||||
sprf, err := s.asOptsGetRoutes()
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -609,14 +609,14 @@ func TestSuppliersAsOptsGetSuppliersIgnoreErrors(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) {
|
||||
s := &ArgsGetSuppliers{
|
||||
func TestRoutesAsOptsGetRoutesMaxCost(t *testing.T) {
|
||||
s := &ArgsGetRoutes{
|
||||
MaxCost: "10.0",
|
||||
}
|
||||
spl := &optsGetSuppliers{
|
||||
spl := &optsGetRoutes{
|
||||
maxCost: 10.0,
|
||||
}
|
||||
sprf, err := s.asOptsGetSuppliers()
|
||||
sprf, err := s.asOptsGetRoutes()
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -625,9 +625,9 @@ func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuppliersMatchWithIndexFalse(t *testing.T) {
|
||||
splService.cgrcfg.SupplierSCfg().IndexedSelects = false
|
||||
sprf, err := splService.matchingRouteProfilesForEvent(argsGetSuppliers[0].CGREvent, true)
|
||||
func TestRoutesMatchWithIndexFalse(t *testing.T) {
|
||||
splService.cgrcfg.RouteCfg().IndexedSelects = false
|
||||
sprf, err := splService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -635,7 +635,7 @@ func TestSuppliersMatchWithIndexFalse(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[1].CGREvent, true)
|
||||
sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -643,7 +643,7 @@ func TestSuppliersMatchWithIndexFalse(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[2].CGREvent, true)
|
||||
sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREvent, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user