SyncMadeEasy/force-app/main/default/classes/FeatureParameterTest.cls

57 lines
1.7 KiB
OpenEdge ABL

@isTest
private class FeatureParameterTest {
@isTest
static void testIncrementMethodsAndFlush() {
// Call all increment methods to populate the internal pending map
FeatureParameter.incrementOrderCount();
FeatureParameter.incrementOrderItemCount();
FeatureParameter.incrementOrderCount(2);
FeatureParameter.incrementOrderItemCount(5);
// Execute flush which internally calls @future incrementAsync()
Test.startTest();
FeatureParameter.flush();
Test.stopTest();
System.assert(true, 'Flush executed successfully after multiple increments.');
}
@isTest
static void testIncrementAsyncWithEmptyMap() {
// Test when deltas map is empty
Map<String, Integer> emptyMap = new Map<String, Integer>();
Test.startTest();
FeatureParameter.incrementAsync(emptyMap);
Test.stopTest();
System.assert(true, 'Handled empty map without error.');
}
@isTest
static void testIncrementAsyncWithValues() {
// Test direct invocation of @future method with data
Map<String, Integer> deltas = new Map<String, Integer>{
'HIC_ShopifySync__Active_Order_Product_Count' => 10,
'HIC_ShopifySync__Active_Order_Count' => 2
};
Test.startTest();
FeatureParameter.incrementAsync(deltas);
Test.stopTest();
System.assert(true, 'incrementAsync executed successfully with data.');
}
@isTest
static void testFlushWithoutPending() {
// Ensure flush works fine even if pending is empty
Test.startTest();
FeatureParameter.flush();
Test.stopTest();
System.assert(true, 'Flush with no pending entries executed successfully.');
}
}