@Test
public void createFromPolicyObject() {

    Policy policyObject = new ConfigPolicy();
    policyObject.policyAdapter = new PolicyRestAdapter();
    policyObject.policyAdapter.setConfigName("testpolicy1");
    policyObject.policyAdapter.setPolicyDescription("my description");
    policyObject.policyAdapter.setConfigBodyData("this is my test config file");
    policyObject.policyAdapter.setPolicyName("SampleTest1206");
    policyObject.policyAdapter.setConfigType(ConfigPolicy.OTHER_CONFIG);
    policyObject.policyAdapter.setPolicyType("Config");
    policyObject.policyAdapter.setDomainDir("com");
    policyObject.policyAdapter.setVersion("1");
    policyObject.policyAdapter.setHighestVersion(1);
    PolicyType policyTypeObject = new PolicyType();
    policyObject.policyAdapter.setPolicyData(policyTypeObject);
    ClassLoader classLoader = getClass().getClassLoader();
    PolicyType policyConfig = new PolicyType();
    policyConfig.setVersion("1");
    policyConfig.setPolicyId("");
    policyConfig.setTarget(new TargetType());
    policyObject.policyAdapter.setData(policyConfig);
    try {
        policyObject.policyAdapter
                .setParentPath(IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml")));
    } catch (Exception e2) {
        fail();
    }
    PolicyDbDaoTransaction transaction = dbd.getNewTransaction();
    try {
        transaction.createPolicy(policyObject, "testuser1");
        transaction.commitTransaction();
    } catch (Exception e) {
        transaction.rollbackTransaction();
        Assert.fail();
    }
    Session session = sessionFactory.openSession();
    session.getTransaction().begin();
    Query policyQuery =
            session.createQuery("SELECT p FROM PolicyEntity p WHERE p.policyName=:name AND p.scope=:scope");
    policyQuery.setParameter("name", "Config_SampleTest1206.1.xml");
    policyQuery.setParameter("scope", "com");
    List<?> policyQueryList = policyQuery.list();
    PolicyEntity result = null;
    try {
        result = (PolicyEntity) policyQueryList.get(0);
    } catch (Exception e) {
        logger.error("Exception Occured " + e);
        Assert.fail();
    }
    session.getTransaction().commit();
    session.close();
    String expectedData;
    try {
        expectedData = IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml"));
    } catch (IOException e1) {
        expectedData = "";
    }
    Assert.assertEquals(expectedData, result.getPolicyData());
    result = null;
    Assert.assertFalse(transaction.isTransactionOpen());
}