PatrickRen commented on code in PR #45: URL: https://github.com/apache/flink-agents/pull/45#discussion_r2194438702
########## plan/src/test/java/org/apache/flink/agents/plan/serializer/ActionJsonSerializerTest.java: ########## @@ -0,0 +1,193 @@ +/* + * 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.flink.agents.plan.serializer; + +import org.apache.flink.agents.api.Event; +import org.apache.flink.agents.api.InputEvent; +import org.apache.flink.agents.api.OutputEvent; +import org.apache.flink.agents.plan.Action; +import org.apache.flink.agents.plan.JavaFunction; +import org.apache.flink.agents.plan.PythonFunction; +import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** Test for {@link ActionJsonSerializer}. */ +public class ActionJsonSerializerTest { + @Test + public void testSerializeJavaFunction() throws Exception { + // Create a JavaFunction + JavaFunction function = + new JavaFunction( + "org.apache.flink.agents.plan.TestAction", + "legal", + new Class[] {InputEvent.class}); + + // Create an Action + Action action = new Action("testAction", function, List.of(InputEvent.class)); + + // Serialize the action to JSON + String json = new ObjectMapper().writeValueAsString(action); + + // Verify the JSON contains the expected fields + assertTrue(json.contains("\"name\":\"testAction\""), "JSON should contain the action name"); Review Comment: Thanks for the review! I was thinking this could make the assertion failure message more straight-forward, also I'm not sure if the formatting of json could make the test unstable, like with or without new lines, indentations etc. -- 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]
