Fix sonarqube issues
This commit is contained in:
@@ -1,22 +1,31 @@
|
||||
package com.mattrixwv.cipherstream.controller;
|
||||
|
||||
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.mattrixwv.cipherstream.aspect.CipherStreamLoggingAspect;
|
||||
import com.mattrixwv.cipherstream.config.FullFilter;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
import tools.jackson.databind.node.ObjectNode;
|
||||
|
||||
|
||||
@Tag("integration-test")
|
||||
@WebMvcTest(controllers = HealthCheckController.class)
|
||||
@@ -24,34 +33,29 @@ import com.mattrixwv.cipherstream.config.FullFilter;
|
||||
public class HealthCheckControllerIntegrationTest{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
//MDC
|
||||
@Mock
|
||||
private MDCAdapter mdc;
|
||||
//Logging
|
||||
//TODO: Fix logger testing
|
||||
/*
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.HealthCheckController")
|
||||
private Logger healthLogger;
|
||||
@Mock(name = "com.mattrixwv.cipherstream.config.FullFilter")
|
||||
private Logger filterLogger;
|
||||
@Mock(name = "com.mattrixwv.cipherstream.aspect.CipherStreamLoggingAspect")
|
||||
protected Logger aspectLogger;
|
||||
*/
|
||||
@MockitoSpyBean
|
||||
private FullFilter fullFilter;
|
||||
//Fields
|
||||
protected ObjectMapper mapper;
|
||||
protected ObjectNode blankNode;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setupJson(){
|
||||
mapper = new ObjectMapper();
|
||||
blankNode = mapper.createObjectNode();
|
||||
}
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void checkFilter() throws ServletException, IOException{
|
||||
verify(fullFilter, times(1)).doFilter(any(), any(), any());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHealthCheck() throws Exception{
|
||||
mockMvc.perform(options("/health"))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
//Verify results
|
||||
//TODO: Fix logger testing
|
||||
/*
|
||||
verify(healthLogger, times(1)).debug("Health check");
|
||||
verifyNoInteractions(filterLogger);
|
||||
verifyNoInteractions(aspectLogger);
|
||||
verify(mdc, times(1)).clear();
|
||||
verifyNoMoreInteractions(mdc);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user