From f1641e1df2bfb2a7afc9010c7e4dc3586cd1f993 Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Fri, 21 Oct 2022 09:54:22 +0100 Subject: [PATCH] PI-483 Removed messaging/client dependencies (#285) --- .../build.gradle.kts | 9 +---- .../deploy/values.yml | 1 - .../justice/digital/hmpps/IntegrationTest.kt | 31 ----------------- .../digital/hmpps/config/FeignOAuth2Config.kt | 15 --------- .../example/ExampleFeignClient.kt | 16 --------- .../digital/hmpps/listener/MessageListener.kt | 18 ---------- .../hmpps/listener/MessageListenerTest.kt | 33 ------------------- 7 files changed, 1 insertion(+), 122 deletions(-) delete mode 100644 projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/FeignOAuth2Config.kt delete mode 100644 projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/example/ExampleFeignClient.kt delete mode 100644 projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/MessageListener.kt delete mode 100644 projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/listener/MessageListenerTest.kt diff --git a/projects/approved-premises-and-delius/build.gradle.kts b/projects/approved-premises-and-delius/build.gradle.kts index 0cdd88100..b45dd8ddf 100644 --- a/projects/approved-premises-and-delius/build.gradle.kts +++ b/projects/approved-premises-and-delius/build.gradle.kts @@ -8,7 +8,6 @@ dependencies { implementation(project(":libs:oauth-client")) implementation(project(":libs:oauth-server")) - implementation("org.springframework:spring-jms") implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation("org.springframework.boot:spring-boot-starter-security") @@ -17,13 +16,11 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") - implementation(libs.amazon.sqs) implementation(libs.openfeign) implementation(libs.sentry) implementation(libs.swagger.docs) dev(project(":libs:dev-tools")) - dev("org.springframework.boot:spring-boot-starter-activemq") dev("com.h2database:h2") dev(libs.hawtio) @@ -34,9 +31,5 @@ dependencies { } configure { - jacocoExclusions = listOf( - "**/config/**", - "**/entity/**", - "**/AppKt.class" - ) + jacocoExclusions = listOf("**/AppKt.class") } diff --git a/projects/approved-premises-and-delius/deploy/values.yml b/projects/approved-premises-and-delius/deploy/values.yml index a3645232b..9f06e7c66 100644 --- a/projects/approved-premises-and-delius/deploy/values.yml +++ b/projects/approved-premises-and-delius/deploy/values.yml @@ -8,7 +8,6 @@ secrets: SPRING_DATASOURCE_URL: /delius-database/jdbc-url SPRING_DATASOURCE_USERNAME: /approved-premises-and-delius/db-username SPRING_DATASOURCE_PASSWORD: /approved-premises-and-delius/db-password - SPRING_JMS_TEMPLATE_DEFAULT-DESTINATION: /approved-premises-and-delius/sqs-queue-name OAUTH2_CLIENT-ID: /approved-premises-and-delius/client-id OAUTH2_CLIENT-SECRET: /approved-premises-and-delius/client-secret SENTRY_DSN: /approved-premises-and-delius/sentry-dsn diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 7346d5a98..e8b2bccd5 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -2,53 +2,22 @@ package uk.gov.justice.digital.hmpps import com.github.tomakehurst.wiremock.WireMockServer import org.junit.jupiter.api.Test -import org.mockito.Mockito.atLeastOnce -import org.mockito.kotlin.verify import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.jms.core.JmsTemplate import org.springframework.test.context.ActiveProfiles import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator -import uk.gov.justice.digital.hmpps.jms.convertSendAndWait -import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.security.withOAuth2Token -import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import java.util.concurrent.TimeoutException @AutoConfigureMockMvc @ActiveProfiles("integration-test") @SpringBootTest(webEnvironment = RANDOM_PORT) internal class IntegrationTest { - @Value("\${spring.jms.template.default-destination}") lateinit var queueName: String - @Autowired lateinit var mockMvc: MockMvc @Autowired lateinit var wireMockServer: WireMockServer - @Autowired lateinit var jmsTemplate: JmsTemplate - - @MockBean lateinit var telemetryService: TelemetryService - - @Test - fun `message is logged to telemetry`() { - // Given a message - val notification = Notification(message = MessageGenerator.EXAMPLE) - - // When it is received - try { - jmsTemplate.convertSendAndWait(queueName, notification) - } catch (_: TimeoutException) { - // Note: Remove this try/catch when the MessageListener logic has been implemented - } - - // Then it is logged to telemetry - verify(telemetryService, atLeastOnce()).notificationReceived(notification) - } @Test fun `API call retuns a success response`() { diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/FeignOAuth2Config.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/FeignOAuth2Config.kt deleted file mode 100644 index 8624f9135..000000000 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/FeignOAuth2Config.kt +++ /dev/null @@ -1,15 +0,0 @@ -package uk.gov.justice.digital.hmpps.config - -import org.springframework.cloud.openfeign.EnableFeignClients -import org.springframework.context.annotation.Configuration -import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager -import uk.gov.justice.digital.hmpps.config.feign.FeignConfig -import uk.gov.justice.digital.hmpps.integrations.example.ExampleFeignClient - -@Configuration -@EnableFeignClients(clients = [ExampleFeignClient::class]) -class FeignOAuth2Config( - authorizedClientManager: OAuth2AuthorizedClientManager -) : FeignConfig(authorizedClientManager) { - override fun registrationId() = "approved-premises-and-delius" -} diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/example/ExampleFeignClient.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/example/ExampleFeignClient.kt deleted file mode 100644 index 05ca07cb5..000000000 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/example/ExampleFeignClient.kt +++ /dev/null @@ -1,16 +0,0 @@ -package uk.gov.justice.digital.hmpps.integrations.example - -import org.springframework.cloud.openfeign.FeignClient -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.PathVariable -import uk.gov.justice.digital.hmpps.config.FeignOAuth2Config - -@FeignClient( - name = "example", - url = "\${integrations.example.url}", - configuration = [FeignOAuth2Config::class] -) -interface ExampleFeignClient { - @GetMapping(value = ["/example/{inputId}"]) - fun getExampleAPICall(@PathVariable("inputId") inputId: String): String -} diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/MessageListener.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/MessageListener.kt deleted file mode 100644 index 20bf39a9b..000000000 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/MessageListener.kt +++ /dev/null @@ -1,18 +0,0 @@ -package uk.gov.justice.digital.hmpps.listener - -import org.springframework.jms.annotation.EnableJms -import org.springframework.jms.annotation.JmsListener -import org.springframework.stereotype.Component -import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent -import uk.gov.justice.digital.hmpps.message.Notification -import uk.gov.justice.digital.hmpps.telemetry.TelemetryService - -@Component -@EnableJms -class MessageListener(private val telemetryService: TelemetryService) { - @JmsListener(destination = "\${spring.jms.template.default-destination}") - fun receive(notification: Notification) { - telemetryService.notificationReceived(notification) - TODO("Not yet implemented") - } -} diff --git a/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/listener/MessageListenerTest.kt b/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/listener/MessageListenerTest.kt deleted file mode 100644 index f100c3857..000000000 --- a/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/listener/MessageListenerTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package uk.gov.justice.digital.hmpps.listener - -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -import org.mockito.InjectMocks -import org.mockito.Mock -import org.mockito.junit.jupiter.MockitoExtension -import org.mockito.kotlin.verify -import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator -import uk.gov.justice.digital.hmpps.message.Notification -import uk.gov.justice.digital.hmpps.telemetry.TelemetryService - -@ExtendWith(MockitoExtension::class) -internal class MessageListenerTest { - @Mock lateinit var telemetryService: TelemetryService - @InjectMocks lateinit var messageListener: MessageListener - - @Test - fun `message is logged to telemetry`() { - // Given a message - val notification = Notification(message = MessageGenerator.EXAMPLE) - - // When it is received - try { - messageListener.receive(notification) - } catch (_: NotImplementedError) { - // Note: Remove this try/catch when the MessageListener logic has been implemented - } - - // Then it is logged to telemetry - verify(telemetryService).notificationReceived(notification) - } -}