-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48c3cbe
commit 8257312
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/test/java/org/folio/circulation/resources/RequestNoticeSenderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.folio.circulation.resources; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.times; | ||
|
||
import java.util.UUID; | ||
import java.util.stream.Stream; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.folio.circulation.domain.Request; | ||
import org.folio.circulation.domain.RequestAndRelatedRecords; | ||
import org.folio.circulation.domain.notice.ImmediatePatronNoticeService; | ||
import org.folio.circulation.domain.notice.PatronNoticeEvent; | ||
import org.folio.circulation.support.StringUtil; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.testcontainers.shaded.org.bouncycastle.cert.ocsp.Req; | ||
|
||
import api.support.builders.RequestBuilder; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class RequestNoticeSenderTest { | ||
|
||
@Mock | ||
private ImmediatePatronNoticeService immediatePatronNoticeService; | ||
@InjectMocks | ||
private RequestNoticeSender requestNoticeSender; | ||
|
||
@ParameterizedTest | ||
@MethodSource("requestAndRelatedRecords") | ||
void shouldNotSendNotificationWhenIsDcbCancellationTrue(RequestAndRelatedRecords records, | ||
int invocationTimes) { | ||
|
||
requestNoticeSender.sendNoticeOnRequestCancelled(records); | ||
Mockito.verify(immediatePatronNoticeService, times(invocationTimes)).acceptNoticeEvent(any( | ||
PatronNoticeEvent.class)); | ||
} | ||
|
||
static Stream<Arguments> requestAndRelatedRecords() { | ||
return Stream.of( | ||
Arguments.of(getRequest(true, null), 0) | ||
// Arguments.of(getRequest(false, null), 1), | ||
// Arguments.of(getRequest(false, UUID.randomUUID()), 1) | ||
); | ||
} | ||
|
||
private static RequestAndRelatedRecords getRequest(boolean isDcbReRequestCancellation, UUID itemId) { | ||
JsonObject representation = new RequestBuilder() | ||
.withItemId(itemId) | ||
.create(); | ||
representation.put("isDcbReRequestCancellation", isDcbReRequestCancellation); | ||
return new RequestAndRelatedRecords(Request.from(representation)); | ||
} | ||
} |