You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/02/10 13:00:31 UTC

[GitHub] [ignite] l4ndsc4pe opened a new pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

l4ndsc4pe opened a new pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394
 
 
   1. New annotation for storing the name and description of the method argument added
   2. New logic of getting parameter name\description implemented (backward compatible)
   3. Tests for new logic of getting parameter name\description added
   4. Old annotations are now marked as @Deprecated and replaced with new one
   5. Minor codestyle issues fixed

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380100115
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -149,7 +151,7 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380059465
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379574561
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
 
 Review comment:
   It's bad idea to expect `AssertionError` especially when only only one source for it it is Java assertion (`assert <condition>`). This test will fail if Java assertions are disabled (it's default behavior). This statement is valid for all cases below that expect `AssertionError`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379578689
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
 
 Review comment:
   Abbreviation should be used for variable name: `Result` -> `res`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379558879
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
+
+        assert seq < annotations.length;
 
 Review comment:
   I believe tis assertion is redundant. We always get sequence number for standard library.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379563088
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
+
+        assert seq < annotations.length;
+
+        for (Annotation annotation : annotations[seq]) {
+            if (annotation instanceof MXBeanParameterInfo) {
+                return (MXBeanParameterInfo) annotation;
+            }
 
 Review comment:
   We don't use curly braces if body of condition or cycle is one-liner.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379573747
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
+        Method method = TestInterfaceImpl.class.getDeclaredMethod(methodName, String.class, String.class);
+        return new MBeanOperationInfo(OPERATION_INFO_DESCRIPTION, method);
+    }
+
+    /**
+     * Interface used for testing.
+     */
+    public static interface TestInterface {
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION, SECOND_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod1(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({})
+        @MXBeanParametersDescriptions({})
+        void testMethod2(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod3(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({EMPTY_STRING})
+        @MXBeanParametersDescriptions({EMPTY_STRING})
+        void testMethod4(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({NO_DOT_AT_THE_END_OF_THE_STRING, FIRST_LOWERCASE_LETTER})
+        void testMethod5(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod6(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = FIRST_DESCRIPTION_PARAM_ANNOTATION)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = SECOND_DESCRIPTION_PARAM_ANNOTATION)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod7(
+            @MXBeanParameterInfo(name = EMPTY_STRING, description = EMPTY_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = SECOND_DESCRIPTION_PARAM_ANNOTATION)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod8(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = NO_DOT_AT_THE_END_OF_THE_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = FIRST_LOWERCASE_LETTER)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION, SECOND_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod9(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = NO_DOT_AT_THE_END_OF_THE_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = FIRST_LOWERCASE_LETTER)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod10(String firstParam, String secondParam);
+    }
+
+    /**
+     * Test interface implementation.
+     */
+    private static class TestInterfaceImpl implements TestInterface {
+
 
 Review comment:
   Redundant empty line.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380059311
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380091706
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
 
 Review comment:
   Yeup, thanks for idea. Now it's more succinctly.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380030547
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/MXBeanParameterInfo.java
 ##########
 @@ -0,0 +1,43 @@
+/*
+ * 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.mxbean;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Provides name and description for MBean method argument.
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379557391
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
 
 Review comment:
   Please use `code` javadoc tag for such cases: `{@code null}`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380056500
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380090607
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
+
+        assert seq < annotations.length;
+
+        for (Annotation annotation : annotations[seq]) {
+            if (annotation instanceof MXBeanParameterInfo) {
+                return (MXBeanParameterInfo) annotation;
+            }
 
 Review comment:
   Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379578777
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
 
 Review comment:
   Abbreviation should be used for variable name: `Result` -> `res`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380118646
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
 
 Review comment:
   Well, I totally agree. As far as I understand there is two ways of dealing with this problem:
   1. Simply remove tests with expected `AssertionError.class`
   2. Replace asserts with A.ensure and expect `IllegalArgumentException.class`
   Do you have any suggestions or which of these methods do you prefer?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379575920
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
 
 Review comment:
   Abbreviation should be used for variable name: `Interface` -> `Itf`. See abbreviation rules.
   
   Also empty line should be added between every code line (almost always).

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379573596
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
 
 Review comment:
   Redundant empty line.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380100036
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -126,7 +128,7 @@
             assert !str.trim().isEmpty();
 
             // Enforce proper English.
-            assert Character.isUpperCase(str.charAt(0)) == true : str;
+            assert Character.isUpperCase(str.charAt(0)) : str;
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379548125
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/MXBeanParametersDescriptions.java
 ##########
 @@ -26,6 +26,7 @@
 /**
  * Provides MBean method parameters description.
  */
+@Deprecated
 
 Review comment:
   Could you please also add `@deprecated` tag to javadoc and provide description (what should be used instead of deprecated annotation)?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] dspavlov commented on issue #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
dspavlov commented on issue #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#issuecomment-589123904
 
 
   @agura  thank you for the review, @l4ndsc4pe  thank you for contribution.
   
   Closing PR since commit https://github.com/apache/ignite/commit/27ed4240dca9d5d89a1bca850a0306ef3a12fa61 is merged

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379579573
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
 
 Review comment:
   Abbreviation should be used for parameter names: `method` -> `m`, `Index` -> `idx`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379552836
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -149,7 +151,7 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
 
 Review comment:
   Could you please add clear message for case when assert failed?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379580373
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
+        Method method = TestInterfaceImpl.class.getDeclaredMethod(methodName, String.class, String.class);
+        return new MBeanOperationInfo(OPERATION_INFO_DESCRIPTION, method);
+    }
+
+    /**
+     * Interface used for testing.
+     */
+    public static interface TestInterface {
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION, SECOND_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod1(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({})
+        @MXBeanParametersDescriptions({})
+        void testMethod2(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod3(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({EMPTY_STRING})
+        @MXBeanParametersDescriptions({EMPTY_STRING})
+        void testMethod4(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({NO_DOT_AT_THE_END_OF_THE_STRING, FIRST_LOWERCASE_LETTER})
+        void testMethod5(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod6(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = FIRST_DESCRIPTION_PARAM_ANNOTATION)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = SECOND_DESCRIPTION_PARAM_ANNOTATION)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod7(
+            @MXBeanParameterInfo(name = EMPTY_STRING, description = EMPTY_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = SECOND_DESCRIPTION_PARAM_ANNOTATION)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod8(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = NO_DOT_AT_THE_END_OF_THE_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = FIRST_LOWERCASE_LETTER)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION, SECOND_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod9(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = NO_DOT_AT_THE_END_OF_THE_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = FIRST_LOWERCASE_LETTER)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod10(String firstParam, String secondParam);
+    }
+
+    /**
+     * Test interface implementation.
+     */
+    private static class TestInterfaceImpl implements TestInterface {
+
+        /** {@inheritDoc} */
+        @Override public void testMethod1(String firstParam, String secondParam) {
 
 Review comment:
   All empty methods with empty body must contain `// No-op.` line.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380059577
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379556473
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
 
 Review comment:
   Could you please add clear messages for case when assert failed for all assertions under this `if`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379579810
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
 
 Review comment:
   Abbreviation should be used for parameter names `method` -> `m`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379557139
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
 
 Review comment:
   There is no annotation with name `MXBeanArgumentInfo`. Use `link` javadoc tag for cases when you want to refer to some class, method, 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380059384
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379543545
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/MXBeanParameterInfo.java
 ##########
 @@ -0,0 +1,43 @@
+/*
+ * 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.mxbean;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Provides name and description for MBean method argument.
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.PARAMETER})
+public @interface MXBeanParameterInfo {
 
 Review comment:
   Could you please rename it to `MXBeanParameter`? `Info` is just redundant word.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380030658
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/MXBeanParametersDescriptions.java
 ##########
 @@ -26,6 +26,7 @@
 /**
  * Provides MBean method parameters description.
  */
+@Deprecated
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380059348
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380030704
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
                 assert str.charAt(str.length() - 1) == '.' : str;
+            } else {
 
 Review comment:
   Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379556389
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
 
 Review comment:
   `catch` keyword must be on the next line accordingly to code style.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380030387
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
+        Method method = TestInterfaceImpl.class.getDeclaredMethod(methodName, String.class, String.class);
+        return new MBeanOperationInfo(OPERATION_INFO_DESCRIPTION, method);
+    }
+
+    /**
+     * Interface used for testing.
+     */
+    public static interface TestInterface {
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION, SECOND_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod1(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({})
+        @MXBeanParametersDescriptions({})
+        void testMethod2(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod3(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({EMPTY_STRING})
+        @MXBeanParametersDescriptions({EMPTY_STRING})
+        void testMethod4(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({NO_DOT_AT_THE_END_OF_THE_STRING, FIRST_LOWERCASE_LETTER})
+        void testMethod5(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod6(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = FIRST_DESCRIPTION_PARAM_ANNOTATION)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = SECOND_DESCRIPTION_PARAM_ANNOTATION)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod7(
+            @MXBeanParameterInfo(name = EMPTY_STRING, description = EMPTY_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = SECOND_DESCRIPTION_PARAM_ANNOTATION)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod8(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = NO_DOT_AT_THE_END_OF_THE_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = FIRST_LOWERCASE_LETTER)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION, SECOND_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod9(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = NO_DOT_AT_THE_END_OF_THE_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = FIRST_LOWERCASE_LETTER)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod10(String firstParam, String secondParam);
+    }
+
+    /**
+     * Test interface implementation.
+     */
+    private static class TestInterfaceImpl implements TestInterface {
+
+        /** {@inheritDoc} */
+        @Override public void testMethod1(String firstParam, String secondParam) {
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379553123
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
                 assert str.charAt(str.length() - 1) == '.' : str;
+            } else {
 
 Review comment:
   `else` keyword must be on the next line accordingly to code style.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379575336
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
 
 Review comment:
   Abbreviation should be used for field name: `parameter` -> `param`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379553721
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
                 assert str.charAt(str.length() - 1) == '.' : str;
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.description();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+
+                    // Enforce proper English.
+                    assert Character.isUpperCase(str.charAt(0)) : str;
+                    assert str.charAt(str.length() - 1) == '.' : str;
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
 
 Review comment:
   `catch` keyword must be on the next line accordingly to code style.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379578302
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
 
 Review comment:
   Abbreviation should be used for variable name: `Result` -> `res`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380124087
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
 
 Review comment:
   Added.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380049788
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
 
 Review comment:
   Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379562834
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
 
 Review comment:
   It seems it could be done easier:
   
   `m.getParameters()[seq].getAnnotation(MXBeanParameterInfo.class);`
   
   Now we don't need call `getParameterAnnotations` and iterate over array.
   
   Of course we should consider cases when method doesn't have parameters at all.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379579949
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
+        Method method = TestInterfaceImpl.class.getDeclaredMethod(methodName, String.class, String.class);
 
 Review comment:
   Abbreviation should be used for variable name: `method` -> `m`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380051497
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380055560
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
 
 Review comment:
   Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380682340
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/IgnitionMXBean.java
 ##########
 @@ -118,13 +105,10 @@
      * @see org.apache.ignite.Ignition#stopAll(boolean)
      */
     @MXBeanDescription("Stops all started grids.")
-    @MXBeanParametersNames(
-        "cancel"
-    )
-    @MXBeanParametersDescriptions(
-        "If true then all jobs currently executing on all grids will be cancelled."
-    )
-    public void stopAll(boolean cancel);
+    public void stopAll(
+        @MXBeanParameterInfo(name = "cancel",
+            description = "If true then all jobs currently executing on all grids will be cancelled.") boolean cancel
+    );
 
 Review comment:
   @l4ndsc4pe I believe is `cancel` parameter and the first description. Don't worry, I'll probably fix it on merge stage.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380100115
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -149,7 +151,7 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
 
 Review comment:
   Done

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379578819
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
 
 Review comment:
   Abbreviation should be used for variable name: `Result` -> `res`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380069016
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
+
+        assert seq < annotations.length;
 
 Review comment:
   Well, if it's impossible to have `seq` variable value less then number of parameters, then you are right.
   Removed

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380077174
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
+
+        assert seq < annotations.length;
 
 Review comment:
   That assertion was needed for the case, when seq = 0 and method has no parameters at all.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380055476
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
 
 Review comment:
   Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379577675
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
 
 Review comment:
   Abbreviation should be used for variable name: `Result` -> `res`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380100527
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
 
 Review comment:
   Done

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380059526
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380049417
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
 
 Review comment:
   Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379547499
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/MXBeanParametersNames.java
 ##########
 @@ -26,6 +26,7 @@
 /**
  * Provides MBean method parameters names.
  */
+@Deprecated
 
 Review comment:
   Could you please also add `@deprecated` tag to javadoc and provide description (what should be used instead of deprecated annotation)?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380069016
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
+
+        assert seq < annotations.length;
 
 Review comment:
   Well, if it's impossible to have `seq` variable value less then number of parameters, then you are right.
   Removed

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] dspavlov closed pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
dspavlov closed pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380077174
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
+     */
+    private MXBeanParameterInfo getMXBeanArgumentAnnotation(Method m, int seq) {
+        Annotation[][] annotations = m.getParameterAnnotations();
+
+        assert seq < annotations.length;
 
 Review comment:
   That assertion was needed for the case, when seq = 0 and method has no parameters at all. Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379554118
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
                 assert str.charAt(str.length() - 1) == '.' : str;
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.description();
+
+                    assert str != null;
 
 Review comment:
   Could you please add clear messages for case when assert failed for all assertions under this `if`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380031106
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379573517
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
 
 Review comment:
   Please, use `link` javadoc tag for reference to `IgniteStandardMXBean`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380030419
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
+        Method method = TestInterfaceImpl.class.getDeclaredMethod(methodName, String.class, String.class);
+        return new MBeanOperationInfo(OPERATION_INFO_DESCRIPTION, method);
+    }
+
+    /**
+     * Interface used for testing.
+     */
+    public static interface TestInterface {
+
 
 Review comment:
   Removed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380123893
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
                 assert str.charAt(str.length() - 1) == '.' : str;
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.description();
+
+                    assert str != null;
 
 Review comment:
   Added.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380057961
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
 
 Review comment:
   Both comments fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380030728
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
                 assert str.charAt(str.length() - 1) == '.' : str;
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.description();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+
+                    // Enforce proper English.
+                    assert Character.isUpperCase(str.charAt(0)) : str;
+                    assert str.charAt(str.length() - 1) == '.' : str;
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
 
 Review comment:
   Fixed. 
   By the way, I configured code style and code inspection in my IDE and none of this helped to detect this codestyle issues before PR.  What am I doing wrong?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380057003
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
 
 Review comment:
   Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379558258
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
 
 Review comment:
   Please do not use custom formatting in javadocs. We never use such approach. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379557978
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
 
 Review comment:
   There is no annotation with name `MXBeanArgumentInfo`. Use `link` javadoc tag for cases when you want to refer to some class, method, 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380055476
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
 
 Review comment:
   You're right, I forgot to change it before push. Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379552894
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
 
 Review comment:
   Could you please add clear message for case when assert failed?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380127205
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -254,7 +300,7 @@ private Method getMethod(MBeanOperationInfo op) throws ClassNotFoundException, S
      */
     @SuppressWarnings("unchecked")
     private Method findMethod(Class itf, String methodName, Class[] params) {
-        assert itf.isInterface() == true;
+        assert itf.isInterface();
 
 Review comment:
   Added.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380059657
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380055623
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
+     * @param seq The sequence number of the argument considered
+     *            ("0" for the first parameter, "1" for the second parameter,
+     *            etc...)
+     * @return MXBeanArgumentInfo annotation instance.
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380064481
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/IgnitionMXBean.java
 ##########
 @@ -118,13 +105,10 @@
      * @see org.apache.ignite.Ignition#stopAll(boolean)
      */
     @MXBeanDescription("Stops all started grids.")
-    @MXBeanParametersNames(
-        "cancel"
-    )
-    @MXBeanParametersDescriptions(
-        "If true then all jobs currently executing on all grids will be cancelled."
-    )
-    public void stopAll(boolean cancel);
+    public void stopAll(
+        @MXBeanParameterInfo(name = "cancel",
+            description = "If true then all jobs currently executing on all grids will be cancelled.") boolean cancel
+    );
 
 Review comment:
   Well, yes, I can, if you'll tell me which of two names and descriptions use. 
   I mean:
   ![image](https://user-images.githubusercontent.com/58294855/74640067-0b91f500-5180-11ea-8ef0-81a4c938814b.png)
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380030627
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/MXBeanParametersNames.java
 ##########
 @@ -26,6 +26,7 @@
 /**
  * Provides MBean method parameters names.
  */
+@Deprecated
 
 Review comment:
   Done, thanks.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379578445
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
 
 Review comment:
   Abbreviation should be used for variable name: `Result` -> `res`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379580157
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
+        Method method = TestInterfaceImpl.class.getDeclaredMethod(methodName, String.class, String.class);
+        return new MBeanOperationInfo(OPERATION_INFO_DESCRIPTION, method);
+    }
+
+    /**
+     * Interface used for testing.
+     */
+    public static interface TestInterface {
+
 
 Review comment:
   Redundant empty line.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379568405
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/IgnitionMXBean.java
 ##########
 @@ -118,13 +105,10 @@
      * @see org.apache.ignite.Ignition#stopAll(boolean)
      */
     @MXBeanDescription("Stops all started grids.")
-    @MXBeanParametersNames(
-        "cancel"
-    )
-    @MXBeanParametersDescriptions(
-        "If true then all jobs currently executing on all grids will be cancelled."
-    )
-    public void stopAll(boolean cancel);
+    public void stopAll(
+        @MXBeanParameterInfo(name = "cancel",
+            description = "If true then all jobs currently executing on all grids will be cancelled.") boolean cancel
+    );
 
 Review comment:
   Could you please use new annotations for `restart()` method also?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379578586
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
 
 Review comment:
   Abbreviation should be used for variable name: `Result` -> `res`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380030588
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/MXBeanParameterInfo.java
 ##########
 @@ -0,0 +1,43 @@
+/*
+ * 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.mxbean;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Provides name and description for MBean method argument.
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.PARAMETER})
+public @interface MXBeanParameterInfo {
 
 Review comment:
   For me, there is a huge difference between the value of a parameter and the information about it, but I did this change anyway.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380056594
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
 
 Review comment:
   Removed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379556318
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
 
 Review comment:
   `else` keyword must be on the next line accordingly to code style.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379552666
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -126,7 +128,7 @@
             assert !str.trim().isEmpty();
 
             // Enforce proper English.
-            assert Character.isUpperCase(str.charAt(0)) == true : str;
+            assert Character.isUpperCase(str.charAt(0)) : str;
 
 Review comment:
   Could you please add clear message for case when assert failed?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380100527
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380048938
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
+        Method method = TestInterfaceImpl.class.getDeclaredMethod(methodName, String.class, String.class);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379564492
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -254,7 +300,7 @@ private Method getMethod(MBeanOperationInfo op) throws ClassNotFoundException, S
      */
     @SuppressWarnings("unchecked")
     private Method findMethod(Class itf, String methodName, Class[] params) {
-        assert itf.isInterface() == true;
+        assert itf.isInterface();
 
 Review comment:
   Could you please add clear message for case when assert failed?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380059415
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
 
 Review comment:
   Changed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379543161
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/mxbean/MXBeanParameterInfo.java
 ##########
 @@ -0,0 +1,43 @@
+/*
+ * 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.mxbean;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Provides name and description for MBean method argument.
 
 Review comment:
   If we talk about parameters to it wold be better use parameter word insted of argument here and in docs of `name()` and `description()` methods. Just in order to be consistent.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380056669
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getDescription(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method that returns the name for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the name for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getParameterNameWithMethodNameAndParamIndex(String methodName, int paramIndex)
+        throws NoSuchMethodException {
+        MBeanOperationInfo operationInfo = getMBeanOperationInfoWithMehtodName(methodName);
+        return igniteStandardMXBean.getParameterName(operationInfo, parameterInfo, paramIndex);
+    }
+
+    /**
+     * Utility method for getting instance of MBeanOperationInfo constructed with default description from TestInterface
+     * by its method name.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @return MBeanOperationInfo.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private MBeanOperationInfo getMBeanOperationInfoWithMehtodName(String methodName) throws NoSuchMethodException {
+        Method method = TestInterfaceImpl.class.getDeclaredMethod(methodName, String.class, String.class);
+        return new MBeanOperationInfo(OPERATION_INFO_DESCRIPTION, method);
+    }
+
+    /**
+     * Interface used for testing.
+     */
+    public static interface TestInterface {
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION, SECOND_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod1(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({})
+        @MXBeanParametersDescriptions({})
+        void testMethod2(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod3(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({EMPTY_STRING})
+        @MXBeanParametersDescriptions({EMPTY_STRING})
+        void testMethod4(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({NO_DOT_AT_THE_END_OF_THE_STRING, FIRST_LOWERCASE_LETTER})
+        void testMethod5(String firstParam, String secondParam);
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod6(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = FIRST_DESCRIPTION_PARAM_ANNOTATION)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = SECOND_DESCRIPTION_PARAM_ANNOTATION)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod7(
+            @MXBeanParameterInfo(name = EMPTY_STRING, description = EMPTY_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = SECOND_DESCRIPTION_PARAM_ANNOTATION)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod8(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = NO_DOT_AT_THE_END_OF_THE_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = FIRST_LOWERCASE_LETTER)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        @MXBeanParametersNames({FIRST_NAME_METHOD_ANNOTATION, SECOND_NAME_METHOD_ANNOTATION})
+        @MXBeanParametersDescriptions({FIRST_DESCRIPTION_METHOD_ANNOTATION, SECOND_DESCRIPTION_METHOD_ANNOTATION})
+        void testMethod9(
+            @MXBeanParameterInfo(name = FIRST_NAME_PARAM_ANNOTATION, description = NO_DOT_AT_THE_END_OF_THE_STRING)
+                String firstParam,
+            @MXBeanParameterInfo(name = SECOND_NAME_PARAM_ANNOTATION, description = FIRST_LOWERCASE_LETTER)
+                String secondParam
+        );
+
+        /**
+         * Method used for testing.
+         *
+         * @param firstParam first string method parameter.
+         * @param secondParam second string method parameter.
+         */
+        void testMethod10(String firstParam, String secondParam);
+    }
+
+    /**
+     * Test interface implementation.
+     */
+    private static class TestInterfaceImpl implements TestInterface {
+
 
 Review comment:
   Removed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380678561
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -179,11 +181,23 @@
                 assert !str.trim().isEmpty();
 
                 // Enforce proper English.
-                assert Character.isUpperCase(str.charAt(0)) == true : str;
+                assert Character.isUpperCase(str.charAt(0)) : str;
                 assert str.charAt(str.length() - 1) == '.' : str;
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.description();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+
+                    // Enforce proper English.
+                    assert Character.isUpperCase(str.charAt(0)) : str;
+                    assert str.charAt(str.length() - 1) == '.' : str;
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
 
 Review comment:
   @l4ndsc4pe 
   
   > By the way, I configured code style and code inspection in my IDE and none of this helped to detect this codestyle issues before PR. What am I doing wrong?
   
   Unfortunately, I've no idea. I just write in this style automatically :)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380031036
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379579253
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_OldAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_5, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty description parameter value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotation.
+     * Description parameter without a dot at the end of the sentence resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationNoDotAtTheEndOfTheString() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Description parameter starts with a lowercase letter resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getDescription_NewAnnotationFirstLowercaseLetter() throws NoSuchMethodException {
+        getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_8, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_DESCRIPTION_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(PARAMETER_INFO_DESCRIPTION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only the old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An empty array is used as parameters in the annotation resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyValueArray() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_2, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * An array whose length is less than transmitted parameter index is used as a parameter
+     * resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationValueLengthLessThenParamIndex() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_3, FIRST_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_OldAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_4, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NewAnnotation() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_6, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_PARAM_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only new annotations.
+     * Empty parameter name value resulting in an AssertionError.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test(expected = AssertionError.class)
+    public void getParameterName_NewAnnotationEmptyParamValue() throws NoSuchMethodException {
+        getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_7, ZERO_INDEX);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has both old and new annotations.
+     * All annotations parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_BothOldAndNewAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_9, FIRST_INDEX);
+
+        assertEquals(SECOND_NAME_METHOD_ANNOTATION, actualResult);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has no annotations at all.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getParameterName_NoAnnotations() throws NoSuchMethodException {
+        String actualResult = getParameterNameWithMethodNameAndParamIndex(TEST_METHOD_10, FIRST_INDEX);
+
+        assertEquals(NAME, actualResult);
+    }
+
+    /**
+     * Utility method that returns the description for method argument by method name and parameter index.
+     *
+     * @param methodName method name from interface TestInterface.
+     * @param paramIndex the sequence number of the argument considered.
+     * @return the description for method argument.
+     * @throws NoSuchMethodException if a matching method is not found.
+     */
+    private String getDescriptionWithMethodNameAndParamIndex(String methodName, int paramIndex)
 
 Review comment:
   Abbreviation should be used for parameter names: `method` -> `m`, `Index` -> `idx`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r379576097
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBeanTest.java
 ##########
 @@ -0,0 +1,576 @@
+/*
+ * 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.mxbean;
+
+import java.lang.reflect.Method;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import org.apache.ignite.mxbean.MXBeanParameterInfo;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains tests for IgniteStandardMXBean methods.
+ */
+public class IgniteStandardMXBeanTest {
+
+    /** */
+    private static final String NAME = "Name";
+
+    /** */
+    private static final String TYPE = "Type";
+
+    /** */
+    private static final String OPERATION_INFO_DESCRIPTION = "Operation info description";
+
+    /** */
+    private static final String PARAMETER_INFO_DESCRIPTION = "Parameter info description";
+
+    /** */
+    private static final String EMPTY_STRING = "";
+
+    /** */
+    private static final String TEST_METHOD_1 = "testMethod1";
+
+    /** */
+    private static final String TEST_METHOD_2 = "testMethod2";
+
+    /** */
+    private static final String TEST_METHOD_3 = "testMethod3";
+
+    /** */
+    private static final String TEST_METHOD_4 = "testMethod4";
+
+    /** */
+    private static final String TEST_METHOD_5 = "testMethod5";
+
+    /** */
+    private static final String TEST_METHOD_6 = "testMethod6";
+
+    /** */
+    private static final String TEST_METHOD_7 = "testMethod7";
+
+    /** */
+    private static final String TEST_METHOD_8 = "testMethod8";
+
+    /** */
+    private static final String TEST_METHOD_9 = "testMethod9";
+
+    /** */
+    private static final String TEST_METHOD_10 = "testMethod10";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_PARAM_ANNOTATION = "First description parameter annotation.";
+
+    /** */
+    private static final String FIRST_DESCRIPTION_METHOD_ANNOTATION = "First description method annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_PARAM_ANNOTATION = "Second description parameter annotation.";
+
+    /** */
+    private static final String SECOND_DESCRIPTION_METHOD_ANNOTATION = "Second description method annotation.";
+
+    /** */
+    private static final String FIRST_NAME_PARAM_ANNOTATION = "First name parameter annotation";
+
+    /** */
+    private static final String FIRST_NAME_METHOD_ANNOTATION = "First name method annotation";
+
+    /** */
+    private static final String SECOND_NAME_PARAM_ANNOTATION = "Second name parameter annotation";
+
+    /** */
+    private static final String SECOND_NAME_METHOD_ANNOTATION = "Second name method annotation";
+
+    /** */
+    private static final String FIRST_LOWERCASE_LETTER = "first lowercase letter.";
+
+    /** */
+    private static final String NO_DOT_AT_THE_END_OF_THE_STRING = "No dot at the end of the string";
+
+    /** */
+    private static final int ZERO_INDEX = 0;
+
+    /** */
+    private static final int FIRST_INDEX = 1;
+
+    /**
+     * Instance of IgniteStandardMXBean.
+     */
+    private final IgniteStandardMXBean igniteStandardMXBean;
+
+    /**
+     * Instance of MBeanParameterInfo.
+     */
+    private final MBeanParameterInfo parameterInfo;
+
+    /**
+     * Public constructor that initializes instances of IgniteStandardMXBean and MBeanParameterInfo classes.
+     */
+    public IgniteStandardMXBeanTest() throws NotCompliantMBeanException {
+        TestInterfaceImpl testInterfaceImpl = new TestInterfaceImpl();
+        igniteStandardMXBean = new IgniteStandardMXBean(testInterfaceImpl, TestInterface.class);
+        parameterInfo = new MBeanParameterInfo(NAME, TYPE, PARAMETER_INFO_DESCRIPTION);
+    }
+
+    /**
+     * A test method that represents a situation in which the method has only old annotation.
+     * All annotation parameters are valid.
+     *
+     * @throws NoSuchMethodException if method is not found.
+     */
+    @Test
+    public void getDescription_OldAnnotation() throws NoSuchMethodException {
+        String actualResult = getDescriptionWithMethodNameAndParamIndex(TEST_METHOD_1, FIRST_INDEX);
 
 Review comment:
   Abbreviation should be used for variable name: `Result` -> `res`. See abbreviation rules.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions

Posted by GitBox <gi...@apache.org>.
l4ndsc4pe commented on a change in pull request #7394: IGNITE-10698: Get rid of @MXBeanParametersNames and @MXBeanParametersDescriptions
URL: https://github.com/apache/ignite/pull/7394#discussion_r380055873
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/mxbean/IgniteStandardMXBean.java
 ##########
 @@ -207,15 +221,47 @@
 
                 assert str != null;
                 assert !str.trim().isEmpty();
+            } else {
+                MXBeanParameterInfo argumentInfoAnnotation = getMXBeanArgumentAnnotation(m, seq);
+
+                if (argumentInfoAnnotation != null) {
+                    str = argumentInfoAnnotation.name();
+
+                    assert str != null;
+                    assert !str.trim().isEmpty();
+                }
             }
-        }
-        catch (SecurityException | ClassNotFoundException ignored) {
+        } catch (SecurityException | ClassNotFoundException ignored) {
             // No-op. Default value will be returned.
         }
 
         return str;
     }
 
+    /**
+     * Gets MXBeanArgumentInfo annotation instance from
+     * method if possible, otherwise returns null.
+     *
+     * @param m   Method instance.
 
 Review comment:
   You're right, I forgot to change it before push. Fixed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services