use of com.azure.core.util.BinaryData 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));
}
}
use of com.azure.core.util.BinaryData in project DataSpaceConnector by eclipse-dataspaceconnector.
the class AzureEventGridPublisher method sendEvent.
private Mono<Void> sendEvent(String what, String where, Object payload) {
BinaryData data = BinaryData.fromObject(payload);
var evt = new EventGridEvent(what, where, data, "0.1");
return client.sendEvent(evt);
}
Aggregations