Skip to content

Commit

Permalink
Merge pull request #385 from navikt/TestNrOfEmployees
Browse files Browse the repository at this point in the history
Created test-class for GetNumberOfEmployeesGroup
  • Loading branch information
raac09 authored Jan 13, 2025
2 parents 024258b + e92541c commit ad7cbfd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions force-app/ereg-handler/classes/KafkaEnhetHandler.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
16 changes: 16 additions & 0 deletions force-app/ereg-handler/classes/KafkaEnhetHandlerTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ad7cbfd

Please sign in to comment.