Update integration tests

This commit is contained in:
2024-04-28 16:25:39 -04:00
parent c6d98c72ef
commit 6a8b69371f
26 changed files with 227 additions and 16 deletions

View File

@@ -0,0 +1,53 @@
package com.mattrixwv.cipherstream.controller;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.slf4j.Logger;
import org.slf4j.spi.MDCAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.web.servlet.MockMvc;
import com.mattrixwv.cipherstream.aspect.CipherStreamLoggingAspect;
import com.mattrixwv.cipherstream.config.FullFilter;
@Tag("integration-test")
@WebMvcTest(controllers = HealthCheckController.class)
@Import({AopAutoConfiguration.class, FullFilter.class, CipherStreamLoggingAspect.class})
public class HealthCheckControllerIntegrationTest{
@Autowired
private MockMvc mockMvc;
//MDC
@Mock
private MDCAdapter mdc;
//Logging
@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;
@Test
public void testHealthCheck() throws Exception{
mockMvc.perform(options("/health"))
.andExpect(status().isOk());
//Verify results
verify(healthLogger, times(1)).debug("Health check");
verifyNoInteractions(filterLogger);
verifyNoInteractions(aspectLogger);
verify(mdc, times(1)).clear();
verifyNoMoreInteractions(mdc);
}
}