@@ -223,8 +223,8 @@ void calculateRecommendationsForProject_ParsingFails_ThrowsIllegalStateException
223223 }
224224
225225 @ Test
226- @ DisplayName ("Should wrap AI Gateway exception in IllegalStateException " )
227- void calculateRecommendationsForProject_AiGatewayFails_WrapsException () {
226+ @ DisplayName ("Should throw RuntimeException when AI Gateway fails " )
227+ void calculateRecommendationsForProject_AiGatewayFails_ThrowsRuntimeException () {
228228 // Arrange
229229 RuntimeException aiException = new RuntimeException ("AI Gateway connection failed" );
230230 when (recommendationCalculationConfig .getCalculationConfig ()).thenReturn (testCalculationConfig );
@@ -233,28 +233,25 @@ void calculateRecommendationsForProject_AiGatewayFails_WrapsException() {
233233 when (aiGatewayClient .generate (any ())).thenThrow (aiException );
234234
235235 // Act & Assert
236- IllegalStateException exception = assertThrows (IllegalStateException .class ,
236+ RuntimeException exception = assertThrows (RuntimeException .class ,
237237 () -> recommendationCalculationService .calculateRecommendationsForProject (testProjectInput ));
238238
239- assertTrue (exception .getMessage ().contains ("Failed to calculate recommendations" ));
240- assertTrue (exception .getMessage ().contains (testProjectInput .nodeId ()));
241- assertEquals (aiException , exception .getCause ());
239+ assertEquals ("AI Gateway connection failed" , exception .getMessage ());
242240 }
243241
244242 @ Test
245- @ DisplayName ("Should wrap KPI extraction exception in IllegalStateException " )
246- void calculateRecommendationsForProject_KpiExtractionFails_WrapsException () {
243+ @ DisplayName ("Should throw RuntimeException when KPI extraction fails " )
244+ void calculateRecommendationsForProject_KpiExtractionFails_ThrowsRuntimeException () {
247245 // Arrange
248246 RuntimeException kpiException = new RuntimeException ("KPI data fetch failed" );
249247 when (recommendationCalculationConfig .getCalculationConfig ()).thenReturn (testCalculationConfig );
250248 when (kpiDataExtractionService .fetchKpiDataForProject (testProjectInput )).thenThrow (kpiException );
251249
252250 // Act & Assert
253- IllegalStateException exception = assertThrows (IllegalStateException .class ,
251+ RuntimeException exception = assertThrows (RuntimeException .class ,
254252 () -> recommendationCalculationService .calculateRecommendationsForProject (testProjectInput ));
255253
256- assertTrue (exception .getMessage ().contains ("Failed to calculate recommendations" ));
257- assertEquals (kpiException , exception .getCause ());
254+ assertEquals ("KPI data fetch failed" , exception .getMessage ());
258255
259256 verify (promptService , never ()).getKpiRecommendationPrompt (anyMap (), any ());
260257 verify (aiGatewayClient , never ()).generate (any ());
@@ -276,7 +273,7 @@ void calculateRecommendationsForProject_MissingTTLConfig_ThrowsIllegalStateExcep
276273 IllegalStateException exception = assertThrows (IllegalStateException .class ,
277274 () -> recommendationCalculationService .calculateRecommendationsForProject (testProjectInput ));
278275
279- assertFalse (exception .getMessage ().contains ("TTL configuration not found " ));
276+ assertTrue (exception .getMessage ().contains ("TTL configuration" ));
280277 }
281278
282279 @ Test
0 commit comments