Skip to content

Commit

Permalink
Make sure error message marker is the highest one.
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
  • Loading branch information
techcobweb committed Jan 29, 2025
1 parent 2da3aeb commit 49a35f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ public enum ServletErrorMessage {
GAL5125_ACTION_NOT_PERMITTED (5125, "E: Insufficient privileges to perform the requested operation. Check with your Galasa systems administrator that you have been assigned the correct role with the ''{0}'' action before trying again."),
GAL5126_INTERNAL_RBAC_ERROR (5126, "E: Error occurred when trying to access the Role Based Access Control service. Report the problem to your Galasa systems administrator."),

// Next one to allocate is: 5127
;


// >>>
// >>> Note: Please keep this up to date, to save us wondering what to allocate next...
// >>>
public static final int GALxxx_NEXT_MESSAGE_NUMBER_TO_USE = 5413 ;


private String template ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.junit.Test;

import static dev.galasa.framework.api.common.ServletErrorMessage.GALxxx_NEXT_MESSAGE_NUMBER_TO_USE;
import static org.assertj.core.api.Assertions.*;

import java.util.EnumSet;
Expand All @@ -22,7 +23,7 @@ public void TestCanGetAMessageOutOfTheList() throws Exception {
}

@Test
public void TestAllErrorMessageNumbersAreUnique() throws Exception {
public void testAllErrorMessageNumbersAreUnique() throws Exception {

Map<Integer,ServletErrorMessage> messagesLookedAtSoFar = new HashMap<>();

Expand All @@ -45,4 +46,25 @@ public void TestAllErrorMessageNumbersAreUnique() throws Exception {
assertThat(errorMsg).isBlank();
}

@Test
public void testNextMessageNumberToAllocateIsHighestSoFar() {

int highestMsgNumber = 0 ;
for( ServletErrorMessage msg : EnumSet.allOf(ServletErrorMessage.class)) {
int msgNumber = msg.getTemplateNumber();
if (msgNumber>highestMsgNumber) {
highestMsgNumber = msgNumber;
}
}
assertThat(highestMsgNumber)
.as("Highest message number in use is higher than the GALxxx_NEXT_MESSAGE_NUMBER_TO_USE marker value."+
" Edit the GALxxx_NEXT_MESSAGE_NUMBER_TO_USE value to be higher than that.")
.isLessThan(GALxxx_NEXT_MESSAGE_NUMBER_TO_USE);
}






}

0 comments on commit 49a35f0

Please sign in to comment.