dant3 commented on code in PR #3563: URL: https://github.com/apache/ignite-3/pull/3563#discussion_r1561174390
########## modules/eventlog/src/test/java/org/apache/ignite/internal/eventlog/ser/RegistryBackedEventSerializerTest.java: ########## @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.eventlog.ser; + +import static org.hamcrest.MatcherAssert.assertThat; +import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; + +import java.util.Map; +import java.util.stream.Stream; +import org.apache.ignite.internal.eventlog.api.Event; +import org.apache.ignite.internal.eventlog.api.IgniteEvents; +import org.apache.ignite.internal.eventlog.event.EventImpl; +import org.apache.ignite.internal.eventlog.event.EventUser; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class RegistryBackedEventSerializerTest { + private static Stream<Arguments> events() { + return Stream.of( + Arguments.of( + new CustomEventBuilder() + .productVersion("3.0.0") + .timestamp(1234567890) + .user(EventUser.of("test_user", "test_provider")) + .message(new Message(1, "test")) + .build(), + "{\"type\":\"CUSTOM\"," + + "\"timestamp\":1234567890," + + "\"productVersion\":\"3.0.0\"," + + "\"user\":{\"username\":\"test_user\",\"authenticationProvider\":\"test_provider\"}," + + "\"message\":{\"version\":1,\"body\":\"test\"}," + + "\"fields\":{\"hasMessage\":true}" + + "}" + ), + Arguments.of( + IgniteEvents.USER_AUTHENTICATED.builder() + .productVersion("3.0.0") + .timestamp(1234567890) + .user(EventUser.of("test_user", "test_provider")) + .fields(Map.of("ip", "127.0.0.1", "id", "123")) Review Comment: > Thanks for the informative answer. You made me think about the following approach: we can introduce the constraint to all Event children -- they should be a Pojo classes. This constraint seems to be ok when we speak about Events and its fields. > > In this case the architecture is going to be as stupid as possible. No extension points, no way to adjust the serialization mechanism. Just give us POJO. > > WDYT? Yeah, we can do this. Actually if we will throw away the EventSerializerRegistry that was created in this patch this is exactly how it's going to work :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
