From 100c00353cea15934a60cdfd35f48b43ee035a16 Mon Sep 17 00:00:00 2001 From: Sriram Kasthuri Date: Tue, 28 Nov 2023 18:11:50 +0000 Subject: [PATCH 1/2] LCAM-1034: Code clean up for Micrometer TraceIdHandler configuration --- crime-evidence/build.gradle | 5 +++++ .../justice/laa/crime/evidence/CrimeEvidenceApplication.java | 3 +-- .../evidence/config/CrimeEvidenceTestConfiguration.java | 2 -- .../evidence/controller/CrimeEvidenceControllerTest.java | 4 ++++ .../evidence/controller/CrimeEvidenceIntegrationTest.java | 2 ++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crime-evidence/build.gradle b/crime-evidence/build.gradle index 23a1d2e..a3455a6 100644 --- a/crime-evidence/build.gradle +++ b/crime-evidence/build.gradle @@ -20,9 +20,14 @@ def versions = [ mockwebserverVersion : "4.10.0", pitest : "1.4.10", commonsLang3Version : "3.10", +<<<<<<< Updated upstream crimeCommonsVersion : "2.7.0", wiremockVersion : "2.35.0", springDocWebMVCVersion : "2.1.0" +======= + crimeCommonsVersion : "2.8.0", + wiremockVersion : "2.35.0" +>>>>>>> Stashed changes ] diff --git a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/CrimeEvidenceApplication.java b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/CrimeEvidenceApplication.java index 7596f54..54dbbb3 100644 --- a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/CrimeEvidenceApplication.java +++ b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/CrimeEvidenceApplication.java @@ -2,13 +2,12 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; -import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; import org.springframework.context.annotation.EnableAspectJAutoProxy; @Slf4j -@SpringBootApplication(exclude = ZipkinAutoConfiguration.class) +@SpringBootApplication @ConfigurationPropertiesScan @EnableAspectJAutoProxy(proxyTargetClass = true) public class CrimeEvidenceApplication { diff --git a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/config/CrimeEvidenceTestConfiguration.java b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/config/CrimeEvidenceTestConfiguration.java index 76e79d5..3d9039b 100644 --- a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/config/CrimeEvidenceTestConfiguration.java +++ b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/config/CrimeEvidenceTestConfiguration.java @@ -2,7 +2,6 @@ import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.security.oauth2.jwt.JwtDecoder; @@ -10,7 +9,6 @@ import java.util.Map; @TestConfiguration -@ComponentScan(basePackages = {"uk.gov.justice.laa.crime.commons.tracing"}) public class CrimeEvidenceTestConfiguration { static final String SUB = "sub"; diff --git a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceControllerTest.java b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceControllerTest.java index 276b00c..0e7f70a 100644 --- a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceControllerTest.java +++ b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceControllerTest.java @@ -15,6 +15,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import uk.gov.justice.laa.crime.commons.tracing.TraceIdHandler; import uk.gov.justice.laa.crime.evidence.CrimeEvidenceApplication; import uk.gov.justice.laa.crime.evidence.config.CrimeEvidenceTestConfiguration; import uk.gov.justice.laa.crime.evidence.data.builder.TestModelDataBuilder; @@ -52,6 +53,9 @@ class CrimeEvidenceControllerTest { @MockBean private EvidenceService evidenceService; + @MockBean + private TraceIdHandler traceIdHandler; + @BeforeEach public void setup() { this.mvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext) diff --git a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceIntegrationTest.java b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceIntegrationTest.java index 260a428..6954804 100644 --- a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceIntegrationTest.java +++ b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceIntegrationTest.java @@ -6,6 +6,7 @@ import com.github.tomakehurst.wiremock.client.WireMock; import org.junit.jupiter.api.*; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.http.HttpMethod; @@ -33,6 +34,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @Import(CrimeEvidenceTestConfiguration.class) @SpringBootTest(classes = CrimeEvidenceApplication.class, webEnvironment = DEFINED_PORT) +@AutoConfigureObservability class CrimeEvidenceIntegrationTest { private static final String CCP_ENDPOINT_URL = "/api/internal/v1/evidence"; From 5503758183929bb635a8b9ccd5689a9b2d95a37c Mon Sep 17 00:00:00 2001 From: Sriram Kasthuri Date: Tue, 28 Nov 2023 18:14:04 +0000 Subject: [PATCH 2/2] LCAM-1034: Code clean up for Micrometer TraceIdHandler configuration --- crime-evidence/build.gradle | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crime-evidence/build.gradle b/crime-evidence/build.gradle index a3455a6..5db36fe 100644 --- a/crime-evidence/build.gradle +++ b/crime-evidence/build.gradle @@ -20,15 +20,9 @@ def versions = [ mockwebserverVersion : "4.10.0", pitest : "1.4.10", commonsLang3Version : "3.10", -<<<<<<< Updated upstream - crimeCommonsVersion : "2.7.0", + crimeCommonsVersion : "2.8.0", wiremockVersion : "2.35.0", springDocWebMVCVersion : "2.1.0" -======= - crimeCommonsVersion : "2.8.0", - wiremockVersion : "2.35.0" ->>>>>>> Stashed changes - ] java {