diff --git a/src/main/java/uk/gov/hmcts/opal/controllers/develop/ChequeController.java b/src/main/java/uk/gov/hmcts/opal/controllers/develop/ChequeController.java new file mode 100644 index 000000000..e72b81ecf --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/controllers/develop/ChequeController.java @@ -0,0 +1,58 @@ +package uk.gov.hmcts.opal.controllers.develop; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.ChequeEntity; +import uk.gov.hmcts.opal.service.ChequeServiceInterface; + +import java.util.List; + +import static uk.gov.hmcts.opal.util.HttpUtil.buildResponse; + + +@RestController +@RequestMapping("/dev/cheque") +@Slf4j(topic = "ChequeController") +@Tag(name = "Cheque Controller") +public class ChequeController { + + private final ChequeServiceInterface chequeService; + + public ChequeController(@Qualifier("chequeService") ChequeServiceInterface chequeService) { + this.chequeService = chequeService; + } + + @GetMapping(value = "/{chequeId}") + @Operation(summary = "Returns the Cheque for the given chequeId.") + public ResponseEntity getChequeById(@PathVariable Long chequeId) { + + log.info(":GET:getChequeById: chequeId: {}", chequeId); + + ChequeEntity response = chequeService.getCheque(chequeId); + + return buildResponse(response); + } + + @PostMapping(value = "/search", consumes = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Searches Cheques based upon criteria in request body") + public ResponseEntity> postChequesSearch(@RequestBody ChequeSearchDto criteria) { + log.info(":POST:postChequesSearch: query: \n{}", criteria); + + List response = chequeService.searchCheques(criteria); + + return buildResponse(response); + } + + +} diff --git a/src/main/java/uk/gov/hmcts/opal/dto/search/ChequeSearchDto.java b/src/main/java/uk/gov/hmcts/opal/dto/search/ChequeSearchDto.java new file mode 100644 index 000000000..5e40c54e7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/dto/search/ChequeSearchDto.java @@ -0,0 +1,14 @@ +package uk.gov.hmcts.opal.dto.search; + +import lombok.Builder; +import lombok.Data; +import uk.gov.hmcts.opal.dto.ToJsonString; + +@Data +@Builder +public class ChequeSearchDto implements ToJsonString { + + private String chequeId; + private String businessUnitId; + +} diff --git a/src/main/java/uk/gov/hmcts/opal/entity/ChequeEntity.java b/src/main/java/uk/gov/hmcts/opal/entity/ChequeEntity.java new file mode 100644 index 000000000..b89abb43f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/entity/ChequeEntity.java @@ -0,0 +1,71 @@ +package uk.gov.hmcts.opal.entity; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.SequenceGenerator; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.time.LocalDate; + +@Entity +@Table(name = "cheques") +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "chequeId") +public class ChequeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cheque_id_seq_generator") + @SequenceGenerator(name = "cheque_id_seq_generator", sequenceName = "cheque_id_seq", allocationSize = 1) + @Column(name = "cheque_id", nullable = false) + private Long chequeId; + + @ManyToOne + @JoinColumn(name = "business_unit_id", nullable = false) + private BusinessUnitEntity businessUnit; + + @Column(name = "cheque_number", nullable = false) + private Long chequeNumber; + + @Column(name = "issue_date", nullable = false) + @Temporal(TemporalType.DATE) + private LocalDate issueDate; + + @Column(name = "creditor_transaction_id") + private Long creditorTransactionId; + + @Column(name = "defendant_transaction_id") + private Long defendantTransactionId; + + @Column(name = "amount", precision = 18, scale = 2, nullable = false) + private BigDecimal amount; + + @Column(name = "allocation_type", length = 10) + private String allocationType; + + @Column(name = "reminder_date") + @Temporal(TemporalType.DATE) + private LocalDate reminderDate; + + @Column(name = "status", length = 1, nullable = false) + private String status; + +} diff --git a/src/main/java/uk/gov/hmcts/opal/repository/ChequeRepository.java b/src/main/java/uk/gov/hmcts/opal/repository/ChequeRepository.java new file mode 100644 index 000000000..b902174c6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/repository/ChequeRepository.java @@ -0,0 +1,11 @@ +package uk.gov.hmcts.opal.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; +import uk.gov.hmcts.opal.entity.ChequeEntity; + +@Repository +public interface ChequeRepository extends JpaRepository, + JpaSpecificationExecutor { +} diff --git a/src/main/java/uk/gov/hmcts/opal/repository/jpa/ChequeSpecs.java b/src/main/java/uk/gov/hmcts/opal/repository/jpa/ChequeSpecs.java new file mode 100644 index 000000000..230d33cd1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/repository/jpa/ChequeSpecs.java @@ -0,0 +1,38 @@ +package uk.gov.hmcts.opal.repository.jpa; + +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import org.springframework.data.jpa.domain.Specification; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.BusinessUnitEntity; +import uk.gov.hmcts.opal.entity.ChequeEntity; +import uk.gov.hmcts.opal.entity.ChequeEntity_; + +import static uk.gov.hmcts.opal.repository.jpa.BusinessUnitSpecs.equalsBusinessUnitIdPredicate; + +public class ChequeSpecs extends EntitySpecs { + + public Specification findBySearchCriteria(ChequeSearchDto criteria) { + return Specification.allOf(specificationList( + notBlank(criteria.getChequeId()).map(ChequeSpecs::equalsChequeId), + numericShort(criteria.getBusinessUnitId()).map(ChequeSpecs::equalsBusinessUnitId) + )); + } + + public static Specification equalsChequeId(String chequeId) { + return (root, query, builder) -> builder.equal(root.get(ChequeEntity_.chequeId), chequeId); + } + + public static Specification equalsBusinessUnitId(Short businessUnitId) { + return (root, query, builder) -> + equalsBusinessUnitIdPredicate(joinBusinessUnit(root), builder, businessUnitId); + } + + public static Specification equalsChequeNumber(String chequeNumber) { + return (root, query, builder) -> builder.equal(root.get(ChequeEntity_.chequeNumber), chequeNumber); + } + + public static Join joinBusinessUnit(From from) { + return from.join(ChequeEntity_.businessUnit); + } +} diff --git a/src/main/java/uk/gov/hmcts/opal/service/ChequeServiceInterface.java b/src/main/java/uk/gov/hmcts/opal/service/ChequeServiceInterface.java new file mode 100644 index 000000000..5929a800d --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/service/ChequeServiceInterface.java @@ -0,0 +1,13 @@ +package uk.gov.hmcts.opal.service; + +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.ChequeEntity; + +import java.util.List; + +public interface ChequeServiceInterface { + + ChequeEntity getCheque(long chequeId); + + List searchCheques(ChequeSearchDto criteria); +} diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyChequeService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyChequeService.java new file mode 100644 index 000000000..d264d1508 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyChequeService.java @@ -0,0 +1,37 @@ +package uk.gov.hmcts.opal.service.legacy; + +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestClient; +import uk.gov.hmcts.opal.config.properties.LegacyGatewayProperties; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.ChequeEntity; +import uk.gov.hmcts.opal.service.ChequeServiceInterface; + +import java.util.List; + +@Service +@Slf4j(topic = "LegacyChequeService") +public class LegacyChequeService extends LegacyService implements ChequeServiceInterface { + + public LegacyChequeService(LegacyGatewayProperties legacyGatewayProperties, RestClient restClient) { + super(legacyGatewayProperties, restClient); + } + + @Override + public Logger getLog() { + return log; + } + + @Override + public ChequeEntity getCheque(long chequeId) { + throw new LegacyGatewayResponseException("Not Yet Implemented"); + } + + @Override + public List searchCheques(ChequeSearchDto criteria) { + throw new LegacyGatewayResponseException("Not Yet Implemented"); + } + +} diff --git a/src/main/java/uk/gov/hmcts/opal/service/opal/ChequeService.java b/src/main/java/uk/gov/hmcts/opal/service/opal/ChequeService.java new file mode 100644 index 000000000..960a52fbe --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/service/opal/ChequeService.java @@ -0,0 +1,40 @@ +package uk.gov.hmcts.opal.service.opal; + + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.ChequeEntity; +import uk.gov.hmcts.opal.repository.ChequeRepository; +import uk.gov.hmcts.opal.repository.jpa.ChequeSpecs; +import uk.gov.hmcts.opal.service.ChequeServiceInterface; + +import java.util.List; + +@Service +@RequiredArgsConstructor +@Qualifier("chequeService") +public class ChequeService implements ChequeServiceInterface { + + private final ChequeRepository chequeRepository; + + private final ChequeSpecs specs = new ChequeSpecs(); + + @Override + public ChequeEntity getCheque(long chequeId) { + return chequeRepository.getReferenceById(chequeId); + } + + @Override + public List searchCheques(ChequeSearchDto criteria) { + Page page = chequeRepository + .findBy(specs.findBySearchCriteria(criteria), + ffq -> ffq.page(Pageable.unpaged())); + + return page.getContent(); + } + +} diff --git a/src/main/java/uk/gov/hmcts/opal/service/proxy/ChequeServiceProxy.java b/src/main/java/uk/gov/hmcts/opal/service/proxy/ChequeServiceProxy.java new file mode 100644 index 000000000..6468a77b6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/opal/service/proxy/ChequeServiceProxy.java @@ -0,0 +1,37 @@ +package uk.gov.hmcts.opal.service.proxy; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.ChequeEntity; +import uk.gov.hmcts.opal.service.DynamicConfigService; +import uk.gov.hmcts.opal.service.ChequeServiceInterface; +import uk.gov.hmcts.opal.service.legacy.LegacyChequeService; +import uk.gov.hmcts.opal.service.opal.ChequeService; + +import java.util.List; + +@Service +@RequiredArgsConstructor +@Qualifier("chequeServiceProxy") +public class ChequeServiceProxy implements ChequeServiceInterface, ProxyInterface { + + private final ChequeService opalChequeService; + private final LegacyChequeService legacyChequeService; + private final DynamicConfigService dynamicConfigService; + + private ChequeServiceInterface getCurrentModeService() { + return isLegacyMode(dynamicConfigService) ? legacyChequeService : opalChequeService; + } + + @Override + public ChequeEntity getCheque(long chequeId) { + return getCurrentModeService().getCheque(chequeId); + } + + @Override + public List searchCheques(ChequeSearchDto criteria) { + return getCurrentModeService().searchCheques(criteria); + } +} diff --git a/src/test/java/uk/gov/hmcts/opal/controllers/develop/ChequeControllerTest.java b/src/test/java/uk/gov/hmcts/opal/controllers/develop/ChequeControllerTest.java new file mode 100644 index 000000000..cdcc44293 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/opal/controllers/develop/ChequeControllerTest.java @@ -0,0 +1,65 @@ +package uk.gov.hmcts.opal.controllers.develop; + +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.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.ChequeEntity; +import uk.gov.hmcts.opal.service.opal.ChequeService; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class ChequeControllerTest { + + @Mock + private ChequeService chequeService; + + @InjectMocks + private ChequeController chequeController; + + @Test + void testGetCheque_Success() { + // Arrange + ChequeEntity entity = ChequeEntity.builder().build(); + + when(chequeService.getCheque(any(Long.class))).thenReturn(entity); + + // Act + ResponseEntity response = chequeController.getChequeById(1L); + + // Assert + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertEquals(entity, response.getBody()); + verify(chequeService, times(1)).getCheque(any(Long.class)); + } + + @Test + void testSearchCheques_Success() { + // Arrange + ChequeEntity entity = ChequeEntity.builder().build(); + List chequeList = List.of(entity); + + when(chequeService.searchCheques(any())).thenReturn(chequeList); + + // Act + ChequeSearchDto searchDto = ChequeSearchDto.builder().build(); + ResponseEntity> response = chequeController.postChequesSearch(searchDto); + + // Assert + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertEquals(chequeList, response.getBody()); + verify(chequeService, times(1)).searchCheques(any()); + } + +} diff --git a/src/test/java/uk/gov/hmcts/opal/service/legacy/LegacyChequeServiceTest.java b/src/test/java/uk/gov/hmcts/opal/service/legacy/LegacyChequeServiceTest.java new file mode 100644 index 000000000..f98eed76a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/opal/service/legacy/LegacyChequeServiceTest.java @@ -0,0 +1,56 @@ +package uk.gov.hmcts.opal.service.legacy; + +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.slf4j.Logger; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@ExtendWith(MockitoExtension.class) +class LegacyChequeServiceTest extends LegacyTestsBase { + + @Mock + private Logger log; + + @InjectMocks + private LegacyChequeService legacyChequeService; + + @Test + void testGetCheque() { + // Act + LegacyGatewayResponseException exception = assertThrows( + LegacyGatewayResponseException.class, + () -> legacyChequeService.getCheque(1) + ); + + // Assert + assertNotNull(legacyChequeService.getLog()); + assertNotNull(exception); + assertEquals(NOT_YET_IMPLEMENTED, exception.getMessage()); + + } + + @Test + void testSearchCheques() { + // Arrange + ChequeSearchDto criteria = ChequeSearchDto.builder().build(); + + // Act + LegacyGatewayResponseException exception = assertThrows( + LegacyGatewayResponseException.class, + () -> legacyChequeService.searchCheques(criteria) + ); + + // Assert + assertNotNull(exception); + assertEquals(NOT_YET_IMPLEMENTED, exception.getMessage()); + + } + +} diff --git a/src/test/java/uk/gov/hmcts/opal/service/opal/ChequeServiceTest.java b/src/test/java/uk/gov/hmcts/opal/service/opal/ChequeServiceTest.java new file mode 100644 index 000000000..5034f389c --- /dev/null +++ b/src/test/java/uk/gov/hmcts/opal/service/opal/ChequeServiceTest.java @@ -0,0 +1,72 @@ +package uk.gov.hmcts.opal.service.opal; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.repository.query.FluentQuery; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.ChequeEntity; +import uk.gov.hmcts.opal.repository.ChequeRepository; + +import java.util.List; +import java.util.function.Function; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class ChequeServiceTest { + + @Mock + private ChequeRepository chequeRepository; + + @InjectMocks + private ChequeService chequeService; + + @Test + void testGetCheque() { + // Arrange + + ChequeEntity chequeEntity = ChequeEntity.builder().build(); + when(chequeRepository.getReferenceById(any())).thenReturn(chequeEntity); + + // Act + ChequeEntity result = chequeService.getCheque(1); + + // Assert + assertNotNull(result); + + } + + @SuppressWarnings("unchecked") + @Test + void testSearchCheques() { + // Arrange + FluentQuery.FetchableFluentQuery ffq = Mockito.mock(FluentQuery.FetchableFluentQuery.class); + + ChequeEntity chequeEntity = ChequeEntity.builder().build(); + Page mockPage = new PageImpl<>(List.of(chequeEntity), Pageable.unpaged(), 999L); + when(chequeRepository.findBy(any(Specification.class), any())).thenAnswer(iom -> { + iom.getArgument(1, Function.class).apply(ffq); + return mockPage; + }); + + // Act + List result = chequeService.searchCheques(ChequeSearchDto.builder().build()); + + // Assert + assertEquals(List.of(chequeEntity), result); + + } + + +} diff --git a/src/test/java/uk/gov/hmcts/opal/service/proxy/ChequeServiceProxyTest.java b/src/test/java/uk/gov/hmcts/opal/service/proxy/ChequeServiceProxyTest.java new file mode 100644 index 000000000..1713e6ce8 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/opal/service/proxy/ChequeServiceProxyTest.java @@ -0,0 +1,97 @@ +package uk.gov.hmcts.opal.service.proxy; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import uk.gov.hmcts.opal.dto.search.ChequeSearchDto; +import uk.gov.hmcts.opal.entity.ChequeEntity; +import uk.gov.hmcts.opal.service.ChequeServiceInterface; +import uk.gov.hmcts.opal.service.legacy.LegacyChequeService; +import uk.gov.hmcts.opal.service.opal.ChequeService; + +import java.util.List; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.when; + +class ChequeServiceProxyTest extends ProxyTestsBase { + + private AutoCloseable closeable; + + @Mock + private ChequeService opalService; + + @Mock + private LegacyChequeService legacyService; + + @InjectMocks + private ChequeServiceProxy chequeServiceProxy; + + @BeforeEach + void setUp() { + closeable = MockitoAnnotations.openMocks(this); + } + + @AfterEach + void tearDown() throws Exception { + closeable.close(); + } + + void testMode(ChequeServiceInterface targetService, ChequeServiceInterface otherService) { + testGetCheque(targetService, otherService); + testSearchCheques(targetService, otherService); + } + + void testGetCheque(ChequeServiceInterface targetService, ChequeServiceInterface otherService) { + // Given: a ChequeEntity is returned from the target service + ChequeEntity entity = ChequeEntity.builder().build(); + when(targetService.getCheque(anyLong())).thenReturn(entity); + + // When: getCheque is called on the proxy + ChequeEntity chequeResult = chequeServiceProxy.getCheque(1); + + // Then: target service should be used, and the returned cheque should be as expected + verify(targetService).getCheque(1); + verifyNoInteractions(otherService); + Assertions.assertEquals(entity, chequeResult); + } + + void testSearchCheques(ChequeServiceInterface targetService, ChequeServiceInterface otherService) { + // Given: a cheques list result is returned from the target service + ChequeEntity entity = ChequeEntity.builder().build(); + List chequesList = List.of(entity); + when(targetService.searchCheques(any())).thenReturn(chequesList); + + // When: searchCheques is called on the proxy + ChequeSearchDto criteria = ChequeSearchDto.builder().build(); + List listResult = chequeServiceProxy.searchCheques(criteria); + + // Then: target service should be used, and the returned list should be as expected + verify(targetService).searchCheques(criteria); + verifyNoInteractions(otherService); + Assertions.assertEquals(chequesList, listResult); + } + + @Test + void shouldUseOpalChequeServiceWhenModeIsNotLegacy() { + // Given: app mode is set + setMode(OPAL); + // Then: the target service is called, but the other service is not + testMode(opalService, legacyService); + } + + @Test + void shouldUseLegacyChequeServiceWhenModeIsLegacy() { + // Given: app mode is set + setMode(LEGACY); + // Then: the target service is called, but the other service is not + testMode(legacyService, opalService); + } +}