Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.translator.tojava.utils; |
| 18 | |
| 19 | import java.lang.reflect.Constructor; |
| 20 | import java.lang.reflect.InvocationTargetException; |
| 21 | |
| 22 | import org.junit.Test; |
| 23 | import org.onosproject.yangutils.datamodel.YangType; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame^] | 24 | import org.onosproject.yangutils.utils.io.YangPluginConfig; |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 25 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 26 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator; |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 27 | |
| 28 | import static org.hamcrest.core.Is.is; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 29 | import static org.hamcrest.core.IsNot.not; |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 30 | import static org.junit.Assert.assertThat; |
Gaurav Agrawal | a8391d0 | 2016-06-30 13:28:14 +0530 | [diff] [blame] | 31 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 33 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuild; |
| 34 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildForInterface; |
| 35 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getCheckNotNull; |
| 36 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor; |
| 37 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart; |
| 38 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod; |
| 39 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; |
| 40 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForInterface; |
| 41 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethod; |
| 42 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString; |
| 43 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; |
| 44 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForInterface; |
| 45 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForTypeDefClass; |
| 46 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 47 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 48 | import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; |
| 49 | import static org.onosproject.yangutils.utils.UtilConstants.BUILD; |
| 50 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
| 51 | import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING; |
| 52 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
| 53 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
| 54 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
| 55 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; |
| 56 | import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; |
| 57 | import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING; |
| 58 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
| 59 | import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX; |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 60 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; |
| 61 | import static org.onosproject.yangutils.utils.UtilConstants.NEW; |
| 62 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
| 63 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; |
| 64 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING; |
| 65 | import static org.onosproject.yangutils.utils.UtilConstants.OF; |
| 66 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; |
| 67 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; |
| 68 | import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE; |
| 69 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
| 70 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; |
| 71 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; |
| 72 | import static org.onosproject.yangutils.utils.UtilConstants.RETURN; |
| 73 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
| 74 | import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX; |
| 75 | import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION; |
| 76 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
| 77 | import static org.onosproject.yangutils.utils.UtilConstants.STATIC; |
| 78 | import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; |
| 79 | import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S; |
| 80 | import static org.onosproject.yangutils.utils.UtilConstants.THIS; |
| 81 | import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; |
| 82 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; |
| 83 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 84 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 85 | |
| 86 | /** |
| 87 | * Unit tests for generated methods from the file type. |
| 88 | */ |
| 89 | public final class MethodsGeneratorTest { |
| 90 | |
| 91 | private static final String CLASS_NAME = "testname"; |
| 92 | private static final String ATTRIBUTE_NAME = "testname"; |
| 93 | |
| 94 | /** |
| 95 | * Unit test for private constructor. |
| 96 | * |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 97 | * @throws SecurityException if any security violation is observed |
| 98 | * @throws NoSuchMethodException if when the method is not found |
| 99 | * @throws IllegalArgumentException if there is illegal argument found |
| 100 | * @throws InstantiationException if instantiation is provoked for the private constructor |
| 101 | * @throws IllegalAccessException if instance is provoked or a method is provoked |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 102 | * @throws InvocationTargetException when an exception occurs by the method or constructor |
| 103 | */ |
| 104 | @Test |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 105 | public void callPrivateConstructors() |
| 106 | throws SecurityException, NoSuchMethodException, IllegalArgumentException, |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 107 | InstantiationException, IllegalAccessException, InvocationTargetException { |
| 108 | |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 109 | Class<?>[] classesToConstruct = {MethodsGenerator.class}; |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 110 | for (Class<?> clazz : classesToConstruct) { |
| 111 | Constructor<?> constructor = clazz.getDeclaredConstructor(); |
| 112 | constructor.setAccessible(true); |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 113 | assertThat(null, not(constructor.newInstance())); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 114 | } |
| 115 | } |
| 116 | |
| 117 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 118 | * Unit test case for checking the parse builder and type constructor. |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 119 | */ |
| 120 | @Test |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 121 | public void getTypeConstructorTest() { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 122 | |
| 123 | YangPluginConfig pluginConfig = new YangPluginConfig(); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 124 | JavaAttributeInfo testAttr = getTestAttribute(); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 125 | String test = getTypeConstructorStringAndJavaDoc(testAttr, CLASS_NAME, pluginConfig); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 126 | assertThat(true, is(test.contains(PUBLIC + SPACE + CLASS_NAME + OPEN_PARENTHESIS))); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Test for build method for class. |
| 131 | */ |
| 132 | @Test |
| 133 | public void getBuildTest() { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 134 | String method = getBuild(CLASS_NAME, false); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 135 | assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_NAME + SPACE + BUILD |
| 136 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 137 | + RETURN + SPACE + NEW + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 138 | + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET))); |
| 139 | |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Test for build method of interface. |
| 144 | */ |
| 145 | @Test |
| 146 | public void getBuildForInterfaceTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 147 | String method = getBuildForInterface(CLASS_NAME); |
| 148 | assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + CLASS_NAME + SPACE + BUILD + |
| 149 | OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE))); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Test for check not null method. |
| 154 | */ |
| 155 | @Test |
| 156 | public void getCheckNotNullTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 157 | String method = getCheckNotNull(CLASS_NAME); |
| 158 | assertThat(true, is(method.equals(EIGHT_SPACE_INDENTATION + CHECK_NOT_NULL_STRING + OPEN_PARENTHESIS |
| 159 | + CLASS_NAME + COMMA + SPACE + CLASS_NAME + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE))); |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Test case for constructor. |
| 164 | */ |
| 165 | @Test |
| 166 | public void getConstructorTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 167 | JavaAttributeInfo testAttr = getTestAttribute(); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 168 | YangPluginConfig pluginConfig = new YangPluginConfig(); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 169 | String method = getConstructor(testAttr, GENERATE_SERVICE_AND_MANAGER, pluginConfig); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 170 | assertThat(true, is(method.contains(THIS + PERIOD + CLASS_NAME + SPACE + EQUAL + SPACE + "builder" + OBJECT |
| 171 | + PERIOD + GET_METHOD_PREFIX + "Testname" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN))); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Test for constrcutor start method. |
| 176 | */ |
| 177 | @Test |
| 178 | public void getConstructorStartTest() { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 179 | YangPluginConfig pluginConfig = new YangPluginConfig(); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 180 | String method = getConstructorStart(CLASS_NAME, pluginConfig, false); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 181 | assertThat(true, is(method.contains(PUBLIC + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + CLASS_NAME |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 182 | + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE |
| 183 | + OPEN_CURLY_BRACKET + NEW_LINE))); |
| 184 | } |
| 185 | |
| 186 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 187 | * Test case for equals method. |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 188 | */ |
| 189 | @Test |
| 190 | public void getEqualsMethodTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 191 | JavaAttributeInfo testAttr = getTestAttribute(); |
| 192 | String method = getEqualsMethod(testAttr); |
| 193 | assertThat(true, is(method.contains(SIXTEEN_SPACE_INDENTATION + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD |
| 194 | + EQUALS_STRING + OPEN_PARENTHESIS))); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Test for to string method. |
| 199 | */ |
| 200 | @Test |
| 201 | public void getToStringMethodTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 202 | JavaAttributeInfo testAttr = getTestAttribute(); |
| 203 | String method = getToStringMethod(testAttr); |
| 204 | assertThat(true, is(method.equals( |
| 205 | TWELVE_SPACE_INDENTATION + PERIOD + ADD_STRING + OPEN_PARENTHESIS + QUOTES + testAttr.getAttributeName() |
| 206 | + QUOTES + COMMA + SPACE + testAttr.getAttributeName() + CLOSE_PARENTHESIS))); |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Test for getter method of class. |
| 211 | */ |
| 212 | @Test |
| 213 | public void getGetterForClassTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 214 | JavaAttributeInfo testAttr = getTestAttribute(); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 215 | String method = getGetterForClass(testAttr, GENERATE_SERVICE_AND_MANAGER); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 216 | assertThat(true, is(method.contains(PUBLIC + SPACE + STRING_DATA_TYPE + SPACE + GET_METHOD_PREFIX))); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Test for getter of interface. |
| 221 | */ |
| 222 | @Test |
| 223 | public void getGetterForInterfaceTest() { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 224 | String method = getGetterForInterface(CLASS_NAME, STRING_DATA_TYPE, false, GENERATE_SERVICE_AND_MANAGER); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 225 | assertThat(true, is(method.contains(STRING_DATA_TYPE + SPACE + GET_METHOD_PREFIX))); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Test case for setter method of class. |
| 230 | */ |
| 231 | @Test |
| 232 | public void getSetterForClassTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 233 | JavaAttributeInfo testAttr = getTestAttribute(); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 234 | String method = getSetterForClass(testAttr, CLASS_NAME, GENERATE_SERVICE_AND_MANAGER); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 235 | assertThat(true, is( |
| 236 | method.contains(PUBLIC + SPACE + VOID + SPACE + |
| 237 | SET_METHOD_PREFIX + getCapitalCase(CLASS_NAME) + OPEN_PARENTHESIS + |
| 238 | STRING_DATA_TYPE + SPACE + ATTRIBUTE_NAME))); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /** |
| 242 | * Test for setter method of interface. |
| 243 | */ |
| 244 | @Test |
| 245 | public void getSetterForInterfaceTest() { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 246 | String method = getSetterForInterface(CLASS_NAME, STRING_DATA_TYPE, CLASS_NAME, false, |
| 247 | GENERATE_SERVICE_AND_MANAGER); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 248 | assertThat(true, is(method.contains(VOID + SPACE + |
| 249 | SET_METHOD_PREFIX + "Testname"))); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Test case for of method. |
| 254 | */ |
| 255 | @Test |
| 256 | public void getOfMethodest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 257 | JavaAttributeInfo testAttr = getTestAttribute(); |
| 258 | String method = getOfMethod(CLASS_NAME, testAttr); |
| 259 | assertThat(true, is(method.contains(PUBLIC + SPACE + STATIC + SPACE + CLASS_NAME + SPACE + OF + OPEN_PARENTHESIS |
| 260 | + STRING_DATA_TYPE + SPACE + VALUE + CLOSE_PARENTHESIS))); |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Test case for setter in type def class. |
| 265 | */ |
| 266 | @Test |
| 267 | public void getSetterForTypeDefClassTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 268 | JavaAttributeInfo testAttr = getTestAttribute(); |
| 269 | String method = getSetterForTypeDefClass(testAttr); |
| 270 | assertThat(true, is(method.contains(PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX))); |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Test case for over ride string. |
| 275 | */ |
| 276 | @Test |
| 277 | public void getOverRideStringTest() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 278 | String method = getOverRideString(); |
| 279 | assertThat(true, is(method.contains(OVERRIDE))); |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Returns java attribute. |
| 284 | * |
| 285 | * @return java attribute |
| 286 | */ |
| 287 | private JavaAttributeInfo getTestAttribute() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 288 | JavaAttributeInfo testAttr = new JavaAttributeInfo(getTestYangType(), ATTRIBUTE_NAME, false, false); |
| 289 | testAttr.setAttributeName(ATTRIBUTE_NAME); |
| 290 | testAttr.setAttributeType(getTestYangType()); |
| 291 | testAttr.setImportInfo(getTestJavaQualifiedTypeInfo()); |
| 292 | return testAttr; |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Returns java qualified info. |
| 297 | * |
| 298 | * @return java qualified info |
| 299 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 300 | private JavaQualifiedTypeInfoTranslator getTestJavaQualifiedTypeInfo() { |
| 301 | JavaQualifiedTypeInfoTranslator info = new JavaQualifiedTypeInfoTranslator(); |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 302 | info.setPkgInfo(JAVA_LANG); |
| 303 | info.setClassInfo(STRING_DATA_TYPE); |
| 304 | return info; |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Returns stub YANG type. |
| 309 | * |
| 310 | * @return test YANG type |
| 311 | */ |
| 312 | private YangType<?> getTestYangType() { |
Bharat saraswal | c34b944 | 2016-03-28 15:50:13 +0530 | [diff] [blame] | 313 | YangType<?> attrType = new YangType<>(); |
| 314 | attrType.setDataTypeName(STRING_DATA_TYPE); |
| 315 | attrType.setDataType(STRING); |
| 316 | return attrType; |
| 317 | } |
| 318 | } |