Package com.philip.journal.common.mock

Examples of com.philip.journal.common.mock.BeanUtilsSubject


    /** Case 3: Normal behavior. */
    @Test
    public final void testConvertList3() {
        final List<Object> input = new ArrayList<Object>();
        final BeanUtilsSubject testBean = new BeanUtilsSubject();
        input.add(testBean);

        final List<Map<String, Object>> result = converter.convert(input);
        assertSame("Test failed on property count check.", BeanUtils.getProperties(testBean).length,
                result.get(0).keySet().size());
View Full Code Here


    }

    /** Case 4: Non-existing property. */
    @Test(expected = IllegalArgumentException.class)
    public void testGetProperty4() {
        BeanUtils.getProperty(new BeanUtilsSubject(), "field4");
        Assert.fail("Case 4: Non-existing property.");
    }
View Full Code Here

     * Case 5.2: Expected primitive type.<br/>
     * Case 5.3: Expected Map type.
     */
    @Test
    public void testGetProperty5() {
        final BeanUtilsSubject input4 = new BeanUtilsSubject();
        input4.setField1(TEST_STRING);
        Assert.assertEquals("Case 5.1: Expected String type.", TEST_STRING,
                BeanUtils.getProperty(input4, BeanUtilsSubject.FIELD1));
        Assert.assertEquals("Case 5.2: Expected primitive type.", 0,
                BeanUtils.getProperty(input4, BeanUtilsSubject.FIELD2));
        Assert.assertSame("Case 5.3: Expected Map type.", null,
View Full Code Here

     * Case 4.2: Expected primitive type.<br/>
     * Case 4.3: Expected Map type.
     */
    @Test
    public void testGetReturnType4() {
        final BeanUtilsSubject input3 = new BeanUtilsSubject();
        Assert.assertEquals("Case 4.1: Expected String type.", String.class,
                BeanUtils.getPropertyType(input3, BeanUtilsSubject.FIELD1));
        Assert.assertEquals("Case 4.2: Expected primitive type.", Integer.TYPE,
                BeanUtils.getPropertyType(input3, BeanUtilsSubject.FIELD2));
        Assert.assertEquals("Case 4.3: Expected Map type.", Map.class,
View Full Code Here

     * Case 1: Expected.
     */
    @Test
    public void testInvokeMethodSilent1() {
        try {
            BeanUtils.invokeMethodSilent(new BeanUtilsSubject(), "exception", null, null);
        } catch (final Exception e) {
            Assert.fail("Case 1: Expected.");
        }
    }
View Full Code Here

    }

    /** Case 4: Null return for void method. */
    @Test
    public void testInvokeMethod4() {
        final BeanUtilsSubject input34 = new BeanUtilsSubject();
        final String input34a = "input3a";
        try {
            Assert.assertNull("Case 4: Null return for void method.", BeanUtils.invokeMethod(input34, "setField1",
                    new Class[] { String.class }, new Object[] { input34a }));
        } catch (final InvocationTargetException e) {
View Full Code Here

    }

    /** Case 5: Reference return type. */
    @Test
    public void testInvokeMethod5() {
        final BeanUtilsSubject input = new BeanUtilsSubject();
        final String inputVal = "input3a";
        input.setField1(inputVal);
        try {
            Assert.assertEquals("Case 5: Reference return type.", inputVal,
                    BeanUtils.invokeMethod(input, "getField1", new Class[0], new Object[0]));
        } catch (final InvocationTargetException e) {
            failUnexpectedException(e);
View Full Code Here

    }

    /** Case 6: Primitive return type. */
    @Test
    public void testInvokeMethod6() {
        final BeanUtilsSubject input5 = new BeanUtilsSubject();
        try {
            Assert.assertEquals("Primitive type method test failed. Equals", 0,
                    BeanUtils.invokeMethod(input5, "getField2", new Class[0], new Object[0]));
        } catch (final InvocationTargetException e) {
            failUnexpectedException(e);
View Full Code Here

     *
     * @throws InvocationTargetException expected exception thrown.
     */
    @Test(expected = InvocationTargetException.class)
    public void testInvokeMethod7() throws InvocationTargetException {
        final BeanUtilsSubject input6 = new BeanUtilsSubject();
        BeanUtils.invokeMethod(input6, "exception", null, null);
        Assert.fail("Case 7: Expected exception.");
    }
View Full Code Here

     * Case 2.2: Primitive property type. <br/>
     * Case 2.3: Map property type.
     */
    @Test
    public void testConvertToMap2() {
        final BeanUtilsSubject inputX = new BeanUtilsSubject();
        inputX.setField2(TEST_INT);
        inputX.setField3(new HashMap<String, Class<?>>());

        final Map<String, Object> output2 = BeanUtils.convertToMap(inputX, new String[] { BeanUtilsSubject.FIELD1 });
        Assert.assertEquals("Case 2.1: Exclusion property count.", 2, output2.size());
        Assert.assertEquals("Case 2.2: Primitive property type.", TEST_INT, output2.get(BeanUtilsSubject.FIELD2));
        Assert.assertTrue("Case 2.3: Map property type.", output2.get(BeanUtilsSubject.FIELD3) instanceof Map);
View Full Code Here

TOP

Related Classes of com.philip.journal.common.mock.BeanUtilsSubject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.