Skip to content

Commit

Permalink
DTSAM-357 Remove unused tasks left over from CCD Data Migration (#966)
Browse files Browse the repository at this point in the history
* DTSAM-357 Remove unused tasks from CCD migration

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Remove unused tasks left over from the CCD data migration.

* DTSAM-357 Remove LaunchDarkly

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Remove LaunchDarkly as no longer in use in this repo.

* DTSAM-357 Refactor unit tests

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Refactor unit tests.

* Bumping chart version/ fixing aliases

* DTSAM-357 Refactor EmailServiceImpl

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Refactor EmailServiceImpl after Sonar warnings.

* DTSAM-357 Move Flyway to Integration Tests.

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Move Flyway to Integration Tests: as not required for main code.

* DTSAM-357 Use WithSpan annotation on tasks.

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Use WithSpan annotation on remaining tasks to group AppInsight logs.

* DTSAM-357 Refactor unit tests

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Refactor unit tests: move RoleAssignmentHistoryTest.

* DTSAM-357 Refactor tasks for Sonar issue

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Refactor tasks for Sonar issue.

* DTSAM-357 Remove tomcat dependency from job

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Remove tomcat dependency from job: as no webservice in use.

* DTSAM-357 Refactor integration tests

   [DTSAM-357](https://tools.hmcts.net/jira/browse/DTSAM-357)

Refactor integration tests.

* Bumping chart version/ fixing aliases

* Add sonar labels to readme

---------

Co-authored-by: hmcts-jenkins-a-to-c <62422075+hmcts-jenkins-a-to-c[bot]@users.noreply.github.com>
Co-authored-by: mikebrownccd <104495891+mikebrownccd@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 10, 2024
1 parent 388ac90 commit 85ab735
Show file tree
Hide file tree
Showing 70 changed files with 427 additions and 4,064 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# am-role-assignment-batch-service

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=am-role-assignment-batch-service&metric=alert_status)](https://sonarcloud.io/summary/overall?id=am-role-assignment-batch-service)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=am-role-assignment-batch-service&metric=security_rating)](https://sonarcloud.io/summary/overall?id=am-role-assignment-batch-service)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=am-role-assignment-batch-service&metric=vulnerabilities)](https://sonarcloud.io/summary/overall?id=am-role-assignment-batch-service)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=am-role-assignment-batch-service&metric=sqale_rating)](https://sonarcloud.io/summary/overall?id=am-role-assignment-batch-service)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=am-role-assignment-batch-service&metric=coverage)](https://sonarcloud.io/summary/overall?id=am-role-assignment-batch-service)

Role Assignment Batch Service

## Purpose
Expand All @@ -11,7 +17,7 @@ This is spring batch application scheduled with Kubernetes and runs once in a da

To run the project you will need to have the following installed:

* Java 11
* Java 17
* Docker

please ensure the following application components are already running:
Expand Down
22 changes: 15 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def versions = [
spring : '5.3.39',
springSecurity : '5.8.14',
sonarPitest : '0.5',
tomcat : '9.0.93',
rest_assured : '3.3.0',
feign_jackson : '13.3',
jacksondata : '2.17.2',
Expand Down Expand Up @@ -95,6 +94,14 @@ sourceSets {
}
}

idea {
module {
// config to allow IntelliJ to mark test source and resource files correctly to help linting tools
testSources.from(java.sourceSets.integrationTest.java.srcDirs)
testResources.from(java.sourceSets.integrationTest.resources.srcDirs)
}
}

tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror"
}
Expand All @@ -116,7 +123,7 @@ task fortifyScan(type: JavaExec) {
}

jacocoTestReport {
executionData(test)
executionData(test, integration)
reports {
xml.required = true
csv.required = false
Expand Down Expand Up @@ -148,7 +155,9 @@ sonarqube {
property "sonar.projectName", "am-role-assignment-batch-service"
property "sonar.projectKey", "am-role-assignment-batch-service"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"
property "sonar.exclusions", "**/RoleAssignmentBatchApplication.java,"+ "**/roleassignmentbatch/**.java,"+ "**/util/**.java,"+"**/RenameTablesPostMigration.java,"+"**/ReplicateTablesTasklet.java"
property "sonar.exclusions",
"src/main/java/uk/gov/hmcts/reform/roleassignmentbatch/*Application.java," +
"src/main/java/uk/gov/hmcts/reform/roleassignmentbatch/config/**"
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
}
Expand Down Expand Up @@ -242,14 +251,11 @@ dependencies {
implementation group: 'javax.inject', name: 'javax.inject', version: '1'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.7.4'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.reformLogging
implementation group: 'com.launchdarkly', name: 'launchdarkly-java-server-sdk' , version: '5.10.9'
implementation group: 'com.google.guava', name: 'guava', version: '33.2.1-jre'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '9.22.3'
implementation group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: versions.tomcat
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: versions.tomcat

implementation group: 'com.microsoft.azure', name: 'applicationinsights-spring-boot-starter', version: '2.6.4'
implementation group: 'io.opentelemetry.instrumentation', name: 'opentelemetry-instrumentation-annotations', version: '1.33.4'

testImplementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.16'
testImplementation group: 'org.springframework.batch', name: 'spring-batch-test'
Expand Down Expand Up @@ -280,6 +286,8 @@ dependencies {
integrationTestImplementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: versions.serenity
integrationTestImplementation group: 'net.serenity-bdd', name: 'serenity-spring', version: versions.serenity

integrationTestImplementation group: 'org.flywaydb', name: 'flyway-core', version: '9.22.3'

integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath

Expand Down
2 changes: 1 addition & 1 deletion charts/am-role-assignment-batch-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: "1.0"
description: A Helm chart for AM Role Assignment Batch Service
name: am-role-assignment-batch-service
home: https://github.com/hmcts/am-role-assignment-batch-service
version: 0.0.48
version: 0.0.49
maintainers:
- name: Access Management Team
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion charts/am-role-assignment-batch-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ job:
- name: role-assignment-batch-service-EMAIL-LIST
alias: EMAIL_LIST
environment:
BATCH_ENV: "{{ .Values.global.environment }}"
EMAIL_ENABLED: false
ROLE_ASSIGNMENT_DB_PORT: 5432
ROLE_ASSIGNMENT_DB_NAME: role_assignment
JUDICIAL_BOOKING_SERVICE_POSTGRES_PORT: 5432
JUDICIAL_BOOKING_SERVICE_POSTGRES_DATABASE: judicial_booking
LAUNCH_DARKLY_ENV: "{{ .Values.global.environment }}"
postgresql:
enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,29 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import uk.gov.hmcts.reform.roleassignmentbatch.exception.BadDayConfigForJudicialRecords;
import uk.gov.hmcts.reform.roleassignmentbatch.service.EmailService;
import uk.gov.hmcts.reform.roleassignmentbatch.task.DeleteJudicialExpiredRecords;

import javax.sql.DataSource;

@SpringBootTest
@RunWith(SpringIntegrationSerenityRunner.class)
@ContextConfiguration(classes = BaseTest.class)
public class JudicalBookingBatchJobIntegrationTest extends BaseTest {
public class JudicialBookingBatchJobIntegrationTest extends BaseTest {

private static final Logger logger = LoggerFactory.getLogger(JudicalBookingBatchJobIntegrationTest.class);
private static final Logger logger = LoggerFactory.getLogger(JudicialBookingBatchJobIntegrationTest.class);
private DeleteJudicialExpiredRecords sut;

@Autowired
@Qualifier("rasDataSource")
private DataSource rasDataSource;

@Autowired
@Qualifier("judicialDataSource")
private DataSource judicialDataSource;

private JdbcTemplate template;
@Mock
EmailService emailService = Mockito.mock(EmailService.class);

@Mock
StepExecution stepExecution = Mockito.mock(StepExecution.class);
Expand All @@ -61,8 +58,7 @@ public class JudicalBookingBatchJobIntegrationTest extends BaseTest {

@Before
public void setUp() {
template = new JdbcTemplate(judicialDataSource);
sut = new DeleteJudicialExpiredRecords(judicialDataSource, 0);
sut = new DeleteJudicialExpiredRecords(emailService, judicialDataSource, 0);
Mockito.when(stepContribution.getStepExecution()).thenReturn(stepExecution);
Mockito.when(stepContribution.getStepExecution().getJobExecution()).thenReturn(jobExecution);
Mockito.when(stepContribution.getStepExecution().getJobExecution().getId()).thenReturn(Long.valueOf(1));
Expand Down Expand Up @@ -94,7 +90,7 @@ public void shouldDeleteLiveJudicialRecords() {
@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, config = @SqlConfig(dataSource = "judicialDataSource"),
scripts = {"classpath:sql/judicial/insert_judicial_database.sql"})
public void shouldNotDeleteLiveJudicialRecordsForDaysParam() {
sut = new DeleteJudicialExpiredRecords(judicialDataSource, 50);
sut = new DeleteJudicialExpiredRecords(emailService, judicialDataSource, 50);

Integer totalRecords = sut.getTotalJudicialRecords();
logger.info("Total number of Judicial records in Database::{}", totalRecords);
Expand All @@ -121,7 +117,7 @@ public void shouldNotDeleteLiveJudicialRecordsForDaysParam() {
scripts = {"classpath:sql/judicial/insert_judicial_database.sql"})
public void shouldThrowExceptionForBadDayInput() {

sut = new DeleteJudicialExpiredRecords(judicialDataSource, -5);
sut = new DeleteJudicialExpiredRecords(emailService, judicialDataSource, -5);
sut.execute(stepContribution, chunkContext);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import uk.gov.hmcts.reform.roleassignmentbatch.service.EmailService;
import uk.gov.hmcts.reform.roleassignmentbatch.task.DeleteExpiredRecords;

@SpringBootTest
Expand All @@ -46,6 +47,9 @@ public class RoleAssignmentBatchJobIntegrationTest extends BaseTest {

private JdbcTemplate template;

@Mock
private EmailService emailService;

@Mock
StepExecution stepExecution = Mockito.mock(StepExecution.class);

Expand All @@ -64,7 +68,7 @@ public class RoleAssignmentBatchJobIntegrationTest extends BaseTest {
@Before
public void setUp() {
template = new JdbcTemplate(ds);
sut = new DeleteExpiredRecords(template, 2);
sut = new DeleteExpiredRecords(emailService, template, 2);
Mockito.when(stepContribution.getStepExecution()).thenReturn(stepExecution);
Mockito.when(stepContribution.getStepExecution().getJobExecution()).thenReturn(jobExecution);
Mockito.when(stepContribution.getStepExecution().getJobExecution().getId()).thenReturn(Long.valueOf(1));
Expand Down
49 changes: 2 additions & 47 deletions src/integrationTest/resources/application-test.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
server:
port: ${PORT:4099}

management:
health:
db:
enabled: true
defaults:
enabled: true
diskspace:
enabled: true
endpoint:
health:
enabled: true
cache:
time-to-live: 5s
show-details: "always"
endpoints:
web:
base-path: /
exposure:
include: 'health'

#If you use a database then uncomment below lines and update db properties accordingly

spring:
application:
Expand Down Expand Up @@ -87,32 +63,11 @@ delete-expired-judicial-records: deleteExpiredJudicialRecords
batchjob-name: deleteExpiredRecords
batch-size: 4

csv-file-name: book2.csv
migration:
masterFlag: ${CCD_AM_MIGRATION_MASTER_FLAG:true}
renameTables: ${CCD_AM_MIGRATION_RENAME_TABLES_FLAG:false}
chunkSize: ${CHUNK_SIZE:1000}

azure:
container-name: amccdras
account-name: ${AZURE_BLOB_STORAGE_ACCOUNT:amdatamigrationstorage}
account-key: ${AZURE_BLOB_STORAGE_ACCOUNT_KEY:}

ccd:
roleNames: ${ROLE_NAMES:[PETSOLICITOR],[RESPSOLICITOR],[BARRISTER],[CAFCASSSOLICITOR],[EPSMANAGING],[LABARRISTER],[LAMANAGING],
[LASOLICITOR],[SOLICITOR],[SOLICITORA],[SOLICITORB],[SOLICITORC],[SOLICITORD],[SOLICITORE],
[SOLICITORF],[SOLICITORG],[SOLICITORH],[SOLICITORI],[SOLICITORJ],[LEGALREPRESENTATIVE],[CREATOR]}
roleCategories: ${ROLE_CATEGORIES:PROFESSIONAL,CITIZEN,JUDICIAL,LEGAL_OPERATIONS}

launchdarkly:
sdk:
key: ${LD_SDK_KEY:}
environment: ${LAUNCH_DARKLY_ENV:pr}
user: am-${LAUNCH_DARKLY_ENV:local}
batch-environment: ${BATCH_ENV:local}

logging.level.org.springframework.batch.core.step.item.ChunkMonitor: ${APPLICATION_LOGGING_LEVEL:ERROR}

sendgrid:
key: ${AM_SENDGRID_API_KEY:dummyValue}
mail:
from: ${AM_SENDGRID_API_EMAIL_FROM:no-reply@mail-am-nonprod.platform.hmcts.net}
from: ${AM_SENDGRID_API_EMAIL_FROM:no-reply@mail-am-nonprod.platform.hmcts.net}
5 changes: 0 additions & 5 deletions src/integrationTest/resources/book2.csv

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.hmcts.reform.roleassignmentbatch.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.thymeleaf.ITemplateEngine;
import org.thymeleaf.spring5.SpringTemplateEngine;

@Configuration
public class AppConfiguration {

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}

@Bean public ConversionService conversionService() {
return new DefaultConversionService();
}

@Bean
public ITemplateEngine springTemplateEngine() {
return new SpringTemplateEngine();
}

}

This file was deleted.

Loading

0 comments on commit 85ab735

Please sign in to comment.