Fix sonarqube issues
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
package com.mattrixwv.cipherstream.controller;
|
||||
|
||||
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
|
||||
|
||||
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;
|
||||
|
||||
@@ -17,58 +25,28 @@ import tools.jackson.databind.node.ObjectNode;
|
||||
@Tag("integration-test")
|
||||
@Import({AopAutoConfiguration.class, FullFilter.class, CipherStreamLoggingAspect.class})
|
||||
public class CipherStreamControllerIntegrationTestBase{
|
||||
protected static final ObjectMapper mapper = new ObjectMapper();
|
||||
//Filter
|
||||
@MockitoSpyBean
|
||||
private FullFilter fullFilter;
|
||||
//Objects
|
||||
protected ObjectNode decodedNode;
|
||||
protected ObjectNode encodedNode;
|
||||
//Fields
|
||||
protected static final String requestId = UUID.randomUUID().toString();
|
||||
protected static final String ipAddress = "192.168.1.1";
|
||||
|
||||
//TODO: Fix Aspect testing
|
||||
//TODO: Fix logger testing
|
||||
//MDC
|
||||
//@Mock
|
||||
//protected MDCAdapter mdc;
|
||||
|
||||
//Base
|
||||
//@Mock(name = "com.mattrixwv.cipherstream.controller.CipherStreamController")
|
||||
//protected Logger baseLogger;
|
||||
protected ObjectMapper mapper;
|
||||
protected ObjectNode blankNode;
|
||||
protected static final String REQUEST_ID = UUID.randomUUID().toString();
|
||||
protected static final String IP_ADDRESS = "192.168.1.1";
|
||||
|
||||
|
||||
//Misc
|
||||
//@Mock(name = "com.mattrixwv.cipherstream.config.FullFilter")
|
||||
//protected Logger filterLogger;
|
||||
//@Mock(name = "com.mattrixwv.cipherstream.aspect.CipherStreamLoggingAspect")
|
||||
//protected Logger aspectLogger;
|
||||
|
||||
|
||||
/*
|
||||
protected void verifyFilter(String url){
|
||||
verify(filterLogger, never()).info(eq("Request parameters: {}"), any(StringBuilder.class));
|
||||
verify(mdc, times(1)).put(eq("requestId"), any());
|
||||
verify(mdc, times(1)).put("ip", ipAddress);
|
||||
verify(mdc, times(1)).put("url", url);
|
||||
verify(mdc, times(1)).clear();
|
||||
@BeforeEach
|
||||
public void setupJson(){
|
||||
mapper = new ObjectMapper();
|
||||
blankNode = mapper.createObjectNode();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
protected void verifyAspectLogging(ObjectNode jsonNode){
|
||||
//Verify the MDC
|
||||
jsonNode.properties().forEach(entry -> {
|
||||
if(entry.getValue().isString()){
|
||||
verify(mdc, times(1)).put(entry.getKey(), entry.getValue().asString());
|
||||
}
|
||||
else{
|
||||
verify(mdc, times(1)).put(entry.getKey(), entry.getValue().toString());
|
||||
}
|
||||
});
|
||||
verifyNoMoreInteractions(mdc);
|
||||
|
||||
//Verify the logger
|
||||
verify(aspectLogger, times(1)).info("CipherStream log");
|
||||
verifyNoMoreInteractions(aspectLogger);
|
||||
@AfterEach
|
||||
public void checkFilter() throws ServletException, IOException{
|
||||
verify(fullFilter, times(1)).doFilter(any(), any(), any());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user