@@ -0,0 +1,2303 @@
+package com.cloud.utils;%0A%0Aimport javax.persistence.Column;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Ignore;%0Aimport org.junit.Test;%0A%0Aimport com.cloud.utils.db.DbUtil;%0A%0Apublic class DbUtilTest %7B%0A%0A    static class Testbean %7B%0A        String noAnnotation;%0A        @Column()%0A        String withAnnotation;%0A        @Column(name = %22surprise%22)%0A        String withAnnotationAndName;%0A    %7D%0A%0A    @Test%0A    public void getColumnName() throws SecurityException, NoSuchFieldException %7B%0A        // if no annotation, then the field name%0A        Assert.assertEquals(%22noAnnotation%22, DbUtil.getColumnName(Testbean.class%0A                .getDeclaredField(%22noAnnotation%22)));%0A        // there is annotation with name, take the name%0A        Assert.assertEquals(%22surprise%22, DbUtil.getColumnName(Testbean.class%0A                .getDeclaredField(%22withAnnotationAndName%22)));%0A    %7D%0A%0A    @Test%0A    @Ignore%0A    public void getColumnNameWithAnnotationButWithoutNameAttribute()%0A            throws SecurityException, NoSuchFieldException %7B%0A        // there is annotation, but no name defined, fallback to field name%0A        // this does not work this way, it probably should%0A        Assert.assertEquals(%22withAnnotation%22, DbUtil%0A                .getColumnName(Testbean.class%0A                        .getDeclaredField(%22withAnnotation%22)));%0A%0A    %7D%0A%0A    static class IsPersistableTestBean %7B%0A        static final String staticFinal = %22no%22;%0A        final String justFinal = %22no%22;%0A        transient String transientField;%0A        transient static String strange = %22%22;%0A        String instanceField;%0A    %7D%0A%0A    @Test%0A    public void isPersistable() throws SecurityException, NoSuchFieldException %7B%0A        Assert.assertFalse(DbUtil.isPersistable(IsPersistableTestBean.class%0A                .getDeclaredField(%22staticFinal%22)));%0A        Assert.assertFalse(DbUtil.isPersistable(IsPersistableTestBean.class%0A                .getDeclaredField(%22justFinal%22)));%0A        Assert.assertFalse(DbUtil.isPersistable(IsPersistableTestBean.class%0A                .getDeclaredField(%22transientField%22)));%0A        Assert.assertFalse(DbUtil.isPersistable(IsPersistableTestBean.class%0A                .getDeclaredField(%22strange%22)));%0A        Assert.assertTrue(DbUtil.isPersistable(IsPersistableTestBean.class%0A                .getDeclaredField(%22instanceField%22)));%0A    %7D%0A%0A%7D%0A

Test for DbUtil