use of com.azure.messaging.eventgrid.EventGridPublisherClient in project vividus by vividus-framework.
the class EventGridServiceTests method shouldSendCustomEvent.
@Test
void shouldSendCustomEvent() {
@SuppressWarnings("unchecked") EventGridPublisherClient<BinaryData> client = mock(EventGridPublisherClient.class);
try (MockedConstruction<EventGridPublisherClientBuilder> builderConstructor = mockConstruction(EventGridPublisherClientBuilder.class, (mock, context) -> {
when(mock.endpoint(ENDPOINT)).thenReturn(mock);
ArgumentMatcher<AzureKeyCredential> matcher = c -> KEY.equals(c.getKey());
when(mock.credential(argThat(matcher))).thenReturn(mock);
when(mock.buildCustomEventPublisherClient()).thenReturn(client);
});
MockedStatic<BinaryData> mockedEvent = mockStatic(BinaryData.class)) {
BinaryData event = mock(BinaryData.class);
mockedEvent.when(() -> BinaryData.fromString(PAYLOAD)).thenReturn(event);
topic.setEventSchema(EventSchema.CUSTOM);
SERVICE.sendEvent(topic, PAYLOAD);
verify(client).sendEvents(List.of(event));
}
}
Aggregations