src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
SearchResultConverter { public SearchHit convertUGCToHit(String queryRegex, SolrDocument ugc) { SearchHit hit = new SearchHit(); String mdText = SolrSearchIndex.getMetadataValues(ugc, SolrConstants.UGCTERMS).stream().collect(Collectors.joining("; ")); String type = SolrSearchIndex.getSingleFieldStringValue(ugc, SolrCon...
@Test public void testConvertUGCToHit() { SolrDocument ugc = new SolrDocument(); ugc.setField(SolrConstants.UGCTERMS, text); ugc.setField(SolrConstants.UGCTYPE, "ADDRESS"); ugc.setField(SolrConstants.PI_TOPSTRUCT, pi); ugc.setField(SolrConstants.ORDER, pageNo); ugc.setField(SolrConstants.IDDOC, 123456789); String query...
JPADAO implements IDAO { @Override public boolean addLicenseType(LicenseType licenseType) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(licenseType); em.getTransaction().commit(); } finally { em.close(); } return true; } JPADAO(); JPAD...
@Test public void addLicenseTypeTest() throws DAOException { Assert.assertEquals(NUM_LICENSE_TYPES, DataManager.getInstance().getDao().getAllLicenseTypes().size()); LicenseType licenseType = new LicenseType(); licenseType.setName("license type to add name"); licenseType.setDescription("license type to add desc"); licen...
JPADAO implements IDAO { @Override public boolean updateLicenseType(LicenseType licenseType) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(licenseType); em.getTransaction().commit(); return true; } finally { em.close(); } } JPADAO(); JPA...
@Test public void updateLicenseTypeTest() throws DAOException { Assert.assertEquals(NUM_LICENSE_TYPES, DataManager.getInstance().getDao().getAllLicenseTypes().size()); LicenseType licenseType = DataManager.getInstance().getDao().getLicenseType(1); Assert.assertNotNull(licenseType); Assert.assertEquals(1, licenseType.ge...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Role> getAllRoles() throws DAOException { preQuery(); Query q = em.createQuery("SELECT r FROM Role r"); q.setFlushMode(FlushModeType.COMMIT); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory ge...
@Test public void getAllRolesTest() throws DAOException { List<Role> roles = DataManager.getInstance().getDao().getAllRoles(); Assert.assertEquals(2, roles.size()); }
JPADAO implements IDAO { @Override public Role getRole(long id) throws DAOException { preQuery(); try { Role o = em.getReference(Role.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFa...
@Test public void getRoleByIdTest() throws DAOException { Role role = DataManager.getInstance().getDao().getRole(1); Assert.assertNotNull(role); Assert.assertEquals(Long.valueOf(1), role.getId()); Assert.assertEquals("role 1 name", role.getName()); Assert.assertEquals("role 1 desc", role.getDescription()); Assert.asser...
JPADAO implements IDAO { @Override public boolean addRole(Role role) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(role); em.getTransaction().commit(); } finally { em.close(); } return true; } JPADAO(); JPADAO(String inPersistenceUnitN...
@Test public void addRoleTest() throws DAOException { Role role = new Role(); role.setName("role to add name"); role.setDescription("role to add desc"); role.getPrivileges().add("role to add priv 1"); Assert.assertTrue(DataManager.getInstance().getDao().addRole(role)); Assert.assertNotNull(role.getId()); Role role2 = D...
JPADAO implements IDAO { @Override public boolean updateRole(Role role) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(role); em.getTransaction().commit(); return true; } finally { em.close(); } } JPADAO(); JPADAO(String inPersistenceUnit...
@Test public void updateRoleTest() throws DAOException { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllRoles().size()); Role role = DataManager.getInstance().getDao().getRole(1); Assert.assertNotNull(role); Assert.assertEquals("role 1 name", role.getName()); Assert.assertEquals("role 1 desc", role.get...
JPADAO implements IDAO { @Override public boolean deleteRole(Role role) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); Role o = em.getReference(Role.class, role.getId()); em.remove(o); em.getTransaction().commit(); return true; } finally { em.close...
@Test public void deleteRoleTest() throws DAOException { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllRoles().size()); Role role = DataManager.getInstance().getDao().getRole(2); Assert.assertNotNull(role); Assert.assertTrue(DataManager.getInstance().getDao().deleteRole(role)); Assert.assertNull(DataM...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<BookmarkList> getAllBookmarkLists() throws DAOException { preQuery(); Query q = em.createQuery("SELECT o FROM BookmarkList o"); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); En...
@Test public void getAllBookmarkListsTest() throws DAOException { List<BookmarkList> result = DataManager.getInstance().getDao().getAllBookmarkLists(); Assert.assertEquals(2, result.size()); }
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<BookmarkList> getPublicBookmarkLists() throws DAOException { preQuery(); Query q = em.createQuery("SELECT o FROM BookmarkList o WHERE o.isPublic=true"); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManage...
@Test public void getPublicBookmarkListsTest() throws DAOException { List<BookmarkList> result = DataManager.getInstance().getDao().getPublicBookmarkLists(); Assert.assertEquals(1, result.size()); Assert.assertEquals(Long.valueOf(2), result.get(0).getId()); }
SearchResultConverter { public SearchHit convertMetadataToHit(String queryRegex, String fieldName, SolrDocument doc) { SearchHit hit = new SearchHit(); String mdText = SolrSearchIndex.getMetadataValues(doc, fieldName).stream().collect(Collectors.joining("; ")); Matcher m = Pattern.compile(AbstractSearchParser.getSingle...
@Test public void testConvertMetadataToHit() { SolrDocument doc = new SolrDocument(); doc.setField(SolrConstants.TITLE, text); doc.setField(SolrConstants.PI_TOPSTRUCT, pi); doc.setField(SolrConstants.LOGID, logId); doc.setField(SolrConstants.PI, pi); doc.setField(SolrConstants.THUMBPAGENO, pageNo); doc.setField(SolrCon...
JPADAO implements IDAO { @Override public BookmarkList getBookmarkList(long id) throws DAOException { preQuery(); try { BookmarkList o = em.getReference(BookmarkList.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitN...
@Test public void getBookmarkListByIdTest() throws DAOException { BookmarkList bl = DataManager.getInstance().getDao().getBookmarkList(1); Assert.assertNotNull(bl); Assert.assertEquals(Long.valueOf(1), bl.getId()); Assert.assertNotNull(bl.getOwner()); Assert.assertEquals(Long.valueOf(1), bl.getOwner().getId()); Assert....
JPADAO implements IDAO { @Override public BookmarkList getBookmarkListByShareKey(String shareKey) throws DAOException { preQuery(); Query q = em.createQuery("SELECT o FROM BookmarkList o WHERE o.shareKey = :shareKey"); q.setParameter("shareKey", shareKey); try { BookmarkList o = (BookmarkList) q.getSingleResult(); if (...
@Test public void getBookmarkListByShareKey_shouldReturnCorrectRow() throws Exception { BookmarkList bl = DataManager.getInstance().getDao().getBookmarkListByShareKey("c548e2ea6915acbfa17c3dc6f453f5b1"); Assert.assertNotNull(bl); Assert.assertEquals(Long.valueOf(1), bl.getId()); }
JPADAO implements IDAO { @Override public boolean addBookmarkList(BookmarkList bookmarkList) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(bookmarkList); em.getTransaction().commit(); } finally { em.close(); } return true; } JPADAO(); ...
@Test public void addBookmarkListTest() throws DAOException { User user = DataManager.getInstance().getDao().getUser(1); Assert.assertNotNull(user); BookmarkList bl = new BookmarkList(); bl.setName("add bookmark list test"); bl.setOwner(user); bl.setDescription("add bookmark list test desc"); Bookmark item = new Bookma...
JPADAO implements IDAO { @Override public boolean updateBookmarkList(BookmarkList bookmarkList) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(bookmarkList); em.getTransaction().commit(); if (this.em.contains(bookmarkList)) { this.em.refre...
@Test public void updateBookmarkListTest() throws DAOException { BookmarkList bl = DataManager.getInstance().getDao().getBookmarkList(1); Assert.assertNotNull(bl); Assert.assertEquals(2, bl.getItems().size()); int numBookmarkLists = DataManager.getInstance().getDao().getAllBookmarkLists().size(); Bookmark item = new Bo...
JPADAO implements IDAO { @Override public boolean deleteBookmarkList(BookmarkList bookmarkList) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); BookmarkList o = em.getReference(BookmarkList.class, bookmarkList.getId()); em.remove(o); em.getTransacti...
@Test public void deleteBookmarkListTest() throws DAOException { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllBookmarkLists().size()); BookmarkList bl = DataManager.getInstance().getDao().getBookmarkList(1); Assert.assertNotNull(bl); Assert.assertTrue(DataManager.getInstance().getDao().deleteBookmark...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Comment> getComments(int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT a FROM Comment a"); List<String> filterKeys =...
@Test public void getComments_shouldSortResultsCorrectly() throws Exception { List<Comment> ret = DataManager.getInstance().getDao().getComments(0, 2, "text", true, null); Assert.assertEquals(2, ret.size()); Assert.assertEquals(Long.valueOf(4), ret.get(0).getId()); Assert.assertEquals(Long.valueOf(3), ret.get(1).getId(...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<UserGroup> getUserGroups(int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT o FROM UserGroup o"); List<String> filter...
@Test public void getUserGroups_shouldSortResultsCorrectly() throws Exception { List<UserGroup> userGroups = DataManager.getInstance().getDao().getUserGroups(0, 2, "name", true, null); Assert.assertEquals(2, userGroups.size()); Assert.assertEquals(Long.valueOf(2), userGroups.get(0).getId()); Assert.assertEquals(Long.va...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<User> getUsers(int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT a FROM User a"); Map<String, String> params = new H...
@Test public void getUsers_shouldSortResultsCorrectly() throws Exception { List<User> users = DataManager.getInstance().getDao().getUsers(0, 2, "score", true, null); Assert.assertEquals(2, users.size()); Assert.assertEquals(Long.valueOf(2), users.get(0).getId()); Assert.assertEquals(Long.valueOf(1), users.get(1).getId(...
SearchResultConverter { public AnnotationResultList getAnnotationsFromAlto(Path path, String query) throws IOException, JDOMException { AnnotationResultList results = new AnnotationResultList(); AltoSearchParser parser = new AltoSearchParser(); AltoDocument doc = AltoDocument.getDocumentFromFile(path.toFile()); List<Wo...
@Test public void testGetAnnotationsFromAlto() throws IOException, JDOMException { String query = "Hollywood"; String queryRegex = AbstractSearchParser.getQueryRegex(query); Assert.assertNotNull("Converter is null", converter); Assert.assertNotNull("Alto file is null", altoFile); Assert.assertTrue("Query regex is Blank...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Search> getSearches(User owner, int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder(50); sbQuery.append("SELECT o FROM Search ...
@Test public void getSearches_shouldSortResultsCorrectly() throws Exception { List<Search> ret = DataManager.getInstance().getDao().getSearches(null, 0, 10, "name", true, null); Assert.assertEquals(3, ret.size()); Assert.assertEquals(Long.valueOf(3), ret.get(0).getId()); Assert.assertEquals(Long.valueOf(2), ret.get(1)....
JPADAO implements IDAO { @Override public long getSearchCount(User owner, Map<String, String> filters) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder(50); sbQuery.append("SELECT COUNT(o) FROM Search o"); if (owner != null) { sbQuery.append(" WHERE o.owner = :owner"); } List<String> filterKe...
@Test public void getSearchCount_shouldFilterResultsCorrectly() throws Exception { Map<String, String> filterMap = new HashMap<>(); filterMap.put("newHitsNotification", "true"); Assert.assertEquals(2, DataManager.getInstance().getDao().getSearchCount(null, filterMap)); }
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Role> getRoles(int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT o FROM Role o"); List<String> filterKeys = new Arra...
@Test public void getRoles_shouldSortResultsCorrectly() throws Exception { List<Role> ret = DataManager.getInstance().getDao().getRoles(0, 2, "name", true, null); Assert.assertEquals(2, ret.size()); Assert.assertEquals(Long.valueOf(2), ret.get(0).getId()); Assert.assertEquals(Long.valueOf(1), ret.get(1).getId()); } @Te...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<IpRange> getIpRanges(int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT o FROM IpRange o"); List<String> filterKeys =...
@Test public void getIpRanges_shouldSortResultsCorrectly() throws Exception { List<IpRange> ret = DataManager.getInstance().getDao().getIpRanges(0, 2, "name", true, null); Assert.assertEquals(2, ret.size()); Assert.assertEquals(Long.valueOf(2), ret.get(0).getId()); Assert.assertEquals(Long.valueOf(1), ret.get(1).getId(...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<CMSMediaItem> getAllCMSMediaItems() throws DAOException { synchronized (cmsRequestLock) { try { preQuery(); Query q = em.createQuery("SELECT o FROM CMSMediaItem o"); q.setFlushMode(FlushModeType.COMMIT); q.setHint("javax.persistence.cache.sto...
@Test public void getAllCMSMediaItems_shouldReturnAllItems() throws Exception { Assert.assertEquals(4, DataManager.getInstance().getDao().getAllCMSMediaItems().size()); }
SearchResultConverter { public AnnotationResultList getAnnotationsFromFulltext(String text, String pi, Integer pageNo, String query, long previousHitCount, int firstIndex, int numHits) { AnnotationResultList results = new AnnotationResultList(); long firstPageHitIndex = previousHitCount; long lastPageHitIndex = firstPa...
@Test public void testGetAnnotationsFromFulltext() { String query = "in"; String queryRegex = AbstractSearchParser.getQueryRegex(query); AnnotationResultList results = converter.getAnnotationsFromFulltext(text, pi, pageNo, queryRegex, 0, 0, 1000); Assert.assertEquals(1, results.hits.size()); Assert.assertEquals(2, resu...
JPADAO implements IDAO { @Override public CMSMediaItem getCMSMediaItem(long id) throws DAOException { synchronized (cmsRequestLock) { preQuery(); try { CMSMediaItem o = em.getReference(CMSMediaItem.class, id); em.refresh(o); return o; } catch (EntityNotFoundException e) { return null; } } } JPADAO(); JPADAO(String inP...
@Test public void getCMSMediaItem_shouldReturnCorrectItem() throws Exception { CMSMediaItem item = DataManager.getInstance().getDao().getCMSMediaItem(1); Assert.assertNotNull(item); Assert.assertEquals(Long.valueOf(1), item.getId()); Assert.assertEquals("image1.jpg", item.getFileName()); Assert.assertEquals(2, item.get...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<CMSPage> getAllCMSPages() throws DAOException { try { synchronized (cmsRequestLock) { preQuery(); Query q = em.createQuery("SELECT o FROM CMSPage o"); q.setFlushMode(FlushModeType.COMMIT); return q.getResultList(); } } catch (PersistenceExcep...
@Test public void getAllCMSPages_shouldReturnAllPages() throws Exception { Assert.assertEquals(3, DataManager.getInstance().getDao().getAllCMSPages().size()); }
JPADAO implements IDAO { @Override public long getCMSPageCount(Map<String, String> filters, List<String> allowedTemplates, List<String> allowedSubthemes, List<String> allowedCategories) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT count(DISTINCT a) FROM CMSPage").append(" a"); Map...
@Test public void getCMSPageCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(3L, DataManager.getInstance().getDao().getCMSPageCount(null, null, null, null)); } @Test public void getCMSPagesCount_shouldReturnCorrectCount() throws Exception { long numPages = DataManager.getInstance().getDao().getCM...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<CMSPage> getCMSPagesWithRelatedPi(int first, int pageSize, Date fromDate, Date toDate, List<String> templateIds) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT o FROM CMSPage o WHERE o.relatedPI IS NOT NUL...
@Test public void getCMSPagesWithRelatedPi_shouldReturnCorrectRows() throws Exception { Assert.assertEquals(1, DataManager.getInstance() .getDao() .getCMSPagesWithRelatedPi(0, 100, DateTools.createDate(2015, 1, 1, 0, 0), DateTools.createDate(2015, 12, 31, 0, 0), Arrays.asList("template_simple", "template_two")) .size()...
JPADAO implements IDAO { @Override public boolean isCMSPagesForRecordHaveUpdates(String pi, CMSCategory category, Date fromDate, Date toDate) throws DAOException { if (pi == null) { throw new IllegalArgumentException("pi may not be null"); } preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT COUNT(o) FROM CM...
@Test public void isCMSPagesForRecordHaveUpdates_shouldReturnCorrectValue() throws Exception { Assert.assertTrue(DataManager.getInstance() .getDao() .isCMSPagesForRecordHaveUpdates("PI_1", null, DateTools.createDate(2015, 1, 1, 0, 0), DateTools.createDate(2015, 12, 31, 0, 0))); Assert.assertFalse(DataManager.getInstanc...
JPADAO implements IDAO { @Override public long getCMSPageWithRelatedPiCount(Date fromDate, Date toDate, List<String> templateIds) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT COUNT(DISTINCT o.relatedPI) FROM CMSPage o WHERE o.relatedPI IS NOT NULL AND o.relatedPI <> ''"); if (from...
@Test public void getCMSPageWithRelatedPiCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(1, DataManager.getInstance() .getDao() .getCMSPageWithRelatedPiCount(DateTools.createDate(2015, 1, 1, 0, 0), DateTools.createDate(2015, 12, 31, 0, 0), Arrays.asList("template_simple", "template_two"))); Asse...
JPADAO implements IDAO { @Override public CMSPage getCMSPage(long id) throws DAOException { synchronized (cmsRequestLock) { logger.trace("getCMSPage: {}", id); preQuery(); try { CMSPage o = em.getReference(CMSPage.class, id); if (o != null) { updateCMSPageFromDatabase(o.getId()); } return o; } catch (EntityNotFoundExce...
@Test public void getCMSPage_shouldReturnCorrectPage() throws Exception { CMSPage page = DataManager.getInstance().getDao().getCMSPage(1); Assert.assertNotNull(page); Assert.assertEquals(Long.valueOf(1), page.getId()); Assert.assertEquals("template_simple", page.getTemplateId()); Assert.assertNotNull(page.getDateCreate...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<CMSNavigationItem> getAllTopCMSNavigationItems() throws DAOException { preQuery(); synchronized (cmsRequestLock) { try { Query q = em.createQuery("SELECT o FROM CMSNavigationItem o WHERE o.parentItem IS NULL"); q.setHint("javax.persistence.ca...
@Test public void getAllTopCMSNavigationItems_shouldReturnAllTopItems() throws Exception { List<CMSNavigationItem> items = DataManager.getInstance().getDao().getAllTopCMSNavigationItems(); Assert.assertEquals(2, items.size()); Collections.sort(items); Assert.assertEquals(Long.valueOf(1), items.get(0).getId()); Assert.a...
JPADAO implements IDAO { @Override public CMSNavigationItem getCMSNavigationItem(long id) throws DAOException { preQuery(); synchronized (cmsRequestLock) { try { CMSNavigationItem o = em.find(CMSNavigationItem.class, id); em.refresh(o); return o; } catch (EntityNotFoundException e) { return null; } } } JPADAO(); JPADA...
@Test public void getCMSNavigationItem_shouldReturnCorrectItemAndChildItems() throws Exception { CMSNavigationItem item = DataManager.getInstance().getDao().getCMSNavigationItem(1); Assert.assertNotNull(item); Assert.assertEquals(Long.valueOf(1), item.getId()); Assert.assertEquals("item 1", item.getItemLabel()); Assert...
JPADAO implements IDAO { @Override public long getUserCount(Map<String, String> filters) throws DAOException { String filterQuery = ""; Map<String, String> params = new HashMap<>(); if(filters != null) { String filterValue = filters.values().stream().findFirst().orElse(""); if(StringUtils.isNotBlank(filterValue)) { fil...
@Test public void getUserCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(3L, DataManager.getInstance().getDao().getUserCount(null)); } @Test public void getUserCount_shouldFilterCorrectly() throws Exception { Map<String, String> filters = new HashMap<>(); filters.put("filter", "1"); Assert.asser...
AltoSearchParser extends AbstractSearchParser { public List<List<Word>> findWordMatches(List<Word> words, String regex) { ListIterator<Word> iterator = words.listIterator(); List<List<Word>> results = new ArrayList<>(); while (iterator.hasNext()) { Word word = iterator.next(); if (Pattern.matches(regex, word.getSubsCon...
@Test public void testFindWordMatches() { String query = "diese* schönste*"; String regex = parser.getQueryRegex(query); List<Word> words = doc.getFirstPage().getAllWordsAsList().stream().filter(l -> l instanceof Word).map(l -> (Word) l).collect(Collectors.toList()); Assert.assertFalse("No words found in " + altoFile, ...
JPADAO implements IDAO { @Override public long getIpRangeCount(Map<String, String> filters) throws DAOException { return getRowCount("IpRange", null, filters); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); EntityManager getEntityManager(); @Override void startTransaction(); @Over...
@Test public void getIpRangeCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(2L, DataManager.getInstance().getDao().getIpRangeCount(null)); }
JPADAO implements IDAO { @Override public long getLicenseTypeCount(Map<String, String> filters) throws DAOException { return getRowCount("LicenseType", " WHERE a.core=false", filters); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); EntityManager getEntityManager(); @Override void ...
@Test public void getLicenseTypeCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(NUM_LICENSE_TYPES - 1, DataManager.getInstance().getDao().getLicenseTypeCount(null)); }
JPADAO implements IDAO { @Override public long getRoleCount(Map<String, String> filters) throws DAOException { return getRowCount("Role", null, filters); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); EntityManager getEntityManager(); @Override void startTransaction(); @Override v...
@Test public void getRoleCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(2L, DataManager.getInstance().getDao().getRoleCount(null)); }
JPADAO implements IDAO { @Override public long getUserGroupCount(Map<String, String> filters) throws DAOException { return getRowCount("UserGroup", null, filters); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); EntityManager getEntityManager(); @Override void startTransaction(); @...
@Test public void getUserGroupCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(2L, DataManager.getInstance().getDao().getUserGroupCount(null)); }
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<DownloadJob> getAllDownloadJobs() throws DAOException { preQuery(); Query q = em.createQuery("SELECT o FROM DownloadJob o"); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); Entit...
@Test public void getAllDownloadJobs_shouldReturnAllObjects() throws Exception { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllDownloadJobs().size()); }
JPADAO implements IDAO { @Override public DownloadJob getDownloadJob(long id) throws DAOException { preQuery(); try { DownloadJob o = em.getReference(DownloadJob.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitName)...
@Test public void getDownloadJob_shouldReturnCorrectObject() throws Exception { { DownloadJob job = DataManager.getInstance().getDao().getDownloadJob(1); Assert.assertNotNull(job); Assert.assertEquals(PDFDownloadJob.class, job.getClass()); Assert.assertEquals(Long.valueOf(1), job.getId()); Assert.assertEquals("PI_1", j...
JPADAO implements IDAO { @Override public DownloadJob getDownloadJobByIdentifier(String identifier) throws DAOException { if (identifier == null) { throw new IllegalArgumentException("identifier may not be null"); } preQuery(); StringBuilder sbQuery = new StringBuilder(); sbQuery.append("SELECT o FROM DownloadJob o WHE...
@Test public void getDownloadJobByIdentifier_shouldReturnCorrectObject() throws Exception { DownloadJob job = DataManager.getInstance().getDao().getDownloadJobByIdentifier("0afb73c418262beb2c88dc40c95831b7"); Assert.assertNotNull(job); Assert.assertEquals(PDFDownloadJob.class, job.getClass()); Assert.assertEquals(Long....
JPADAO implements IDAO { @Override public DownloadJob getDownloadJobByMetadata(String type, String pi, String logId) throws DAOException { if (type == null) { throw new IllegalArgumentException("type may not be null"); } if (pi == null) { throw new IllegalArgumentException("pi may not be null"); } preQuery(); StringBui...
@Test public void getDownloadJobByMetadata_shouldReturnCorrectObject() throws Exception { { DownloadJob job = DataManager.getInstance().getDao().getDownloadJobByMetadata(PDFDownloadJob.TYPE, "PI_1", null); Assert.assertNotNull(job); Assert.assertEquals(PDFDownloadJob.class, job.getClass()); Assert.assertEquals(Long.val...
AltoSearchParser extends AbstractSearchParser { public Map<Range<Integer>, List<Line>> findLineMatches(List<Line> lines, String regex) { String text = getText(lines); Map<Range<Integer>, List<Line>> map = new LinkedHashMap<>(); String singleWordRegex = getSingleWordRegex(regex); Matcher matcher = Pattern.compile(single...
@Test public void testFindLineMatches() { String query = "diese* schönste*"; String regex = parser.getQueryRegex(query); List<Line> lines = doc.getFirstPage().getAllLinesAsList().stream().filter(l -> l instanceof Line).map(l -> (Line) l).collect(Collectors.toList()); Map<Range<Integer>, List<Line>> hits = parser.findLi...
JPADAO implements IDAO { public static String createCMSPageFilter(Map<String, String> params, String pageParameter, List<String> allowedTemplateIds, List<String> allowedSubthemes, List<String> allowedCategoryIds) throws AccessDeniedException { String query = ""; int index = 0; if (allowedTemplateIds != null && !allowed...
@Test public void testCreateCMSPageFilter_createValidQueryWithAllParams() throws AccessDeniedException { List<String> categories = Arrays.asList(new String[] { "c1", "c2", "c3" }); List<String> subThemes = Arrays.asList(new String[] { "s1" }); List<String> templates = Arrays.asList(new String[] { "t1", "t2" }); Map<Str...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Campaign> getAllCampaigns() throws DAOException { try { synchronized (crowdsourcingRequestLock) { preQuery(); Query q = em.createQuery("SELECT o FROM Campaign o"); q.setFlushMode(FlushModeType.COMMIT); return q.getResultList(); } } catch (Per...
@Test public void getAllCampaigns_shouldReturnAllCampaigns() throws Exception { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllCampaigns().size()); }
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Campaign> getCampaigns(int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { synchronized (crowdsourcingRequestLock) { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT D...
@Test public void getCampaigns_shouldFilterCampaignsCorrectly() throws Exception { Assert.assertEquals(2, DataManager.getInstance().getDao().getCampaigns(0, 10, null, false, null).size()); Assert.assertEquals(1, DataManager.getInstance().getDao().getCampaigns(0, 10, null, false, Collections.singletonMap("visibility", "...
JPADAO implements IDAO { @Override public long getCampaignCount(Map<String, String> filters) throws DAOException { return getRowCount("Campaign", null, filters); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); EntityManager getEntityManager(); @Override void startTransaction(); @Ov...
@Test public void getCampaignCount_shouldCountCorrectly() throws Exception { Assert.assertEquals(2, DataManager.getInstance().getDao().getCampaignCount(null)); Assert.assertEquals(1, DataManager.getInstance().getDao().getCampaignCount(Collections.singletonMap("visibility", "PUBLIC"))); }
JPADAO implements IDAO { @Override public Campaign getCampaign(Long id) throws DAOException { synchronized (crowdsourcingRequestLock) { preQuery(); try { Campaign o = em.getReference(Campaign.class, id); if (o != null) { updateFromDatabase(id, Campaign.class); } return o; } catch (EntityNotFoundException e) { return nu...
@Test public void getCampaign_shouldReturnCorrectCampaign() throws Exception { Campaign campaign = DataManager.getInstance().getDao().getCampaign(1L); Assert.assertNotNull(campaign); campaign.setSelectedLocale(Locale.ENGLISH); Assert.assertEquals(Long.valueOf(1), campaign.getId()); Assert.assertEquals(CampaignVisibilit...
JPADAO implements IDAO { @Override public Question getQuestion(Long id) throws DAOException { synchronized (crowdsourcingRequestLock) { preQuery(); try { Question o = em.getReference(Question.class, id); if (o != null) { updateFromDatabase(id, Question.class); } return o; } catch (EntityNotFoundException e) { return nu...
@Test public void getQuestion_shouldReturnCorrectRow() throws Exception { Question q = DataManager.getInstance().getDao().getQuestion(1L); Assert.assertNotNull(q); Assert.assertEquals(Long.valueOf(1), q.getId()); Assert.assertEquals(Long.valueOf(1), q.getOwner().getId()); Assert.assertEquals("English text", q.getText()...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<CampaignRecordStatistic> getCampaignStatisticsForRecord(String pi, CampaignRecordStatus status) throws DAOException { synchronized (crowdsourcingRequestLock) { preQuery(); try { String query = "SELECT a FROM CampaignRecordStatistic a WHERE a....
@Test public void getCampaignStatisticsForRecord_shouldReturnCorrectRows() throws Exception { Assert.assertEquals(1, DataManager.getInstance().getDao().getCampaignStatisticsForRecord("PI_1", CampaignRecordStatus.FINISHED).size()); }
JPADAO implements IDAO { @Override public PersistentAnnotation getAnnotation(Long id) throws DAOException { preQuery(); Query q = em.createQuery("SELECT a FROM PersistentAnnotation a WHERE a.id = :id"); q.setParameter("id", id); q.setFlushMode(FlushModeType.COMMIT); PersistentAnnotation annotation = (PersistentAnnotati...
@Test public void getAnnotation_shouldReturnCorrectRow() throws Exception { PersistentAnnotation annotation = DataManager.getInstance().getDao().getAnnotation(1L); Assert.assertNotNull(annotation); Assert.assertEquals(Long.valueOf(1), annotation.getId()); }
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public StructElement getParent() throws IndexUnreachableException { StructElement parent = null; try { String parentIddoc = getMetadataValue(SolrConstants.IDDOC_PARENT); if (parentIddoc != null) { parent = new StructElement...
@Test public void getParent_shouldReturnParentCorrectly() throws Exception { long iddoc = DataManager.getInstance().getSearchIndex().getIddocByLogid(PI_KLEIUNIV, "LOG_0002"); Assert.assertNotEquals(-1, iddoc); StructElement element = new StructElement(iddoc); StructElement parent = element.getParent(); Assert.assertNot...
JPADAO implements IDAO { @Override public long getAnnotationCountForTarget(String pi, Integer page) throws DAOException { preQuery(); String query = "SELECT COUNT(a) FROM PersistentAnnotation a WHERE a.targetPI = :pi"; if (page != null) { query += " AND a.targetPageOrder = :page"; } else { query += " AND a.targetPageOr...
@Test public void getAnnotationCountForTarget_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(1, DataManager.getInstance().getDao().getAnnotationCountForTarget("PI_1", 1)); Assert.assertEquals(2, DataManager.getInstance().getDao().getAnnotationCountForTarget("PI_1", null)); }
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<PersistentAnnotation> getAnnotationsForTarget(String pi, Integer page) throws DAOException { preQuery(); String query = "SELECT a FROM PersistentAnnotation a WHERE a.targetPI = :pi"; if (page != null) { query += " AND a.targetPageOrder = :pag...
@Test public void getAnnotationsForTarget_shouldReturnCorrectRows() throws Exception { { List<PersistentAnnotation> annotations = DataManager.getInstance().getDao().getAnnotationsForTarget("PI_1", 1); Assert.assertEquals(1, annotations.size()); Assert.assertEquals(Long.valueOf(1), annotations.get(0).getId()); } { List<...
JPADAO implements IDAO { @Override public long getAnnotationCount(Map<String, String> filters) throws DAOException { return getRowCount("PersistentAnnotation", null, filters); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); EntityManager getEntityManager(); @Override void startTran...
@Test public void getAnnotationCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(5, DataManager.getInstance().getDao().getAnnotationCount(null)); Assert.assertEquals(3, DataManager.getInstance().getDao().getAnnotationCount(Collections.singletonMap("targetPI", "PI_1"))); }
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<PersistentAnnotation> getAnnotations(int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { synchronized (crowdsourcingRequestLock) { preQuery(); StringBuilder sbQuery = new StringBui...
@Test public void getAnnotations_shouldReturnCorrectRows() throws Exception { Assert.assertEquals(5, DataManager.getInstance().getDao().getAnnotations(0, 10, null, false, null).size()); Assert.assertEquals(2, DataManager.getInstance().getDao().getAnnotations(0, 10, null, false, Collections.singletonMap("targetPI", "PI_...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<GeoMap> getAllGeoMaps() throws DAOException { preQuery(); Query q = em.createQuery("SELECT u FROM GeoMap u"); q.setFlushMode(FlushModeType.COMMIT); List<GeoMap> list = q.getResultList(); list.forEach(map -> { updateFromDatabase(map.getId(), G...
@Test public void testGetAllGeoMaps() throws DAOException { List<GeoMap> maps = DataManager.getInstance().getDao().getAllGeoMaps(); Assert.assertEquals(2, maps.size()); }
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<CMSPage> getPagesUsingMap(GeoMap map) throws DAOException { preQuery(); Query qItems = em.createQuery( "SELECT item FROM CMSContentItem item WHERE item.geoMap = :map"); qItems.setParameter("map", map); List<CMSContentItem> itemList = qItems.g...
@Test public void testGetPagesUsingMap() throws DAOException { GeoMap map1 = DataManager.getInstance().getDao().getGeoMap(1l); GeoMap map2 = DataManager.getInstance().getDao().getGeoMap(2l); List<CMSPage> embedMap1 = DataManager.getInstance().getDao().getPagesUsingMap(map1); List<CMSPage> embedMap2 = DataManager.getIns...
JPADAO implements IDAO { @Override public CMSPageTemplateEnabled getCMSPageTemplateEnabled(String templateId) throws DAOException { preQuery(); Query q = em.createQuery("SELECT o FROM CMSPageTemplateEnabled o where o.templateId = :templateId"); q.setParameter("templateId", templateId); q.setFlushMode(FlushModeType.COMM...
@Test public void getCMSPageTemplateEnabled_shouldReturnCorrectValue() throws Exception { CMSPageTemplateEnabled o = DataManager.getInstance().getDao().getCMSPageTemplateEnabled("template_disabled"); Assert.assertNotNull(o); Assert.assertFalse(o.isEnabled()); }
JPADAO implements IDAO { static String createFilterQuery(String staticFilterQuery, Map<String, String> filters, Map<String, String> params) { StringBuilder join = new StringBuilder(); List<String> filterKeys = new ArrayList<>(); StringBuilder where = new StringBuilder(); if (StringUtils.isNotEmpty(staticFilterQuery)) {...
@Test public void createFilterQuery_shouldBuildMultikeyFilterQueryCorrectly() throws Exception { Map<String, String> filters = Collections.singletonMap("a-a_b-b_c-c_d-d", "bar"); Map<String, String> params = new HashMap<>(); Assert.assertEquals( "STATIC:query AND ( ( UPPER(a.a.a) LIKE :aabbccdd OR UPPER(a.b.b) LIKE :aa...
JPADAO implements IDAO { static String createFilterQuery2(String staticFilterQuery, Map<String, String> filters, Map<String, String> params) { StringBuilder q = new StringBuilder(" "); Map<String, String> tableKeys = new HashMap<>(); if (StringUtils.isNotEmpty(staticFilterQuery)) { q.append(staticFilterQuery); } if (fi...
@Test public void createFilterQuery_twoJoinedTables() throws Exception { Map<String, String> filters = Collections.singletonMap("b-B_c-C", "bar"); Map<String, String> params = new HashMap<>(); String expectedFilterString = " LEFT JOIN a.b b LEFT JOIN a.c c WHERE (UPPER(b.B) LIKE :bBcC OR UPPER(c.C) LIKE :bBcC)"; String...
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public boolean isAnchorChild() throws IndexUnreachableException { if (isWork() && isHasParent()) { return true; } return false; } StructElement(); StructElement(long luceneId); StructElement(long luceneId, SolrDocument do...
@Test public void isAnchorChild_shouldReturnTrueIfCurrentRecordIsVolume() throws Exception { long iddoc = DataManager.getInstance().getSearchIndex().getIddocFromIdentifier("306653648_1891"); Assert.assertNotEquals(-1, iddoc); StructElement element = new StructElement(iddoc); Assert.assertTrue(element.isAnchorChild()); ...
JPADAO implements IDAO { @Override public TermsOfUse getTermsOfUse() throws DAOException { preQuery(); Query q = em.createQuery("SELECT u FROM TermsOfUse u"); List results = q.getResultList(); if(results.isEmpty()) { return new TermsOfUse(); } else { return (TermsOfUse) results.get(0); } } JPADAO(); JPADAO(String inPe...
@Test public void testGetTermsOfUse() throws DAOException { TermsOfUse tou = DataManager.getInstance().getDao().getTermsOfUse(); Assert.assertNotNull(tou); }
JPADAO implements IDAO { @Override public boolean isTermsOfUseActive() throws DAOException { preQuery(); Query q = em.createQuery("SELECT u.active FROM TermsOfUse u"); List results = q.getResultList(); if(results.isEmpty()) { return false; } else { return (boolean) results.get(0); } } JPADAO(); JPADAO(String inPersist...
@Test public void testIsTermsOfUseActive() throws DAOException { boolean active = DataManager.getInstance().getDao().isTermsOfUseActive(); Assert.assertFalse(active); }
JPADAO implements IDAO { @Override public boolean saveTermsOfUse(TermsOfUse tou) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); if(tou.getId() == null) { em.persist(tou); } else { em.merge(tou); } em.getTransaction().commit(); tou = this.em.getRefe...
@Test public void testSaveTermsOfUse() throws DAOException { Assert.assertFalse(DataManager.getInstance().getDao().isTermsOfUseActive()); TermsOfUse tou = new TermsOfUse(); tou.setActive(true); DataManager.getInstance().getDao().saveTermsOfUse(tou); Assert.assertTrue(DataManager.getInstance().getDao().isTermsOfUseActiv...
JPADAO implements IDAO { @Override public boolean resetUserAgreementsToTermsOfUse() throws DAOException { List<User> users = getAllUsers(true); users.forEach(u -> u.setAgreedToTermsOfUse(false)); users.forEach(u -> { try { updateUser(u); } catch (DAOException e) { logger.error("Error resetting user agreement for user "...
@Test public void testResetUserAgreementsToTermsOfUse() throws DAOException { List<User> users = DataManager.getInstance().getDao().getAllUsers(true); Assert.assertTrue(users.stream().allMatch(u -> !u.isAgreedToTermsOfUse())); for (User user : users) { user.setAgreedToTermsOfUse(true); DataManager.getInstance().getDao(...
CMSCategoryUpdate implements IModelUpdate { public boolean convertData() throws DAOException { if (this.entityMap == null || this.media == null || this.pages == null || this.content == null || this.categories == null) { throw new IllegalStateException("Must successfully run loadData() before calling convertData()"); } ...
@Test public void testAddCategoriesToPages() throws DAOException { update.convertData(); CMSPage page = update.pages.stream().filter(p -> p.getId().equals(2l)).findFirst().get(); Assert.assertEquals(2, page.getCategories().size()); Assert.assertEquals("categoryb", page.getCategories().get(0).getName()); Assert.assertEq...
CMSCategoryUpdate implements IModelUpdate { protected List<CMSCategory> createCategories(Map<String, Map<String, List<Long>>> entityMap) { return entityMap.values() .stream() .flatMap(map -> map.keySet().stream()) .flatMap(name -> Arrays.stream(name.split(CLASSIFICATION_SEPARATOR_REGEX))) .filter(name -> StringUtils.is...
@Test public void testCreateCategories() throws DAOException { update.convertData(); Assert.assertEquals(5, update.categories.size()); Assert.assertTrue(update.categories.stream().anyMatch(cat -> cat.getName().equals("categoryc"))); }
LoginFilter implements Filter { public static boolean isRestrictedUri(String uri) { if (uri == null) { return false; } if (uri.matches("/?viewer/.*")) { uri = uri.replaceAll("/?viewer/", "/"); } logger.trace("uri: {}", uri); switch (uri.trim()) { case "/myactivity/": case "/mysearches/": return true; default: if (uri.s...
@Test public void isRestrictedUri_shouldReturnTrueForCertainPrettyUris() throws Exception { Assert.assertTrue(LoginFilter.isRestrictedUri("/myactivity/")); Assert.assertTrue(LoginFilter.isRestrictedUri("/mysearches/")); Assert.assertTrue(LoginFilter.isRestrictedUri("/user/bookmarks/show")); Assert.assertTrue(LoginFilte...
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public String getImageUrl(int width, int height) throws ViewerConfigurationException { String filename = getMetadataValue(SolrConstants.THUMBNAIL); if (filename != null) { return BeanUtils.getImageDeliveryBean().getThumbs()...
@Test public void getImageUrl_shouldConstructUrlCorrectly() throws Exception { StructElement element = new StructElement(iddocKleiuniv); Assert.assertEquals(ConfigurationTest.APPLICATION_ROOT_URL + "api/v1/records/" + PI_KLEIUNIV + "/files/images/00000001.tif/full/!600,800/0/default.jpg", element.getImageUrl(600, 800))...
Version { static String getInfo(String label, String infoText) { String regex = label + ": *(.*)"; Matcher matcher = Pattern.compile(regex).matcher(infoText); if (matcher.find()) { return matcher.group(1); } return "?"; } @Deprecated static String getBuildDate(String pattern); @Deprecated static String convertDate(Str...
@Test public void getInfo_shouldExtractFieldsCorrectly() throws Exception { Assert.assertEquals("20.01", Version.getInfo("Public-Version", MANIFEST)); Assert.assertEquals("Apache Maven", Version.getInfo("Created-By", MANIFEST)); Assert.assertEquals("2020-01-15 18:30", Version.getInfo("Implementation-Build-Date", MANIFE...
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public StructElement getTopStruct() throws PresentationException, IndexUnreachableException { if (work || anchor) { this.topStruct = this; return this; } if (this.topStruct == null) { String topstructIddoc = getMetadataValu...
@Test public void getTopStruct_shouldRetrieveTopStructCorrectly() throws Exception { long iddoc = DataManager.getInstance().getSearchIndex().getIddocByLogid(PI_KLEIUNIV, "LOG_0002"); Assert.assertNotEquals(-1, iddoc); StructElement element = new StructElement(iddoc); StructElement topStruct = element.getTopStruct(); As...
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public String getFirstVolumeFieldValue(String field) throws PresentationException, IndexUnreachableException { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (anchor) { SolrDocument d...
@Test public void getFirstVolumeFieldValue_shouldReturnCorrectValue() throws Exception { SolrDocument doc = DataManager.getInstance().getSearchIndex().getFirstDoc(SolrConstants.PI + ":306653648", null); Assert.assertNotNull(doc); StructElement element = new StructElement(Long.valueOf((String) doc.getFieldValue(SolrCons...
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public boolean isHasChildren() throws IndexUnreachableException, PresentationException { if (hasChildren == null) { if (DataManager.getInstance() .getSearchIndex() .getHitCount(new StringBuilder(SolrConstants.IDDOC_PARENT)....
@Test public void isHasChildren_shouldReturnTrueIfElementHasChildren() throws Exception { StructElement element = new StructElement(iddocKleiuniv); Assert.assertTrue(element.isHasChildren()); }
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public String getGroupLabel(String groupIdentifier, String altValue) throws IndexUnreachableException { if (groupIdentifier == null) { throw new IllegalArgumentException("groupIdentifier may not be null"); } if (groupLabels...
@Test public void getGroupLabel_shouldReturnAltValueOfNoLabelWasFound() throws Exception { StructElement element = new StructElement(1L); Assert.assertEquals("alt", element.getGroupLabel("id10T", "alt")); }
TemplateDebugger { public String render() { STGroupFile templateGroup = new STGroupFile(templateGroupFile); ST template = templateGroup.getInstanceOf(templateName); if (template == null) { throw new IllegalStateException( String.format( "The template named [%s] does not exist in the template group [%s]", templateName, ...
@Test public void testDebugger() throws Exception { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); InputStream yaml = getClass().getResourceAsStream( "/yaml/templateDebugger.yml"); TemplateDebugger debugger = mapper.readValue(yaml, TemplateDebugger.class); assertNotNull(debugger); String rendered = debugger...
RxStores { public static <STATE> Observable<STATE> states(Store<STATE> store) { if (store == null) { throw new IllegalArgumentException("Store is null"); } return Observable.create(new StoreOnSubscribe<>(store), BackpressureMode.ERROR); } private RxStores(); static Observable<STATE> states(Store<STATE> store); }
@Test public void states_should_observeInitialState() { Store<Integer> store = new Store<>(0); TestSubscriber<Integer> testSubscriber = new TestSubscriber<>(); states(store).subscribe(testSubscriber); testSubscriber.assertNoTerminalEvent(); testSubscriber.assertValue(0); } @Test public void states_should_observeStateCh...
RxStores { public static <STATE> Observable<STATE> states(Store<STATE> store) { if (store == null) { throw new IllegalArgumentException("Store is null"); } return Observable.create(new StoreOnSubscribe<>(store)); } private RxStores(); static Observable<STATE> states(Store<STATE> store); }
@Test public void states_should_observeStateChanges() { Store<Integer> store = new Store<>(0); TestObserver<Integer> testSubscriber = new TestObserver<>(); states(store).subscribe(testSubscriber); store.dispatch(integer -> integer + 1); testSubscriber.assertNotComplete(); testSubscriber.assertValues(0, 1); } @Test publ...
SingleActionCommand implements Action<STATE>, Command<STATE> { @Override public final Observable<? extends Action<STATE>> actions() { return just(this); } @Override final Observable<? extends Action<STATE>> actions(); }
@Test public void actions_should_returnThis() { SingleActionCommand<String> action = new SingleActionCommandUnderTest(); final Action observedAction = action.actions().blockingFirst(); assertThat(action, is(observedAction)); } @Test public void actions_should_returnThis() { SingleActionCommand<String> action = new Sing...
Store { public STATE getState() { return state; } @SafeVarargs Store(STATE initialState, Middleware<STATE>... middlewares); synchronized void dispatch(Action<STATE> action); STATE getState(); void subscribe(StateChangeListener<STATE> listener); @SuppressWarnings("WeakerAccess") void unsubscribe(StateChangeListener<STA...
@Test public void testStoreWithInitialState_shouldReturnInitialState() { Store<Integer> store = new Store<>(0); Integer state = store.getState(); assertThat(state, is(0)); }
Store { public synchronized void dispatch(Action<STATE> action) { actionQueue.add(action); if (isDispatching.get()) { return; } emitSequentially(); } @SafeVarargs Store(STATE initialState, Middleware<STATE>... middlewares); synchronized void dispatch(Action<STATE> action); STATE getState(); void subscribe(StateChangeL...
@Test(expected = IllegalStateException.class) public void testDispatchAction_withMiddleWare_shouldFailWhenMiddlewareDoesNotCallProceed() { Middleware<Integer> mockMiddleWare = chain -> { }; Store<Integer> store = new Store<>(0, mockMiddleWare); final Action<Integer> incrementAction = integer -> integer + 1; store.dispa...
CameraClient { public Call<State> state() { return service.state(); } CameraClient(); CameraClient(String basePath); Call<State> state(); Call<Info> info(); Call<ListFiles.Response> listFiles(ListFiles listFilesCommand); Call<Status> commandStatus(Command.CommandId id); }
@Test public void state() throws Exception { final MockResponse mockResponse = new MockResponse() .setResponseCode(200) .setBody(loadFile("fixtures/cameraStateResponse.json")); server.enqueue(mockResponse); final Response<State> response = client.state().execute(); assertThat(response.code(), equalTo(200)); final State...
CameraClient { public Call<Info> info() { return service.info(); } CameraClient(); CameraClient(String basePath); Call<State> state(); Call<Info> info(); Call<ListFiles.Response> listFiles(ListFiles listFilesCommand); Call<Status> commandStatus(Command.CommandId id); }
@Test public void info() throws Exception { final MockResponse mockResponse = new MockResponse() .setResponseCode(200) .setBody(loadFile("fixtures/cameraInfoResponse.json")); server.enqueue(mockResponse); final retrofit2.Response<Info> response = client.info().execute(); final Info info = response.body(); assertThat(in...
CameraClient { public Call<Status> commandStatus(Command.CommandId id) { return service.commandStatus(id); } CameraClient(); CameraClient(String basePath); Call<State> state(); Call<Info> info(); Call<ListFiles.Response> listFiles(ListFiles listFilesCommand); Call<Status> commandStatus(Command.CommandId id); }
@Test public void commandStatus() throws Exception { server.enqueue( new MockResponse() .setResponseCode(200) .setBody(loadFile("fixtures/cameraStatusResponse.json")) ); final Response<Status> statusResponse = client.commandStatus( new Command.CommandId("fancyCommandId") ).execute(); final RecordedRequest recordedReque...
LocationFragment extends LifecycleFragment implements LocationListener { @Override public void onAttach(Context context) { super.onAttach(context); FragmentActivity activity = getActivity(); LocationViewModel locationViewModel = getViewModelProvider(activity).get(LocationViewModel.class); LiveData<CommonLocation> liveD...
@Test public void givenALocationFragment_whenOnAttachIsCalled_thenItStartsObservingTheLiveDataObject() throws Exception { locationFragment.onAttach(context); verify(locationLiveData).observe(eq(locationFragment), any(Observer.class)); }
LoadosophiaUploaderGui extends AbstractListenerGui implements HyperlinkListener, Clearable, UnsharedComponent { @Override public String getStaticLabel() { return "bzm - BlazeMeter Sense Uploader"; } LoadosophiaUploaderGui(); @Override String getStaticLabel(); @Override String getLabelResource(); @Override TestElement c...
@Test public void testGetStaticLabel() { System.out.println("getStaticLabel"); LoadosophiaUploaderGui instance = new LoadosophiaUploaderGui(); String result = instance.getStaticLabel(); Assert.assertTrue(result.length() > 0); }
LoadosophiaClient implements BackendListenerClient { public JSONArray getDataToSend(List<SampleResult> list) { JSONArray data = new JSONArray(); SortedMap<Long, List<SampleResult>> sortedResults = sortResults(list); for (Long sec : sortedResults.keySet()) { data.add(getAggregateSecond(sec, sortedResults.get(sec))); } r...
@Test public void testGetDataToSend() { System.out.println("addSample"); LoadosophiaClient instance = new LoadosophiaClient(); List<SampleResult> list = new LinkedList<>(); list.add(new SampleResult(System.currentTimeMillis(), 1)); list.add(new SampleResult(System.currentTimeMillis() + 1000, 1)); list.add(new SampleRes...
LoadosophiaClient implements BackendListenerClient { public static JSONObject getQuantilesJSON(Long[] rtimes) { JSONObject result = new JSONObject(); Arrays.sort(rtimes); double[] quantiles = {0.25, 0.50, 0.75, 0.80, 0.90, 0.95, 0.98, 0.99, 1.00}; Stack<Long> timings = new Stack<>(); timings.addAll(Arrays.asList(rtimes...
@Test public void testGetQuantiles() { System.out.println("getQuantiles"); Long[] rtimes = {1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L}; JSONObject result = LoadosophiaClient.getQuantilesJSON(rtimes); assertEquals("{\"100.0\":10,\"99.0\":10,\"98.0\":10,\"95.0\":10,\"90.0\":9,\"80.0\":8,\"75.0\":8,\"50.0\":5,\"25.0\":3}", ...
LoadosophiaClient implements BackendListenerClient { protected void stop() { String redirectLink = ""; try { flush(); if (fileName == null) { throw new IOException("File for upload was not set, search for errors above in log"); } LinkedList<String> monFiles; if (hasStandardSet()) { monFiles = PerfMonCollector.getFiles(...
@Test public void testStop() throws Exception { LoadosophiaClient client = new LoadosophiaClient(); client.setOnlineInitiated(true); client.setResultCollector(new ResultCollector()); client.setFileName(""); StatusNotifierCallbackTest.StatusNotifierCallbackImpl notifierCallback = new StatusNotifierCallbackTest.StatusNot...
LoadosophiaUploader extends BackendListener implements StatusNotifierCallback, Clearable { public void setTitle(String prefix) { setProperty(TITLE, prefix); } LoadosophiaUploader(); @Override void testStarted(); @Override void testEnded(); @Override void testStarted(String host); @Override void testEnded(String host); ...
@Test public void testSetFilePrefix() { System.out.println("setFilePrefix"); String prefix = ""; LoadosophiaUploader instance = new LoadosophiaUploaderEmul(); instance.setTitle(prefix); } @Test public void testSetTitle() { System.out.println("setTitle"); String prefix = ""; LoadosophiaUploader instance = new Loadosophi...
LoadosophiaUploader extends BackendListener implements StatusNotifierCallback, Clearable { public void setProject(String proj) { setProperty(PROJECT, proj); } LoadosophiaUploader(); @Override void testStarted(); @Override void testEnded(); @Override void testStarted(String host); @Override void testEnded(String host); ...
@Test public void testSetProject() { System.out.println("setProject"); String proj = ""; LoadosophiaUploader instance = new LoadosophiaUploaderEmul(); instance.setProject(proj); }
LoadosophiaUploader extends BackendListener implements StatusNotifierCallback, Clearable { public void setUploadToken(String token) { setProperty(UPLOAD_TOKEN, token); } LoadosophiaUploader(); @Override void testStarted(); @Override void testEnded(); @Override void testStarted(String host); @Override void testEnded(Str...
@Test public void testSetUploadToken() { System.out.println("setUploadToken"); String token = ""; LoadosophiaUploader instance = new LoadosophiaUploaderEmul(); instance.setUploadToken(token); }
LoadosophiaUploader extends BackendListener implements StatusNotifierCallback, Clearable { public String getProject() { return getPropertyAsString(PROJECT); } LoadosophiaUploader(); @Override void testStarted(); @Override void testEnded(); @Override void testStarted(String host); @Override void testEnded(String host); ...
@Test public void testGetProject() { System.out.println("getProject"); LoadosophiaUploader instance = new LoadosophiaUploaderEmul(); String expResult = ""; String result = instance.getProject(); Assert.assertEquals(expResult, result); }
LoadosophiaUploader extends BackendListener implements StatusNotifierCallback, Clearable { public String getUploadToken() { return getPropertyAsString(UPLOAD_TOKEN).trim(); } LoadosophiaUploader(); @Override void testStarted(); @Override void testEnded(); @Override void testStarted(String host); @Override void testEnde...
@Test public void testGetUploadToken() { System.out.println("getUploadToken"); LoadosophiaUploader instance = new LoadosophiaUploaderEmul(); String expResult = ""; String result = instance.getUploadToken(); Assert.assertEquals(expResult, result); }
LoadosophiaUploader extends BackendListener implements StatusNotifierCallback, Clearable { public String getTitle() { return getPropertyAsString(TITLE); } LoadosophiaUploader(); @Override void testStarted(); @Override void testEnded(); @Override void testStarted(String host); @Override void testEnded(String host); @Ove...
@Test public void testGetFilePrefix() { System.out.println("getFilePrefix"); LoadosophiaUploader instance = new LoadosophiaUploaderEmul(); String expResult = ""; String result = instance.getTitle(); Assert.assertEquals(expResult, result); } @Test public void testGetTitle() { System.out.println("getTitle"); LoadosophiaU...
LoadosophiaUploaderGui extends AbstractListenerGui implements HyperlinkListener, Clearable, UnsharedComponent { @Override public String getLabelResource() { return getClass().getCanonicalName(); } LoadosophiaUploaderGui(); @Override String getStaticLabel(); @Override String getLabelResource(); @Override TestElement cre...
@Test public void testGetLabelResource() { System.out.println("getLabelResource"); LoadosophiaUploaderGui instance = new LoadosophiaUploaderGui(); String result = instance.getLabelResource(); Assert.assertTrue(result.length() > 0); }
LoadosophiaUploader extends BackendListener implements StatusNotifierCallback, Clearable { public String getStoreDir() { return getPropertyAsString(STORE_DIR); } LoadosophiaUploader(); @Override void testStarted(); @Override void testEnded(); @Override void testStarted(String host); @Override void testEnded(String host...
@Test public void testGetStoreDir() { System.out.println("getStoreDir"); LoadosophiaUploader instance = new LoadosophiaUploaderEmul(); String expResult = ""; String result = instance.getStoreDir(); Assert.assertEquals(expResult, result); }