/*
 * Copyright (C) 2018 the original author or authors.
 *
 * This file is part of jBB Application Project.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may obtain a copy of the License at
 *        http://www.apache.org/licenses/LICENSE-2.0
 */

package org.jbb.lib.restful.error;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.context.MessageSource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.context.request.WebRequest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

@RunWith(MockitoJUnitRunner.class) //TODO - test another handlers
public class RestExceptionHandlerTest {

    @Mock
    private MessageSource messageSourceMock;

    @InjectMocks
    private RestExceptionHandler restExceptionHandler;

    @Test
    public void handleGenericException() {
        // when
        ResponseEntity<Object> responseEntity = restExceptionHandler.handleExceptionInternal(new Exception(), mock(WebRequest.class));

        // then
        assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
@@ -311,16 +311,291 @@
 error;%0A%0A
+import static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.mockito.ArgumentMatchers.any;%0Aimport static org.mockito.BDDMockito.given;%0Aimport static org.mockito.Mockito.mock;%0A%0Aimport java.util.Optional;%0Aimport org.jbb.lib.commons.web.ClientStackTraceProvider;%0A
 import o
@@ -609,16 +609,16 @@
 t.Test;%0A
-
 import o
@@ -950,107 +950,8 @@
 t;%0A%0A
-import static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.mockito.Mockito.mock;%0A%0A
 @Run
@@ -1109,16 +1109,88 @@
 eMock;%0A%0A
+    @Mock%0A    private ClientStackTraceProvider stacktraceProviderMock;%0A%0A
     @Inj
@@ -1264,16 +1264,16 @@
   @Test%0A
-
     publ
@@ -1307,16 +1307,151 @@
 ion() %7B%0A
+        // given%0A        given(stacktraceProviderMock.getClientStackTrace(any()))%0A            .willReturn(Optional.of(%22stacktrace%22));%0A%0A
         

Fix test