diff --git a/force-app/ereg-handler/classes/KafkaEnhetHandler.cls b/force-app/ereg-handler/classes/KafkaEnhetHandler.cls index 47eec24a..cf13f272 100644 --- a/force-app/ereg-handler/classes/KafkaEnhetHandler.cls +++ b/force-app/ereg-handler/classes/KafkaEnhetHandler.cls @@ -265,8 +265,8 @@ public without sharing class KafkaEnhetHandler implements IKafkaMessageConsumer * @param hasRegisteredEmployees Contains boolean value that indicates if the employer har registered any employees * @return Group of number of employees. */ - private static String getNumberOfEmployeesGroup(Decimal numberOfEmployees, Boolean hasRegisteredEmployees) { - if (numberOfEmployees <= 4 && hasRegisteredEmployees == true) { + public static String getNumberOfEmployeesGroup(Decimal numberOfEmployees, Boolean hasRegisteredEmployees) { + if (hasRegisteredEmployees == true && (numberOfEmployees == null || numberOfEmployees <= 4)) { return '1-4'; } else if (numberOfEmployees >= 5 && numberOfEmployees <= 10) { return '5-10'; diff --git a/force-app/ereg-handler/classes/KafkaEnhetHandlerTest.cls b/force-app/ereg-handler/classes/KafkaEnhetHandlerTest.cls index 96cb8f2a..96415971 100644 --- a/force-app/ereg-handler/classes/KafkaEnhetHandlerTest.cls +++ b/force-app/ereg-handler/classes/KafkaEnhetHandlerTest.cls @@ -114,6 +114,22 @@ public with sharing class KafkaEnhetHandlerTest { } } + @isTest + static void testGetNumberOfEmployeesGroup() { + System.assertEquals('1-4', KafkaEnhetHandler.getNumberOfEmployeesGroup(4, true)); + System.assertEquals('1-4', KafkaEnhetHandler.getNumberOfEmployeesGroup(null, true)); + System.assertEquals('5-10', KafkaEnhetHandler.getNumberOfEmployeesGroup(5, true)); + System.assertEquals('11-25', KafkaEnhetHandler.getNumberOfEmployeesGroup(11, true)); + System.assertEquals('26-50', KafkaEnhetHandler.getNumberOfEmployeesGroup(26, true)); + System.assertEquals('51-100', KafkaEnhetHandler.getNumberOfEmployeesGroup(51, true)); + System.assertEquals('101-250', KafkaEnhetHandler.getNumberOfEmployeesGroup(101, true)); + System.assertEquals('251-500', KafkaEnhetHandler.getNumberOfEmployeesGroup(251, true)); + System.assertEquals('501-1000', KafkaEnhetHandler.getNumberOfEmployeesGroup(501, true)); + System.assertEquals('1000+', KafkaEnhetHandler.getNumberOfEmployeesGroup(1001, true)); + System.assertEquals('0', KafkaEnhetHandler.getNumberOfEmployeesGroup(4, false)); + System.assertEquals('0', KafkaEnhetHandler.getNumberOfEmployeesGroup(0, false)); + } + @isTest private static void testVerifyEmailFormat() { // Valid email addresses