Vladsz83 commented on code in PR #13461: URL: https://github.com/apache/ignite/pull/13461#discussion_r3756917937
########## modules/core/src/test/resources/codegen/MarshalledOnMessageArray2.java: ########## @@ -0,0 +1,32 @@ +/* + * 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; + +import java.util.Collection; +import org.apache.ignite.plugin.extensions.communication.Message; + +/** */ +public class MarshalledOnMessageArray2 implements Message { Review Comment: Suggestion: `MarshalledOnMessageCollectionArray` ########## modules/core/src/test/resources/codegen/MarshalledOnMessageCollection.java: ########## @@ -0,0 +1,32 @@ +/* + * 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; + +import java.util.Collection; +import org.apache.ignite.plugin.extensions.communication.Message; + +/** */ +public class MarshalledOnMessageCollection implements Message { + /** */ + @Marshalled("msgBytes") + Collection<TestMessage> msgColl; Review Comment: Do we need to check also `List` and `List` in the same way? ########## modules/core/src/test/resources/codegen/MarshalledOnMessageSet.java: ########## @@ -0,0 +1,32 @@ +/* + * 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; + +import java.util.Set; +import org.apache.ignite.plugin.extensions.communication.Message; + +/** */ +public class MarshalledOnMessageSet implements Message { Review Comment: Looks wierd. Why should we allow `@Marshalled` not on `byte[]` at all? ########## modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java: ########## @@ -683,6 +684,43 @@ public void testNonMarshallableSelfMarshallingFailed() { "or SelfMarshallingMessage, nor declare @Marshalled fields"); } + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnMessageFieldFailGeneration() { + List<String> cases = Arrays.asList( + "MarshalledOnMessage.java", + "MarshalledOnMessageCollection.java", + "MarshalledOnMessageCollection2.java", + "MarshalledOnMessageCollection3.java", + "MarshalledOnMessageMap.java", + "MarshalledOnMessageMap2.java", + "MarshalledOnMessageMap3.java", + "MarshalledOnMessageArray.java", + "MarshalledOnMessageArray2.java" + ); + + for (String file : cases) { + Compilation compilation = compile("TestMessage.java", file); + + assertThat(compilation).failed(); + assertThat(compilation).hadErrorContaining("Message must be written by communication protocol"); + } + } + + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnMessageSet() { + assertThat(compile("TestMessage.java", "MarshalledOnMessageSet.java")).succeeded(); + } + + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnSetToArraySucceed() { Review Comment: How differs from `testMarshalledOnMessageSet()`? ########## modules/core/src/test/resources/codegen/MarshalledOnMessageMap.java: ########## @@ -0,0 +1,32 @@ +/* + * 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; + +import org.apache.ignite.plugin.extensions.communication.Message; +import java.util.Map; + +/** */ +public class MarshalledOnMessageMap implements Message { + /** */ + @Marshalled("bytes") Review Comment: Do we need to check also `@Marshalled` with `keys()` and `values()`? ########## modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java: ########## @@ -683,6 +684,43 @@ public void testNonMarshallableSelfMarshallingFailed() { "or SelfMarshallingMessage, nor declare @Marshalled fields"); } + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnMessageFieldFailGeneration() { + List<String> cases = Arrays.asList( + "MarshalledOnMessage.java", + "MarshalledOnMessageCollection.java", + "MarshalledOnMessageCollection2.java", + "MarshalledOnMessageCollection3.java", + "MarshalledOnMessageMap.java", + "MarshalledOnMessageMap2.java", + "MarshalledOnMessageMap3.java", + "MarshalledOnMessageArray.java", + "MarshalledOnMessageArray2.java" + ); + + for (String file : cases) { + Compilation compilation = compile("TestMessage.java", file); + + assertThat(compilation).failed(); + assertThat(compilation).hadErrorContaining("Message must be written by communication protocol"); + } + } + + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnMessageSet() { + assertThat(compile("TestMessage.java", "MarshalledOnMessageSet.java")).succeeded(); + } + + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnSetToArraySucceed() { + Compilation compilation = compile("TestMessage.java", "MarshalledOnMessageSet.java"); Review Comment: The same. if `will fail generation.` why `.succeeded()`? ########## modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java: ########## @@ -683,6 +684,43 @@ public void testNonMarshallableSelfMarshallingFailed() { "or SelfMarshallingMessage, nor declare @Marshalled fields"); } + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnMessageFieldFailGeneration() { + List<String> cases = Arrays.asList( + "MarshalledOnMessage.java", + "MarshalledOnMessageCollection.java", + "MarshalledOnMessageCollection2.java", + "MarshalledOnMessageCollection3.java", + "MarshalledOnMessageMap.java", + "MarshalledOnMessageMap2.java", + "MarshalledOnMessageMap3.java", + "MarshalledOnMessageArray.java", + "MarshalledOnMessageArray2.java" + ); + + for (String file : cases) { + Compilation compilation = compile("TestMessage.java", file); + + assertThat(compilation).failed(); + assertThat(compilation).hadErrorContaining("Message must be written by communication protocol"); Review Comment: `by communication protocol` is a bit unclear. I suggest smth. like `by dedicated message serializers` ########## modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java: ########## @@ -683,6 +684,43 @@ public void testNonMarshallableSelfMarshallingFailed() { "or SelfMarshallingMessage, nor declare @Marshalled fields"); } + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnMessageFieldFailGeneration() { + List<String> cases = Arrays.asList( + "MarshalledOnMessage.java", + "MarshalledOnMessageCollection.java", + "MarshalledOnMessageCollection2.java", + "MarshalledOnMessageCollection3.java", + "MarshalledOnMessageMap.java", + "MarshalledOnMessageMap2.java", + "MarshalledOnMessageMap3.java", + "MarshalledOnMessageArray.java", + "MarshalledOnMessageArray2.java" + ); + + for (String file : cases) { + Compilation compilation = compile("TestMessage.java", file); + + assertThat(compilation).failed(); + assertThat(compilation).hadErrorContaining("Message must be written by communication protocol"); + } + } + + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnMessageSet() { + assertThat(compile("TestMessage.java", "MarshalledOnMessageSet.java")).succeeded(); + } + + /** Test that {@code @Marshalled} annotation on {@link Message} field will fail generation. */ + @Test + public void testMarshalledOnSetToArraySucceed() { + Compilation compilation = compile("TestMessage.java", "MarshalledOnMessageSet.java"); Review Comment: Why not a single line btw like in the previous test? -- 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]
