ScriptEnginePersonAttributeDao extends AbstractDefaultAttributePersonAttributeDao { private SCRIPT_TYPE determineScriptType(String fileName) { File f = new File(fileName); if (f.exists() && f.isFile()) { return SCRIPT_TYPE.FILE; } InputStream in = ScriptEnginePersonAttributeDao.class.getClassLoader().getResourceAsStream(fileName); try { if (in != null && in.markSupported() && in.available() > 0) { return SCRIPT_TYPE.RESOURCE; } } catch (IOException e) { logger.warn("Error checking if stream exists: {}",e.getMessage(),e); return SCRIPT_TYPE.CONTENTS; } return SCRIPT_TYPE.CONTENTS; } ScriptEnginePersonAttributeDao();  ScriptEnginePersonAttributeDao(String scriptFile);  ScriptEnginePersonAttributeDao(String scriptFile, String engineName);  ScriptEnginePersonAttributeDao(String scriptFile, String engineName, IUsernameAttributeProvider usernameAttributeProvider); String getScriptFile(); void setScriptFile(final String scriptFile); String getEngineName(); void setEngineName(final String engineName); boolean isCaseInsensitiveUsername(); void setCaseInsensitiveUsername(final boolean caseInsensitiveUsername); @Override IPersonAttributes getPerson(final String uid, final IPersonAttributeDaoFilter filter); @Override Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(final Map<String, List<Object>> query,
                                                                     final IPersonAttributeDaoFilter filter); @Override @JsonIgnore Set<String> getPossibleUserAttributeNames(final IPersonAttributeDaoFilter filter); @Override @JsonIgnore Set<String> getAvailableQueryAttributes(final IPersonAttributeDaoFilter filter); static String getScriptEngineName(String filename);  }
@Test public void testDetermineScriptType() { assertEquals(ScriptEnginePersonAttributeDao.SCRIPT_TYPE.RESOURCE, new ScriptEnginePersonAttributeDao("SampleScriptedJavascriptPersonAttributeDao.js").getScriptType()); assertEquals(ScriptEnginePersonAttributeDao.SCRIPT_TYPE.FILE, new ScriptEnginePersonAttributeDao("src/test/resources/SampleScriptedJavascriptPersonAttributeDao.js").getScriptType()); assertEquals(ScriptEnginePersonAttributeDao.SCRIPT_TYPE.CONTENTS, new ScriptEnginePersonAttributeDao("doesnotexist/src/test/resources/SampleScriptedJavascriptPersonAttributeDao.js").getScriptType()); }