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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to