Skip to content

Commit

Permalink
MODTLR-20 Use constructor injection for DcbService
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrVidinieiev committed Mar 8, 2024
1 parent 4387fdc commit a10433b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/main/java/org/folio/service/impl/DcbServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
@Log4j2
public class DcbServiceImpl implements DcbService {

@Autowired
private DcbClient dcbClient;
private final DcbClient dcbClient;

public DcbServiceImpl(@Autowired DcbClient dcbClient) {
this.dcbClient = dcbClient;
}

public void createTransactions(EcsTlrEntity ecsTlr) {
log.info("createTransaction:: creating DCB transactions for ECS TLR {}", ecsTlr.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ void beforeEach() {
@Test
void requestUpdateEventIsConsumed() {
EcsTlrEntity initialEcsTlr = getEcsTlrEntity();

executionService.executeAsyncSystemUserScoped(TENANT_ID_CONSORTIUM,
() -> ecsTlrRepository.save(initialEcsTlr));

var mockEcsDcbTransactionResponse = new TransactionStatusResponse()
.status(TransactionStatusResponse.StatusEnum.CREATED);

wireMockServer.stubFor(WireMock.post(urlMatching(".*" + POST_ECS_TLR_TRANSACTION_URL_PATTERN))
.willReturn(jsonResponse(mockEcsDcbTransactionResponse, HttpStatus.SC_CREATED)));

Expand Down Expand Up @@ -99,7 +97,7 @@ void requestUpdateEventIsIgnoredWhenEcsTlrAlreadyHasItemId() {
.build();

executionService.executeAsyncSystemUserScoped(TENANT_ID_CONSORTIUM,
() -> ecsTlrRepository.save(initialEcsTlr));
() -> ecsTlrRepository.save(initialEcsTlr));

var mockEcsDcbTransactionResponse = new TransactionStatusResponse()
.status(TransactionStatusResponse.StatusEnum.CREATED);
Expand All @@ -110,7 +108,7 @@ void requestUpdateEventIsIgnoredWhenEcsTlrAlreadyHasItemId() {
publishEventAndWait(REQUEST_TOPIC_NAME, CONSUMER_GROUP_ID, REQUEST_UPDATE_EVENT_SAMPLE);

EcsTlrEntity ecsTlr = executionService.executeSystemUserScoped(TENANT_ID_CONSORTIUM,
() -> ecsTlrRepository.findById(ecsTlrId).orElseThrow());
() -> ecsTlrRepository.findById(ecsTlrId)).orElseThrow();
assertEquals(ITEM_ID, ecsTlr.getItemId());
assertNull(ecsTlr.getPrimaryRequestDcbTransactionId());
assertNull(ecsTlr.getSecondaryRequestDcbTransactionId());
Expand Down

0 comments on commit a10433b

Please sign in to comment.