/*
 * Copyright (c) 2008-2016 Haulmont.
 *
 * Licensed 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 com.haulmont.bali.util;

import org.junit.Test;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

public class ReflectionHelperTest {

    @Test
    public void testNewInstance() throws Exception {
        MyObject myObject = ReflectionHelper.newInstance(MyObject.class, new MyParam());
        assertNotNull(myObject);

        myObject = ReflectionHelper.newInstance(MyObject.class, new MyParamExt());
        assertNotNull(myObject);

        try {
            ReflectionHelper.newInstance(MyObject.class, "str");
            fail();
        } catch (NoSuchMethodException e) {
            // ok
        }
    }

    public static class MyParam {
    }

    public static class MyParamExt extends MyParam {
    }

    public static class MyObject {
        public MyObject(MyParam param) {
        }
    }
}
@@ -654,16 +654,90 @@
 it.Test;
+%0Aimport org.springframework.util.Assert;%0A%0Aimport java.lang.reflect.Method;
 %0A%0Aimport
@@ -1340,37 +1340,529 @@
     
-public static class MyParam %7B
+@Test%0A    public void testFindMethod() throws Exception %7B%0A        Method method = ReflectionHelper.findMethod(MyParamExt.class, %22parentPrivateMethod%22);%0A        assertNotNull(method);%0A%0A        method = ReflectionHelper.findMethod(MyParamExt.class, %22privateMethod%22);%0A        assertNotNull(method);%0A%0A        method = ReflectionHelper.findMethod(MyParamExt.class, %22noSuchMethod%22);%0A        Assert.isNull(method, %22Should be null%22);%0A    %7D%0A%0A    public static class MyParam %7B%0A        private void parentPrivateMethod() %7B%0A        %7D
 %0A   
@@ -1914,24 +1914,73 @@
 s MyParam %7B%0A
+        private void privateMethod() %7B%0A        %7D%0A
     %7D%0A%0A    p

Fix ReflectionHelper.findMethod #204 Unit test