From 5fe972c5022065a15646d072d7d762051cf2acf9 Mon Sep 17 00:00:00 2001 From: Aidan Gordon Date: Sun, 1 Dec 2024 13:44:42 -0800 Subject: [PATCH] Getting codesservice to 100% --- .../gov/nrs/wfprev/services/CodesServiceTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/wfprev-api/src/test/java/ca/bc/gov/nrs/wfprev/services/CodesServiceTest.java b/server/wfprev-api/src/test/java/ca/bc/gov/nrs/wfprev/services/CodesServiceTest.java index bb2d98cc..c3d04a18 100644 --- a/server/wfprev-api/src/test/java/ca/bc/gov/nrs/wfprev/services/CodesServiceTest.java +++ b/server/wfprev-api/src/test/java/ca/bc/gov/nrs/wfprev/services/CodesServiceTest.java @@ -67,6 +67,19 @@ void testGetAllForestAreaCodes_Success() throws ServiceException { assertNotNull(result); } + @Test + void testGetAllForestAreaCodes_Exception() { + // Arrange + when(forestAreaCodeRepository.findAll()).thenThrow(new RuntimeException("Error fetching forest area codes")); + + // Act & Assert + ServiceException exception = assertThrows( + ServiceException.class, + () -> codesService.getAllForestAreaCodes() + ); + assertEquals("Error fetching forest area codes",exception.getMessage()); + } + @Test void testGetForestAreaCodeById_Success() throws ServiceException { // Arrange