@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()); }
public PolicyDbDaoTransaction getNewTransaction() { logger.debug("getNewTransaction() as getNewTransaction() called"); return new PolicyDbDaoTransactionInstance("init"); }
PolicyDbDao { public PolicyDbDaoTransaction getNewTransaction() { logger.debug("getNewTransaction() as getNewTransaction() called"); return new PolicyDbDaoTransactionInstance("init"); } }
PolicyDbDao { public PolicyDbDaoTransaction getNewTransaction() { logger.debug("getNewTransaction() as getNewTransaction() called"); return new PolicyDbDaoTransactionInstance("init"); } @Autowired  PolicyDbDao(SessionFactory sessionFactory);  PolicyDbDao();  PolicyDbDao(String init); }
PolicyDbDao { public PolicyDbDaoTransaction getNewTransaction() { logger.debug("getNewTransaction() as getNewTransaction() called"); return new PolicyDbDaoTransactionInstance("init"); } @Autowired  PolicyDbDao(SessionFactory sessionFactory);  PolicyDbDao();  PolicyDbDao(String init); static PolicyDbDao getPolicyDbDaoInstance(); void setPapEngine(PAPPolicyEngine papEngine2); @SuppressWarnings("deprecation") void startTransactionSynced(Session session, int waitTime); PolicyDbDaoTransaction getNewTransaction(); PolicyDbDaoTransaction getNewAuditTransaction(); static boolean stringEquals(String one, String two); String[] getPapUrlUserPass(); String[] splitPapUrlUserPass(String url); StdPDPGroup synchronizeGroupPoliciesInFileSystem(StdPDPGroup pdpGroup, GroupEntity groupentity); String removeExtensionAndVersionFromPolicyName(String originalPolicyName); String[] getPolicyNameAndVersionFromPolicyFileName(String originalPolicyName); String getPdpPolicyName(String name, String scope); void auditLocalDatabase(PAPPolicyEngine papEngine2); StdPDPGroup auditLocalFileSystem(StdPDPGroup group); void synchronizeConfigDataInFileSystem(); void deleteAllGroupTables(); @SuppressWarnings("unchecked") void auditGroups(PAPPolicyEngine papEngine2); String getConfigFile(String filename, PolicyRestAdapter policy); String getConfigFile(String inputFilename, String configType); String[] getNameScopeAndVersionFromPdpPolicy(String fileName); static String createNewPdpGroupId(String name); static boolean isNullOrEmpty(String... strings); List<?> getOtherServers(); void setOtherServers(List<?> otherServers); PAPPolicyEngine getPapEngine(); static boolean isJunit(); static void setJunit(boolean isJunit); static PolicyDbDaoTestClass getPolicyDbDaoTestClass(); }
PolicyDbDao { public PolicyDbDaoTransaction getNewTransaction() { logger.debug("getNewTransaction() as getNewTransaction() called"); return new PolicyDbDaoTransactionInstance("init"); } @Autowired  PolicyDbDao(SessionFactory sessionFactory);  PolicyDbDao();  PolicyDbDao(String init); static PolicyDbDao getPolicyDbDaoInstance(); void setPapEngine(PAPPolicyEngine papEngine2); @SuppressWarnings("deprecation") void startTransactionSynced(Session session, int waitTime); PolicyDbDaoTransaction getNewTransaction(); PolicyDbDaoTransaction getNewAuditTransaction(); static boolean stringEquals(String one, String two); String[] getPapUrlUserPass(); String[] splitPapUrlUserPass(String url); StdPDPGroup synchronizeGroupPoliciesInFileSystem(StdPDPGroup pdpGroup, GroupEntity groupentity); String removeExtensionAndVersionFromPolicyName(String originalPolicyName); String[] getPolicyNameAndVersionFromPolicyFileName(String originalPolicyName); String getPdpPolicyName(String name, String scope); void auditLocalDatabase(PAPPolicyEngine papEngine2); StdPDPGroup auditLocalFileSystem(StdPDPGroup group); void synchronizeConfigDataInFileSystem(); void deleteAllGroupTables(); @SuppressWarnings("unchecked") void auditGroups(PAPPolicyEngine papEngine2); String getConfigFile(String filename, PolicyRestAdapter policy); String getConfigFile(String inputFilename, String configType); String[] getNameScopeAndVersionFromPdpPolicy(String fileName); static String createNewPdpGroupId(String name); static boolean isNullOrEmpty(String... strings); List<?> getOtherServers(); void setOtherServers(List<?> otherServers); PAPPolicyEngine getPapEngine(); static boolean isJunit(); static void setJunit(boolean isJunit); static PolicyDbDaoTestClass getPolicyDbDaoTestClass(); static final String JSON_CONFIG; static final String XML_CONFIG; static final String PROPERTIES_CONFIG; static final String OTHER_CONFIG; static final String AUDIT_USER; static final String CONFIG; static final String ACTION; static final String GROUP_ID; static final String DELETED; static final String GROUPENTITY_SELECT; static final String PDPENTITY_SELECT; static final String GROUP_NOT_FOUND; static final String FOUND_IN_DB_NOT_DEL; static final String MORE_THAN_ONE_PDP; static final String DELETED_STATUS_FOUND; static final String DUPLICATE_GROUPID; static final String PDP_ID; static final String QUERY_FAILED_FOR_GROUP; static final String QUERY_FAILED_GET_GROUP; static final String SCOPE; static final String POLICYDBDAO_VAR; static final String DUP_POLICYID; static final String FOUND_IN_DB; }