Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
764e68a
Add reindex entity
SammiChong Jul 17, 2025
8eae7a8
Add unit tests and metadata exception
SammiChong Jul 31, 2025
6c0017e
Add GET
SammiChong Aug 8, 2025
db33162
Add case_type
SammiChong Aug 8, 2025
c186109
Cleanup
SammiChong Aug 8, 2025
9e4eaa1
Add IT and clean up
SammiChong Aug 11, 2025
434db9c
Format error message
SammiChong Aug 11, 2025
0cb50c5
Revert testing
SammiChong Aug 11, 2025
46b8b3f
Cleanup
SammiChong Aug 11, 2025
8cecdf1
Merge branch 'master' into CME-239
SammiChong Aug 11, 2025
6d27919
Cleanup
SammiChong Aug 11, 2025
1b1835e
Add ActiveProfile to IT
SammiChong Aug 11, 2025
41708b4
Update ElasticsearchBaseTest.java
SammiChong Aug 11, 2025
b14b75b
Update ElasticsearchBaseTest.java
SammiChong Aug 12, 2025
36c9bb7
testing
SammiChong Aug 20, 2025
c9e1768
Add findByIndexName
SammiChong Aug 20, 2025
e3be5a6
Add ReindexPersistService
SammiChong Aug 20, 2025
aa1716a
Fix async transaction issue
SammiChong Aug 20, 2025
29a26fa
Clean up
SammiChong Aug 20, 2025
64d0e22
Replace overwrite with insert to DB
SammiChong Aug 22, 2025
2e585ef
Cleanup - rename and add tests
SammiChong Aug 22, 2025
d4aa313
Add reindex_response
SammiChong Aug 22, 2025
60fbf84
More cleanup
SammiChong Aug 29, 2025
3297c20
Merge branch 'master' into CME-239
SammiChong Aug 29, 2025
6ece42a
Add h2database
SammiChong Sep 2, 2025
3e773cd
Use testcontainers
SammiChong Sep 2, 2025
0d84d90
Add back ElasticsearchContainerInitializer
SammiChong Sep 2, 2025
1061029
Merge branch 'master' into CME-239
SammiChong Sep 3, 2025
6d68668
Return ReindexDTO instead of ReindexEntity
SammiChong Sep 3, 2025
c8bf2a9
Merge branch 'CME-239' of https://github.com/hmcts/ccd-definition-sto…
SammiChong Sep 3, 2025
b57eecb
Fix code smells
SammiChong Sep 3, 2025
d15f5d9
Revert !reindex
SammiChong Sep 3, 2025
3044cf3
Merge branch 'master' into CME-239
SammiChong Sep 8, 2025
a4aafd0
Remove null check
SammiChong Sep 8, 2025
453c3af
Address review comments
SammiChong Sep 10, 2025
5246cf8
Rename ReindexDTO
SammiChong Sep 11, 2025
aa5a82f
Merge branch 'master' into CME-239
SammiChong Sep 11, 2025
f2358dd
Merge branch 'master' into CME-239
SammiChong Sep 16, 2025
54b7265
Merge branch 'CME-238-patch' into CME-239
SammiChong Sep 30, 2025
4046b65
Cleanup, add tests
SammiChong Oct 1, 2025
956fa6b
Merge ReindexTaskService with ReindexService
SammiChong Oct 3, 2025
4ccb25b
Checkstyle
SammiChong Oct 3, 2025
35dbf88
Remove transactional
SammiChong Oct 6, 2025
3deab9b
Update ReindexServiceImpl.java
SammiChong Oct 6, 2025
20c2ffc
Merge branch 'CME-238-patch' into CME-239
SammiChong Oct 8, 2025
f7c1d3d
Fix tests, add reindexResponse
SammiChong Oct 8, 2025
576425f
Merge branch 'master' into CME-239
SammiChong Oct 8, 2025
283f295
Merge branch 'master' into CME-239
SammiChong Oct 8, 2025
82d0749
Merge branch 'CME-238-patch' into CME-239
kiran-yenigala-hmcts Oct 8, 2025
1a7d8bb
Clean import
SammiChong Oct 8, 2025
00e5241
Remove buildResponse, add logging
SammiChong Oct 28, 2025
73b2e5c
Remove reindex column
SammiChong Oct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add h2database
  • Loading branch information
SammiChong committed Sep 2, 2025
commit 6ece42a53580e6ffec9fad4a3e995b41ff48ad7f
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ allprojects {
testImplementation group: 'org.apache.groovy', name: 'groovy-xml', version: groovyVersion
testImplementation group: 'org.apache.groovy', name: 'groovy-json', version: groovyVersion
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.10', classifier: 'all'

testImplementation 'com.h2database:h2'
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void initialiseElasticSearchWhenReindexAndDeleteOldIndexAreTrue() throws IOExcep
verify(ccdElasticClient).reindexData(eq(caseTypeName), eq(incrementedCaseTypeName), any());
verify(ccdElasticClient).setIndexReadOnly(baseIndexName, false);
verify(ccdElasticClient).updateAlias(baseIndexName, caseTypeName, incrementedCaseTypeName);
verify(reindexEntityService).persistSuccess(incrementedCaseTypeName, anyString());
verify(reindexEntityService).persistSuccess(eq(incrementedCaseTypeName), anyString());

verify(ccdElasticClient).removeIndex(caseTypeName);
ArgumentCaptor<String> oldIndexCaptor = ArgumentCaptor.forClass(String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.util.StringUtils;
import uk.gov.hmcts.ccd.definition.store.CaseDataAPIApplication;

Expand All @@ -35,7 +36,8 @@

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = {ServletWebServerFactoryAutoConfiguration.class, ElasticsearchConfigurationIT.class,
CaseDataAPIApplication.class})
CaseDataAPIApplication.class, TestReindexConfig.class, ElasticsearchTestApplication.class})
@ActiveProfiles("test")
public abstract class ElasticsearchBaseTest implements TestUtils {

private static final String GET = "GET";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.hmcts.ccd.definition.store.elastic;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

@SpringBootApplication(scanBasePackages = "uk.gov.hmcts.ccd.definition.store.elastic")
@EnableConfigurationProperties
public class ElasticsearchTestApplication {
public static void main(String[] args) {
SpringApplication.run(ElasticsearchTestApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package uk.gov.hmcts.ccd.definition.store.elastic;

import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import uk.gov.hmcts.ccd.definition.store.domain.service.JurisdictionService;
import uk.gov.hmcts.ccd.definition.store.event.DefinitionImportedEvent;
import uk.gov.hmcts.ccd.definition.store.repository.BannerRepository;
import uk.gov.hmcts.ccd.definition.store.repository.CaseFieldRepository;
import uk.gov.hmcts.ccd.definition.store.repository.CaseTypeLiteRepository;
import uk.gov.hmcts.ccd.definition.store.repository.CaseTypeRepository;
import uk.gov.hmcts.ccd.definition.store.repository.DisplayGroupRepository;
import uk.gov.hmcts.ccd.definition.store.repository.EventRepository;
import uk.gov.hmcts.ccd.definition.store.repository.FieldTypeRepository;
import uk.gov.hmcts.ccd.definition.store.repository.GenericLayoutRepository;
import uk.gov.hmcts.ccd.definition.store.repository.JurisdictionRepository;
import uk.gov.hmcts.ccd.definition.store.repository.JurisdictionUiConfigRepository;
import uk.gov.hmcts.ccd.definition.store.repository.ReindexRepository;
import uk.gov.hmcts.ccd.definition.store.repository.entity.ReindexEntity;
import uk.gov.hmcts.reform.idam.client.IdamApi;
import uk.gov.hmcts.reform.idam.client.IdamClient;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.Optional;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@TestConfiguration
@Profile("test")
public class TestReindexConfig {

@Bean
@Primary
public ReindexEntityService mockReindexEntityService() {
ReindexEntityService mockService = mock(ReindexEntityService.class);

ReindexEntity mockEntity = new ReindexEntity();
mockEntity.setId(1);
mockEntity.setReindex(true);
mockEntity.setDeleteOldIndex(true);
mockEntity.setCaseType("TestCaseType");
mockEntity.setJurisdiction("TestJur");
mockEntity.setIndexName("test-index-000001");
mockEntity.setStartTime(LocalDateTime.now());
mockEntity.setStatus("STARTED");

when(mockService.persistInitialReindexMetadata(any(), any(), any(), any()))
.thenReturn(mockEntity);

doNothing().when(mockService).persistSuccess(any(), any());
doNothing().when(mockService).persistFailure(any(), any());

return mockService;
}

@Bean
@Primary
public ReindexRepository mockReindexRepository() {
ReindexRepository mockRepo = mock(ReindexRepository.class);
when(mockRepo.findByIndexName(any())).thenReturn(Optional.empty());
when(mockRepo.saveAndFlush(any())).thenReturn(new ReindexEntity());
when(mockRepo.save(any())).thenReturn(new ReindexEntity());
doNothing().when(mockRepo).deleteAll();
when(mockRepo.findAll()).thenReturn(Collections.emptyList());
return mockRepo;
}

@Bean
@Primary
public SynchronousElasticDefinitionImportListener mockSynchronousElasticDefinitionImportListener() {
SynchronousElasticDefinitionImportListener mockListener = mock(SynchronousElasticDefinitionImportListener.class);

doNothing().when(mockListener).onDefinitionImported(any(DefinitionImportedEvent.class));

return mockListener;
}

@Bean
@Primary
public FieldTypeRepository mockFieldTypeRepository() {
return mock(FieldTypeRepository.class);
}

@Bean
@Primary
public CaseFieldRepository mockCaseFieldRepository() {
return mock(CaseFieldRepository.class);
}

@Bean
@Primary
public JurisdictionRepository mockJurisdictionRepository() {
return mock(JurisdictionRepository.class);
}

@Bean
@Primary
public JurisdictionUiConfigRepository mockJurisdictionUiConfigRepository() {
return mock(JurisdictionUiConfigRepository.class);
}

@Bean
@Primary
public BannerRepository mockBannerRepository() {
return mock(BannerRepository.class);
}

@Bean
@Primary
public JurisdictionService mockJurisdictionService() {
return mock(JurisdictionService.class);
}

@Bean
@Primary
public GenericLayoutRepository mockLayoutService() {
return mock(GenericLayoutRepository.class);
}

@Bean
@Primary
public DisplayGroupRepository mockDisplayGroupRepository() {
return mock(DisplayGroupRepository.class);
}

@Bean
@Primary
public EventRepository mockEventRepository() {
return mock(EventRepository.class);
}

@Bean
@Primary
public IdamClient mockIdamClient() {
return mock(IdamClient.class);
}

@Bean
@Primary
public IdamApi mockIdamApi() {
return mock(IdamApi.class);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Completely disable OIDC client and provider config
spring.security.oauth2.client.registration=
spring.security.oauth2.client.provider=

# Override the issuer-uri that's causing the connection issue
spring.security.oauth2.client.provider.oidc.issuer-uri=

# Disable flyway + database
spring.flyway.enabled=false

# Avoid elastic health failing test context
management.health.elasticsearch.enabled=false

# Disable component scanning for problematic packages
spring.main.sources=uk.gov.hmcts.ccd.definition.store.elastic
management.endpoints.enabled-by-default=false

# Disable SpringDoc entirely for tests
springdoc.api-docs.enabled=false
springdoc.swagger-ui.enabled=false

# Disable all management endpoints to avoid security issues
management.endpoint.health.enabled=false
management.endpoint.info.enabled=false

# Add to application-test.properties - exclude IDAM auto-configuration
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,org.springdoc.core.configuration.SpringDocConfiguration,org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration,uk.gov.hmcts.reform.idam.client.config.IdamClientAutoConfiguration

# Also disable IDAM properties
idam.api.url=disabled
idam.client.id=disabled
idam.client.secret=disabled

elasticsearch.host=localhost
elasticsearch.port=9200
elasticsearch.scheme=http
elasticsearch.enabled=true
elasticsearch.indexShards=8
elasticsearch.indexShardsReplicas=3
elasticsearch.failImportIfError=true
elasticsearch.dynamic=true