diff --git a/engine/attributes_it_test.go b/engine/attributes_it_test.go index 7173e758b..238c44cde 100644 --- a/engine/attributes_it_test.go +++ b/engine/attributes_it_test.go @@ -119,5 +119,70 @@ func TestNewExternalAttributeProfileFromAttributeProfile(t *testing.T) { if !reflect.DeepEqual(expected, rcv) { t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv)) } - +} + +func TestAttrSProcessEventReplyDigest(t *testing.T) { + eRpl := &AttrSProcessEventReply{ + MatchedProfile: "ATTR_1", + AlteredFields: []string{"Account", "Subject"}, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Context: utils.StringPointer(utils.MetaRating), + Event: map[string]interface{}{ + "Account": "1001", + "Subject": "1001", + "Destination": "+491511231234", + }, + }, + } + expRpl := "Account:1001,Subject:1001" + val := eRpl.Digest() + if !reflect.DeepEqual(val, expRpl) { + t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expRpl), utils.ToJSON(val)) + } +} + +func TestAttrSProcessEventReplyDigest2(t *testing.T) { + eRpl := &AttrSProcessEventReply{ + MatchedProfile: "ATTR_1", + AlteredFields: []string{}, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Context: utils.StringPointer(utils.MetaRating), + Event: map[string]interface{}{ + "Account": "1001", + "Subject": "1001", + "Destination": "+491511231234", + }, + }, + } + expRpl := "" + val := eRpl.Digest() + if !reflect.DeepEqual(val, expRpl) { + t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expRpl), utils.ToJSON(val)) + } +} + +func TestAttrSProcessEventReplyDigest3(t *testing.T) { + eRpl := &AttrSProcessEventReply{ + MatchedProfile: "ATTR_1", + AlteredFields: []string{"Subject"}, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Context: utils.StringPointer(utils.MetaRating), + Event: map[string]interface{}{ + "Account": "1001", + "Subject": "1001", + "Destination": "+491511231234", + }, + }, + } + expRpl := "Subject:1001" + val := eRpl.Digest() + if !reflect.DeepEqual(val, expRpl) { + t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expRpl), utils.ToJSON(val)) + } } diff --git a/engine/libsuppliers_test.go b/engine/libsuppliers_test.go index 296842eb6..03caa9bf2 100644 --- a/engine/libsuppliers_test.go +++ b/engine/libsuppliers_test.go @@ -149,3 +149,72 @@ func TestLibSuppliersSortWeight(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", eSpls.Sorting, result.Sorting) } } + +func TestSortedSuppliersDigest(t *testing.T) { + eSpls := SortedSuppliers{ + ProfileID: "SPL_WEIGHT_1", + Sorting: utils.MetaWeight, + SortedSuppliers: []*SortedSupplier{ + &SortedSupplier{ + SupplierID: "supplier2", + SortingData: map[string]interface{}{ + "Weight": 20.0, + }, + SupplierParameters: "param2", + }, + &SortedSupplier{ + SupplierID: "supplier1", + SortingData: map[string]interface{}{ + "Weight": 10.0, + }, + SupplierParameters: "param1", + }, + }, + } + exp := "supplier2:param2,supplier1:param1" + rcv := eSpls.Digest() + if !reflect.DeepEqual(rcv, exp) { + t.Errorf("Expecting: %+v, received: %+v", exp, rcv) + } +} + +func TestSortedSuppliersDigest2(t *testing.T) { + eSpls := SortedSuppliers{ + ProfileID: "SPL_WEIGHT_1", + Sorting: utils.MetaWeight, + SortedSuppliers: []*SortedSupplier{ + &SortedSupplier{ + SupplierID: "supplier1", + SortingData: map[string]interface{}{ + "Weight": 30.0, + }, + SupplierParameters: "param1", + }, + &SortedSupplier{ + SupplierID: "supplier2", + SortingData: map[string]interface{}{ + "Weight": 20.0, + }, + SupplierParameters: "param2", + }, + }, + } + exp := "supplier1:param1,supplier2:param2" + rcv := eSpls.Digest() + if !reflect.DeepEqual(rcv, exp) { + t.Errorf("Expecting: %+v, received: %+v", exp, rcv) + } +} + +func TestSortedSuppliersDigest3(t *testing.T) { + eSpls := SortedSuppliers{ + ProfileID: "SPL_WEIGHT_1", + Sorting: utils.MetaWeight, + SortedSuppliers: []*SortedSupplier{}, + } + exp := "" + rcv := eSpls.Digest() + if !reflect.DeepEqual(rcv, exp) { + t.Errorf("Expecting: %+v, received: %+v", exp, rcv) + } +}