PolicyController extends RestrictedBaseController { @PostConstruct public void init() { Properties prop = new Properties(); try { String fileName; if (jUnit) { fileName = new File(".").getCanonicalPath() + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "JSONConfig.json"; } else { fileName = "xacml.admin.properties"; } try (InputStream input = new FileInputStream(fileName)) { prop.load(input); } setFileSizeLimit(prop.getProperty("file.size.limit")); setPapUrl(prop.getProperty("xacml.rest.pap.url")); setSmtpHost(prop.getProperty("onap.smtp.host")); setSmtpPort(prop.getProperty("onap.smtp.port")); setSmtpUsername(prop.getProperty("onap.smtp.userName")); setSmtpPassword(prop.getProperty("onap.smtp.password")); setSmtpApplicationName(prop.getProperty("onap.application.name")); setSmtpEmailExtension(prop.getProperty("onap.smtp.emailExtension")); setLogdbDriver(prop.getProperty("xacml.log.db.driver")); setLogdbUrl(prop.getProperty("xacml.log.db.url")); setLogdbUserName(prop.getProperty("xacml.log.db.user")); setLogdbPassword(PeCryptoUtils.decrypt(prop.getProperty("xacml.log.db.password"))); setLogdbDialect(prop.getProperty("onap.dialect")); setXacmldbUrl(prop.getProperty("javax.persistence.jdbc.url")); setXacmldbUserName(prop.getProperty("javax.persistence.jdbc.user")); setXacmldbPassword(PeCryptoUtils.decrypt(prop.getProperty("javax.persistence.jdbc.password"))); setAutoPushAvailable(prop.getProperty("xacml.automatic.push")); setAutoPushDSClosedLoop(prop.getProperty("xacml.autopush.closedloop")); setAutoPushDSFirewall(prop.getProperty("xacml.autopush.firewall")); setAutoPushDSMicroservice(prop.getProperty("xacml.autopush.microservice")); setAutoPushPDPGroup(prop.getProperty("xacml.autopush.pdpGroup")); setMsOnapName(prop.getProperty("xacml.policy.msOnapName")); if (getMsOnapName() == null) { setMsOnapName(prop.getProperty("xacml.policy.msEcompName")); } policyLogger.info("getMsOnapName => " + getMsOnapName()); setMsPolicyName(prop.getProperty("xacml.policy.msPolicyName")); policyLogger.info("setMsPolicyName => " + getMsPolicyName()); setConfigHome(prop.getProperty("xacml.rest.config.webapps") + "Config"); setActionHome(prop.getProperty("xacml.rest.config.webapps") + "Action"); try { setLogTableLimit(prop.getProperty("xacml.onap.dashboard.logTableLimit")); setSystemAlertTableLimit(prop.getProperty("xacml.onap.dashboard.systemAlertTableLimit")); } catch (Exception e) { policyLogger .error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Dashboard tab Property fields are missing" + e); setLogTableLimit("5000"); setSystemAlertTableLimit("2000"); } System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.admin.properties"); } catch (IOException ex) { policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured while reading the Smtp properties from xacml.admin.properties file" + ex); } Map<Datatype, List<FunctionDefinition>> functionMap = getFunctionDatatypeMap(); for (Entry<Datatype, List<FunctionDefinition>> entry : functionMap.entrySet()) { List<FunctionDefinition> functionDefinations = entry.getValue(); for (FunctionDefinition functionDef : functionDefinations) { dropDownMap.put(functionDef.getShortname(), functionDef.getXacmlid()); } } } @Autowired private  PolicyController(CommonClassDao commonClassDao);  PolicyController(); static Map<String, String> getDropDownMap(); static void setDropDownMap(Map<String, String> dropDownMap); static String getDomain(); static boolean isjUnit(); static void setjUnit(boolean isJunit); @PostConstruct void init(); static Map<Datatype, List<FunctionDefinition>> getFunctionDatatypeMap(); static Map<String, FunctionDefinition> getFunctionIdMap(); @RequestMapping( value = {"/get_FunctionDefinitionDataByName"}, method = {org.springframework.web.bind.annotation.RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getFunctionDefinitionData(HttpServletRequest request, HttpServletResponse response); PolicyEntity getPolicyEntityData(String scope, String policyName); List<String> getRolesOfUser(String userId); List<Object> getRoles(String userId); @RequestMapping( value = {"/get_UserRolesData"}, method = {org.springframework.web.bind.annotation.RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getUserRolesEntityData(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/policy", "/policy/Editor"}, method = RequestMethod.GET) ModelAndView view(HttpServletRequest request); void getUserRoleFromSession(HttpServletRequest request); PAPPolicyEngine getPapEngine(); static void setPapEngine(PAPPolicyEngine papEngine); String getUserName(String createdBy); static boolean getActivePolicy(String query); void executeQuery(String query); void saveData(Object cloneEntity); void updateData(Object entity); void deleteData(Object entity); List<Object> getData(@SuppressWarnings("rawtypes") Class className); PolicyVersion getPolicyEntityFromPolicyVersion(String query); List<Object> getDataByQuery(String query, SimpleBindings params); @SuppressWarnings("rawtypes") Object getEntityItem(Class className, String columname, String key); void watchPolicyFunction(PolicyVersion entity, String policyName, String mode); JSONObject switchVersionPolicyContent(String thePolicyName); String getUserId(PolicyEntity data, String value); String getDescription(PolicyEntity data); String[] getUserInfo(PolicyEntity data, List<PolicyVersion> activePolicies); static String getLogTableLimit(); static void setLogTableLimit(String logTableLimit); static String getSystemAlertTableLimit(); static void setSystemAlertTableLimit(String systemAlertTableLimit); static CommonClassDao getCommonClassDao(); static void setCommonClassDao(CommonClassDao commonClassDao); static Map<Datatype, List<FunctionDefinition>> getMapDatatype2Function(); static void setMapDatatype2Function(Map<Datatype, List<FunctionDefinition>> mapDatatype2Function); static Map<String, FunctionDefinition> getMapID2Function(); static void setMapID2Function(Map<String, FunctionDefinition> mapID2Function); static String getSmtpHost(); static void setSmtpHost(String smtpHost); static String getSmtpPort(); static void setSmtpPort(String smtpPort); static String getSmtpUsername(); static void setSmtpUsername(String smtpUsername); static String getSmtpPassword(); static void setSmtpPassword(String smtpPassword); static String getSmtpApplicationName(); static void setSmtpApplicationName(String smtpApplicationName); static String getSmtpEmailExtension(); static void setSmtpEmailExtension(String smtpEmailExtension); static String getLogdbDriver(); static void setLogdbDriver(String logdbDriver); static String getLogdbUrl(); static void setLogdbUrl(String logdbUrl); static String getLogdbUserName(); static void setLogdbUserName(String logdbUserName); static String getLogdbPassword(); static void setLogdbPassword(String logdbPassword); static String getLogdbDialect(); static void setLogdbDialect(String logdbDialect); static String getXacmldbUrl(); static void setXacmldbUrl(String xacmldbUrl); static String getXacmldbUserName(); static void setXacmldbUserName(String xacmldbUserName); static String getXacmldbPassword(); static void setXacmldbPassword(String xacmldbPassword); static String getAutoPushAvailable(); static void setAutoPushAvailable(String autoPushAvailable); static String getAutoPushDSClosedLoop(); static void setAutoPushDSClosedLoop(String autoPushDSClosedLoop); static String getAutoPushDSFirewall(); static void setAutoPushDSFirewall(String autoPushDSFirewall); static String getAutoPushDSMicroservice(); static void setAutoPushDSMicroservice(String autoPushDSMicroservice); static String getAutoPushPDPGroup(); static void setAutoPushPDPGroup(String autoPushPDPGroup); static String getPapUrl(); static void setPapUrl(String papUrl); static String getMsOnapName(); static void setMsOnapName(String msOnapName); static String getMsPolicyName(); static void setMsPolicyName(String msPolicyName); static String getConfigHome(); static void setConfigHome(String configHome); static String getActionHome(); static void setActionHome(String actionHome); static Object getMapaccess(); static String getPolicydata(); static String getCharacterencoding(); static String getContenttype(); static String getFile(); static void setFileSizeLimit(String uploadSize); static long getFileSizeLimit();  }
@Test public void testInit() { PolicyController controller = new PolicyController(); PolicyController.setjUnit(true); controller.init(); try { assertTrue(PolicyController.dropDownMap.size() > 0); } catch (Exception e) { logger.error("Exception Occured" + e); fail(); } }