src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_PLAINTEXT) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records" }, summary = "Get plaintext for a single page") public String getPlaintext( @Parameter(description = "Filename containing the text") @PathParam("filename") String filename) throws Conte...
@Test public void testGetPlaintext() throws JDOMException, IOException { String url = urls.path(RECORDS_FILES, RECORDS_FILES_PLAINTEXT).params(PI, FILENAME + ".txt").build(); try (Response response = target(url) .request() .accept(MediaType.TEXT_PLAIN) .get()) { assertEquals(response.getStatusInfo().getReasonPhrase(), ...
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_TEI) @Produces({ MediaType.TEXT_XML }) @Operation(tags = { "records" }, summary = "Get fulltext for a single page in TEI format") public String getTEI( @Parameter(description = "Filename containing the text") @PathParam("filename") String filename) throws Presen...
@Test public void testGetTEI() throws JDOMException, IOException { String url = urls.path(RECORDS_FILES, RECORDS_FILES_TEI).params(PI, FILENAME + ".xml").build(); try (Response response = target(url) .request() .accept(MediaType.TEXT_XML) .get()) { assertEquals(response.getStatusInfo().getReasonPhrase(), 200, response....
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_PDF) @Produces({ "application/pdf" }) @Operation(tags = { "records" }, summary = "Non-canonical URL to PDF file") public Response getPDF( @Parameter(description = "Filename containing the text") @PathParam("filename") String filename) throws ContentLibException ...
@Test public void testGetPdf() { String url = urls.path(RECORDS_FILES, RECORDS_FILES_PDF).params(PI, FILENAME).build(); try (Response response = target(url) .request() .accept("application/pdf") .get()) { assertEquals(response.getStatusInfo().getReasonPhrase(), 200, response.getStatus()); assertNotNull("Should return u...
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_SOURCE) @Operation(tags = { "records" }, summary = "Get source files of record") @Produces(MediaType.APPLICATION_OCTET_STREAM) public StreamingOutput getSourceFile( @Parameter(description = "Source file name") @PathParam("filename") String filename) throws Conte...
@Test public void testGetSourceFile() { String url = urls.path(RECORDS_FILES, RECORDS_FILES_SOURCE).params(PI, "text.txt").build(); try (Response response = target(url) .request() .get()) { assertEquals(response.getStatusInfo().getReasonPhrase(), 200, response.getStatus()); String contentType = response.getHeaderString...
SemiRandomOrderComparator implements Comparator<T> { @Override public int compare(T a, T b) { Integer nA = comparisonOperator.apply(a); Integer nB = comparisonOperator.apply(b); if (nA.equals(0)) { nA = Integer.MAX_VALUE; } if (nB.equals(0)) { nB = Integer.MAX_VALUE; } if (nA.equals(nB)) { return Integer.compare(valueF...
@Test public void testComparatorContract() { Random picker = new Random(System.nanoTime()); for (int i = 0; i < testRuns; i++) { SortTestObject o1 = testArray[picker.nextInt(testArray.length)]; SortTestObject o2 = testArray[picker.nextInt(testArray.length)]; SemiRandomOrderComparator<SortTestObject> comparator = new Se...
RecordSectionResource { @GET @javax.ws.rs.Path(RECORDS_SECTIONS_RIS_FILE) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records"}, summary = "Download ris as file") public String getRISAsFile() throws PresentationException, IndexUnreachableException, DAOException, ContentLibException { StructElement se = get...
@Test public void testGetRISAsFile() { try(Response response = target(urls.path(RECORDS_SECTIONS, RECORDS_SECTIONS_RIS_FILE).params(PI, DIVID).build()) .request() .get()) { assertEquals("Should return status 200", 200, response.getStatus()); assertNotNull("Should return user object as json", response.getEntity()); Stri...
RecordSectionResource { @GET @javax.ws.rs.Path(RECORDS_SECTIONS_RIS_TEXT) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records"}, summary = "Get ris as text") public String getRISAsText() throws PresentationException, IndexUnreachableException, ContentNotFoundException, DAOException { StructElement se = get...
@Test public void testGetRISAsText() { try(Response response = target(urls.path(RECORDS_SECTIONS, RECORDS_SECTIONS_RIS_TEXT).params(PI, DIVID).build()) .request() .accept(MediaType.TEXT_PLAIN) .get()) { assertEquals("Should return status 200", 200, response.getStatus()); assertNotNull("Should return user object as json...
RecordSectionResource { @GET @javax.ws.rs.Path(RECORDS_SECTIONS_RANGE) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = {"records", "iiif"}, summary = "Get IIIF range for section") @IIIFPresentationBinding public IPresentationModelElement getRange() throws ContentNotFoundException, PresentationException, Ind...
@Test public void testGetRange() throws JsonMappingException, JsonProcessingException { String url = urls.path(RECORDS_SECTIONS, RECORDS_SECTIONS_RANGE).params(PI, DIVID).build(); try(Response response = target(url) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, r...
ViewerRecordPDFResource extends MetsPdfResource { @Override @GET @Path(ApiUrls.RECORDS_PDF) @Produces("application/pdf") @ContentServerPdfBinding @Operation(tags = { "records" }, summary = "Get PDF for entire record") public StreamingOutput getPdf() throws ContentLibException { logger.trace("getPdf: {}", filename); res...
@Test public void testGetPdf() { String url = urls.path(RECORDS_RECORD, RECORDS_PDF).params(PI).build(); try (Response response = target(url) .request() .header("x-forwarded-for", "1.2.3.4") .accept("application/pdf") .get()) { assertEquals("Should return status 200", 200, response.getStatus()); assertNotNull("Should r...
ViewerSectionPDFResource extends MetsPdfResource { @GET @Path(ApiUrls.RECORDS_SECTIONS_PDF) @Produces("application/pdf") @ContentServerPdfBinding @Operation(tags = { "records"}, summary = "Get PDF for section of record") public StreamingOutput getPdf() throws ContentLibException { response.addHeader("Content-Dispositio...
@Test public void testGetPdf() { String url = urls.path(RECORDS_SECTIONS, RECORDS_SECTIONS_PDF).params(PI, LOGID).build(); try (Response response = target(url) .request() .header("x-forwarded-for", "1.2.3.4") .accept("application/pdf") .get()) { assertEquals(response.getStatusInfo().getReasonPhrase(), 200, response.get...
RecordPageResource { @GET @javax.ws.rs.Path(RECORDS_PAGES_SEQUENCE) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "records", "iiif" }, summary = "Get IIIF base sequence") @IIIFPresentationBinding public IPresentationModelElement getSequence() throws ContentNotFoundException, PresentationException, Index...
@Test public void testGetSequence() throws JsonMappingException, JsonProcessingException { String url = urls.path(RECORDS_PAGES, RECORDS_PAGES_SEQUENCE).params(PI).build(); try(Response response = target(url) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, response...
RecordPageResource { @GET @javax.ws.rs.Path(RECORDS_PAGES_CANVAS) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "records", "iiif" }, summary = "Get IIIF canvas for a page") @IIIFPresentationBinding public IPresentationModelElement getCanvas( @Parameter(description = "Page numer (1-based") @PathParam("pa...
@Test public void testGetCanvas() throws JsonMappingException, JsonProcessingException { String url = urls.path(RECORDS_PAGES, RECORDS_PAGES_CANVAS).params(PI, PAGENO).build(); try(Response response = target(url) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, resp...
RecordPageResource { @GET @javax.ws.rs.Path(RECORDS_PAGES_COMMENTS) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "records", "annotations"}, summary = "List comments for a page") public IAnnotationCollection getCommentsForPage( @Parameter(description = "Page numer (1-based") @PathParam("pageNo") Integer...
@Test public void testGetCommentsForPage() throws JsonMappingException, JsonProcessingException { try(Response response = target(urls.path(RECORDS_PAGES, RECORDS_PAGES_COMMENTS).params(PI_ANNOTATIONS, PAGENO_ANNOTATIONS).build()) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return statu...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_RIS_FILE) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records" }, summary = "Download ris as file") public String getRISAsFile() throws PresentationException, IndexUnreachableException, DAOException, ContentLibException { StructElement se = getStructElement(p...
@Test public void testGetRISAsFile() { try(Response response = target(urls.path(RECORDS_RECORD, RECORDS_RIS_FILE).params(PI).build()) .request() .get()) { assertEquals("Should return status 200", 200, response.getStatus()); assertNotNull("Should return user object as json", response.getEntity()); String entity = respon...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_RIS_TEXT) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records" }, summary = "Get ris as text") public String getRISAsText() throws PresentationException, IndexUnreachableException, ContentNotFoundException, DAOException { if (servletResponse != null) { servle...
@Test public void testGetRISAsText() { try(Response response = target(urls.path(RECORDS_RECORD, RECORDS_RIS_TEXT).params(PI).build()) .request() .accept(MediaType.TEXT_PLAIN) .get()) { assertEquals("Should return status 200", 200, response.getStatus()); assertNotNull("Should return user object as json", response.getEnt...
CMSContentItem implements Comparable<CMSContentItem>, CMSMediaHolder { @Override public CMSContentItem clone() { CMSContentItem clone = new CMSContentItem(this, null); return clone; } CMSContentItem(); CMSContentItem(CMSContentItem blueprint, CMSPageLanguageVersion owner); CMSContentItem(CMSContentItemType type); Fun...
@Test public void testClone() { CMSMediaItem item1 = new CMSMediaItem(); CMSContentItem original = new CMSContentItem(CMSContentItemType.HTML); original.setBaseCollection("base-collection"); original.setCategories(new ArrayList(Collections.singleton(new CMSCategory("category")))); original.setCollectionBaseLevels(2); o...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_TOC) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records" }, summary = "Get table of contents of records") public String getTOCAsText() throws PresentationException, IndexUnreachableException, ContentNotFoundException, DAOException, ViewerConfigurationExcepti...
@Test public void testGetTOCAsText() { try(Response response = target(urls.path(RECORDS_RECORD, RECORDS_TOC).params(PI).build()) .request() .accept(MediaType.TEXT_PLAIN) .get()) { assertEquals("Should return status 200", 200, response.getStatus()); assertNotNull("Should return user object as json", response.getEntity()...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_ANNOTATIONS) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "records", "annotations" }, summary = "List annotations for a record") public IAnnotationCollection getAnnotationsForRecord( @Parameter( description = "annotation format of the response. If it is '...
@Test public void testGetAnnotationsForRecord() throws JsonMappingException, JsonProcessingException { try(Response response = target(urls.path(RECORDS_RECORD, RECORDS_ANNOTATIONS).params(PI_ANNOTATIONS).build()) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, resp...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_ANNOTATIONS + "/{page}") @Produces({ MediaType.APPLICATION_JSON }) @ApiResponse(responseCode = "400", description = "If the page number is out of bounds") public AnnotationPage getAnnotationPageForRecord(@PathParam("page") Integer page) throws DAOException, IllegalRequest...
@Test public void testGetAnnotationPageForRecord() throws JsonMappingException, JsonProcessingException { try(Response response = target(urls.path(RECORDS_RECORD, RECORDS_ANNOTATIONS).params(PI_ANNOTATIONS).build() + "1/") .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200",...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_COMMENTS) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "records", "annotations" }, summary = "List comments for a record") public IAnnotationCollection getCommentsForRecord( @Parameter( description = "annotation format of the response. If it is 'oa' the c...
@Test public void testGetCommentsForRecord() throws JsonMappingException, JsonProcessingException { try(Response response = target(urls.path(RECORDS_RECORD, RECORDS_COMMENTS).params(PI_ANNOTATIONS).build()) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, response.g...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_COMMENTS + "/{page}") @Produces({ MediaType.APPLICATION_JSON }) @ApiResponse(responseCode = "400", description = "If the page number is out of bounds") public AnnotationPage getCommentPageForRecord(@PathParam("page") Integer page) throws DAOException, IllegalRequestExcept...
@Test public void testGetCommentPageForRecord() throws JsonMappingException, JsonProcessingException { try(Response response = target(urls.path(RECORDS_RECORD, RECORDS_COMMENTS).params(PI_ANNOTATIONS).build() + "1/") .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, ...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_METADATA_SOURCE) @Produces({ MediaType.TEXT_XML }) @Operation(tags = { "records" }, summary = "Get record metadata source file") public StreamingOutput getSource() throws ContentNotFoundException, PresentationException, IndexUnreachableException { StructElement se = getSt...
@Test public void testGetSource() { try(Response response = target(urls.path(RECORDS_RECORD, RECORDS_METADATA_SOURCE).params(PI).build()) .request() .accept(MediaType.TEXT_XML) .get()) { assertEquals("Should return status 404", 404, response.getStatus()); assertNotNull("Should return user object as json", response.getE...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_MANIFEST) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "records", "iiif" }, summary = "Get IIIF manifest for record") @IIIFPresentationBinding public IPresentationModelElement getManifest( @Parameter( description = "Build mode for manifest to select type ...
@Test public void testGetManifest() throws JsonMappingException, JsonProcessingException { String url = urls.path(RECORDS_RECORD, RECORDS_MANIFEST).params(PI).build(); try(Response response = target(url) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, response.getS...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_LAYER) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "records", "iiif" }, summary = "Get a layer within a IIIF manifest") @IIIFPresentationBinding public IPresentationModelElement getLayer( @Parameter(description = "Name of the manifest layer") @PathParam(...
@Test public void testGetLayer() throws JsonMappingException, JsonProcessingException { String url = urls.path(RECORDS_RECORD, RECORDS_LAYER).params(PI, "ALTO").build(); try(Response response = target(url) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, response.ge...
RecordResource { @GET @javax.ws.rs.Path(RECORDS_NER_TAGS) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "records" }, summary = "Get NER tags for a record") public DocumentReference getNERTags( @Parameter(description = "First page to get tags for") @QueryParam("start") Integer start, @Parameter(descripti...
@Test public void testGetNERTags() throws JsonMappingException, JsonProcessingException { String url = urls.path(RECORDS_RECORD, RECORDS_NER_TAGS).params(PI_NER).build(); try(Response response = target(url) .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200, response.g...
CollectionsResource { @GET @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "iiif" }, summary = "Get all collections as IIIF presentation collection") @ApiResponse(responseCode="400", description="No collections available for field") public Collection getAllCollections( @Parameter(description ="Add values ...
@Test public void testGetAllCollections() throws JsonMappingException, JsonProcessingException { String url = urls.path(COLLECTIONS).params(SOLR_FIELD).build(); try(Response response = target(url) .request() .accept(MediaType.APPLICATION_JSON) .get()) { String entity = response.readEntity(String.class); assertEquals("S...
CMSPage implements Comparable<CMSPage>, Harvestable { public String getTileGridUrl(String itemId) throws IllegalRequestException { CMSContentItem item; try { item = getContentItem(itemId); } catch (CmsElementNotFoundException e) { item = null; } if (item != null && item.getType().equals(CMSContentItemType.TILEGRID)) { ...
@Test public void testGetTileGridUrl() { String allowedTags = "a$b$cde"; List<CMSCategory> categories = new ArrayList<>(); for (String catName : allowedTags.split("\\$")) { categories.add(new CMSCategory(catName)); } boolean preferImportant = true; int numTiles = 12; CMSPage page = new CMSPage(); CMSPageLanguageVersion...
CollectionsResource { @GET @javax.ws.rs.Path(COLLECTIONS_COLLECTION) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "iiif" }, summary = "Get given collection as a IIIF presentation collection") @ApiResponse(responseCode="400", description="Invalid collection name or field") public Collection getCollectio...
@Test public void testGetCollection() { String url = urls.path(COLLECTIONS, COLLECTIONS_COLLECTION).params(SOLR_FIELD, COLLECTION).build(); try(Response response = target(url) .request() .accept(MediaType.APPLICATION_JSON) .get()) { String entity = response.readEntity(String.class); assertEquals("Should return status 2...
TranslationResource { @GET @Path(ApiUrls.LOCALIZATION_TRANSLATIONS) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags= {"localization"}, summary = "Get translations for message keys", description = "Pass a list of message keys to get translations for all configured languages") @ApiResponse(responseCode = "200",...
@Test public void testGetTranslations() throws JsonMappingException, JsonProcessingException { try(Response response = target(urls.path(LOCALIZATION, LOCALIZATION_TRANSLATIONS).build()) .queryParam("keys", "cancel,ok") .request() .accept(MediaType.APPLICATION_JSON) .get()) { assertEquals("Should return status 200", 200...
ApplicationResource { @GET @Produces(MediaType.APPLICATION_JSON) public ApiInfo getApiInfo() { ApiInfo info = new ApiInfo(); info.name = "Goobi viewer REST API"; info.version = "v1"; info.specification = urls.getApiUrl() + "/openapi.json"; return info; } @GET @Produces(MediaType.APPLICATION_JSON) ApiInfo getApiInfo();...
@Test public void testGetApiInfo() { try(Response response = target(urls.path().build()) .request() .accept(MediaType.APPLICATION_JSON) .get()) { ApiInfo info = response.readEntity(ApiInfo.class); assertNotNull(info); assertEquals("v1", info.version); } }
RssResource { static String createQuery(String query, Long bookshelfId, String partnerId, HttpServletRequest servletRequest, boolean addSuffixes) throws IndexUnreachableException, PresentationException, DAOException { if (StringUtils.isEmpty(query)) { if (bookshelfId != null) { BookmarkList bookshelf = DataManager.getI...
@Test public void createQuery_shouldAugmentGivenQueryCorrectly() throws Exception { Assert.assertEquals("(PI:*)", RssResource.createQuery("PI:*", null, null, null, false)); } @Test public void createQuery_shouldCreateBasicQueryCorrectly() throws Exception { Assert.assertEquals("(ISWORK:true)", RssResource.createQuery(n...
CampaignItemResource { @GET @Path("/{campaignId}/{pi}") @Produces({ MediaType.APPLICATION_JSON }) @CORSBinding public CampaignItem getItemForManifest(@PathParam("campaignId") Long campaignId, @PathParam("pi") String pi) throws URISyntaxException, DAOException, ContentNotFoundException { URI manifestURI = new ManifestBu...
@Test public void testGetItemForManifest() throws ContentNotFoundException, URISyntaxException, DAOException { Campaign campaign = DataManager.getInstance().getDao().getCampaign(1l); CampaignItem item = resource.getItemForManifest(1l, "PPN1234"); Assert.assertNotNull(item); Assert.assertEquals(campaign, item.getCampaig...
CampaignItemResource { @PUT @Path("/{campaignId}/{pi}/") @Consumes({ MediaType.APPLICATION_JSON }) @CORSBinding public void setItemForManifest(CampaignItem item, @PathParam("campaignId") Long campaignId, @PathParam("pi") String pi) throws DAOException { CampaignRecordStatus status = item.getRecordStatus(); Campaign cam...
@Test public void testSetItemForManifest() throws ContentNotFoundException, URISyntaxException, DAOException { String pi = "PPN1234"; CampaignItem item = resource.getItemForManifest(1l, pi); User user = DataManager.getInstance().getDao().getUser(1l); item.setCreatorURI(user.getIdAsURI()); item.setRecordStatus(CampaignR...
CampaignItemResource { @GET @Path("/{campaignId}/{pi}/annotations") @Produces({ MediaType.APPLICATION_JSON }) @CORSBinding public List<WebAnnotation> getAnnotationsForManifest(@PathParam("campaignId") Long campaignId, @PathParam("pi") String pi) throws URISyntaxException, DAOException { Campaign campaign = DataManager....
@Test public void testGetAnnotationsForManifest() throws URISyntaxException, DAOException { String pi = "PI_1"; List<WebAnnotation> annotationList = resource.getAnnotationsForManifest(1l, pi); Assert.assertEquals(2, annotationList.size()); }
CampaignItemResource { @PUT @Path("/{campaignId}/{pi}/annotations") @Consumes({ MediaType.APPLICATION_JSON }) @CORSBinding public void setAnnotationsForManifest(List<AnnotationPage> pages, @PathParam("campaignId") Long campaignId, @PathParam("pi") String pi) throws URISyntaxException, DAOException { IDAO dao = DataMana...
@Test public void testSetAnnotationsForManifest() throws URISyntaxException, DAOException { String pi = "PI_10"; URI manifestUrl = new ManifestBuilder(urls).getManifestURI(pi); Campaign campaign = DataManager.getInstance().getDao().getCampaign(1l); String annoUrl = urls.path(ApiUrls.ANNOTATIONS, ApiUrls.ANNOTATIONS_ANN...
CMSPage implements Comparable<CMSPage>, Harvestable { public CMSPage() { } CMSPage(); CMSPage(CMSPage original); @Override int compareTo(CMSPage o); boolean saveSidebarElements(); void resetItemData(); List<CMSSidebarElement> getUnusedSidebarElements(); void addSidebarElement(CMSSidebarElement element); Long getId(); ...
@Test public void testCMSPage() throws DAOException, IOException, ServletException, URISyntaxException { CMSPage page = new CMSPage(); String templateId = "template"; page.setTemplateId(templateId); CMSPageLanguageVersion german = new CMSPageLanguageVersion(); german.setLanguage("de"); german.setStatus(CMSPageStatus.FI...
CMSContentResource { @GET @Path("/content/{pageId}/{language}/{contentId}") @Produces({ MediaType.TEXT_HTML }) public String getContentHtml(@PathParam("pageId") Long pageId, @PathParam("language") String language, @PathParam("contentId") String contentId) throws IOException, DAOException, ServletException { if (servlet...
@Test public void testGetContentHtml() throws IOException, DAOException, ServletException { String output = resource.getContentHtml(1l, "de", "C1"); String expectedOutput = "&lt;b&gt;Hello CMS&lt;/b&gt;"; Assert.assertEquals(resource.wrap(expectedOutput, true), output); }
CMSContentResource { @GET @Path("/sidebar/{elementId}") @Produces({ MediaType.TEXT_PLAIN }) public String getSidebarElementHtml(@PathParam("elementId") Long elementId) throws IOException, DAOException, ServletException { String output = createResponseInThread(TargetType.SIDEBAR, elementId, null, null, REQUEST_TIMEOUT);...
@Test public void testGetSidebarElementHtml() throws IOException, DAOException, ServletException { String output = resource.getSidebarElementHtml(1l); String expectedOutput = "&lt;h1&gt;Hello Sidebar&lt;/h1&gt;"; Assert.assertEquals(resource.wrap(expectedOutput, true), output); }
CMSContentResource { public static String getContentUrl(CMSContentItem item) { if (item != null) { StringBuilder urlBuilder = new StringBuilder(BeanUtils.getServletPathWithHostAsUrlFromJsfContext()); urlBuilder.append("/rest/cms/"); urlBuilder.append(TargetType.CONTENT.name().toLowerCase()); urlBuilder.append("/"); url...
@Test public void testGetContentUrl() throws DAOException, CmsElementNotFoundException { CMSPage page = DataManager.getInstance().getDao().getCMSPage(1l); CMSContentItem item = page.getContentItem("C1", "de"); String url = CMSContentResource.getContentUrl(item); url = url.substring(0, url.indexOf("?")); Assert.assertEq...
CMSContentResource { public static String getSidebarElementUrl(CMSSidebarElement item) { if (item != null && item.hasHtml()) { StringBuilder urlBuilder = new StringBuilder(BeanUtils.getServletPathWithHostAsUrlFromJsfContext()); urlBuilder.append("/rest/cms/"); urlBuilder.append(TargetType.SIDEBAR.name().toLowerCase());...
@Test public void testGetSidebarElementUrl() throws DAOException { CMSSidebarElement element = DataManager.getInstance().getDao().getCMSSidebarElement(1); String url = CMSContentResource.getSidebarElementUrl(element); url = url.substring(0, url.indexOf("?")); Assert.assertEquals("/rest/cms/sidebar/1/", url); }
ManifestResource extends AbstractResource { @GET @Path("/{pi}/manifest") @Produces({ MediaType.APPLICATION_JSON }) public IPresentationModelElement getManifest(@PathParam("pi") String pi) throws PresentationException, IndexUnreachableException, URISyntaxException, ViewerConfigurationException, DAOException, ContentNotF...
@Test public void testGetManifest() throws ViewerConfigurationException, ContentNotFoundException, PresentationException, IndexUnreachableException, URISyntaxException, DAOException { IPresentationModelElement manifest = resource.getManifest(PP_NUAG_FOTO_V4); Assert.assertTrue(manifest instanceof Manifest); }
ManifestResource extends AbstractResource { @GET @Path("/{pi}/range/{logId}") @Produces({ MediaType.APPLICATION_JSON }) public Range getRange(@PathParam("pi") String pi, @PathParam("logId") String logId) throws PresentationException, IndexUnreachableException, URISyntaxException, ViewerConfigurationException, DAOExcept...
@Test public void testGetRange() throws ViewerConfigurationException, ContentNotFoundException, PresentationException, IndexUnreachableException, URISyntaxException, DAOException { Range range = resource.getRange(PP_NUAG_FOTO_V4, "LOG_0000"); Assert.assertTrue(range instanceof Range); }
ManifestResource extends AbstractResource { @GET @Path("/{pi}/canvas/{physPageNo}") @Produces({ MediaType.APPLICATION_JSON }) public Canvas getCanvas(@PathParam("pi") String pi, @PathParam("physPageNo") int physPageNo) throws PresentationException, IndexUnreachableException, URISyntaxException, ViewerConfigurationExcep...
@Test public void testGetCanvas() throws ViewerConfigurationException, ContentNotFoundException, PresentationException, IndexUnreachableException, URISyntaxException, DAOException { Canvas canvas = resource.getCanvas(PP_NUAG_FOTO_V4, 1); Assert.assertTrue(canvas instanceof Canvas); }
ManifestResource extends AbstractResource { @GET @Path("/{pi}/list/{physPageNo}/{type}") @Produces({ MediaType.APPLICATION_JSON }) public AnnotationList getOtherContent(@PathParam("pi") String pi, @PathParam("physPageNo") int physPageNo, @PathParam("type") String typeName) throws PresentationException, IndexUnreachable...
@Test public void testGetOtherContent() throws ViewerConfigurationException, ContentNotFoundException, IllegalRequestException, PresentationException, IndexUnreachableException, URISyntaxException, DAOException { try { AnnotationList annoList = resource.getOtherContent(PP_NUAG_FOTO_V4, 1, AnnotationType.FULLTEXT.name()...
ManifestResource extends AbstractResource { @GET @Path("/{pi}/layer/{type}") @Produces({ MediaType.APPLICATION_JSON }) public Layer getLayer(@PathParam("pi") String pi, @PathParam("type") String typeName) throws PresentationException, IndexUnreachableException, URISyntaxException, ViewerConfigurationException, DAOExcep...
@Test public void testGetLayer() throws ViewerConfigurationException, ContentNotFoundException, IllegalRequestException, PresentationException, IndexUnreachableException, URISyntaxException, DAOException, IOException { Layer layer = resource.getLayer(PP_NUAG_FOTO_V4, AnnotationType.FULLTEXT.name()); Assert.assertTrue(l...
SessionResource { @GET @Path("/info") @Produces({ MediaType.TEXT_PLAIN }) @CORSBinding public String getSessionInfo() { if (servletRequest == null) { return "Servlet request not found"; } StringBuilder sb = new StringBuilder(); Map<String, String> sessionMap = DataManager.getInstance().getSessionMap().get(servletReques...
@Test public void getSessionInfo_shouldReturnSessionInfoCorrectly() throws Exception { Map<String, String> sessionMd = new HashMap<>(); sessionMd.put("foo", "bar"); DataManager.getInstance().getSessionMap().put(TEST_SESSION_ID, sessionMd); String ret = resource.getSessionInfo(); Assert.assertTrue(ret, resource.getSessi...
CMSPage implements Comparable<CMSPage>, Harvestable { static List<File> exportItemFiles(CMSContentItem item, String outputFolderPath, String namingScheme, long cmsPageId) throws IOException { if (item.getType() == null) { return Collections.emptyList(); } switch (item.getType()) { case MEDIA: return Collections.singlet...
@Test public void exportItemFiles_shouldReturnMediaFilesDirectly() throws Exception { CMSMediaItem mediaItem = new CMSMediaItem(); mediaItem.setFileName("example.pdf"); CMSContentItem item = new CMSContentItem(CMSContentItemType.MEDIA); item.setMediaItem(mediaItem); List<File> result = CMSPage.exportItemFiles(item, "",...
NormdataResource { static JSONObject addNormDataValuesToJSON(NormData normData, Locale locale) { JSONObject jsonObj = new JSONObject(); String translation = ViewerResourceBundle.getTranslation(normData.getKey(), locale); String translatedKey = StringUtils.isNotEmpty(translation) ? translation : normData.getKey(); for (...
@Test public void addNormDataValuesToJSON_shouldAddValuesCorrectly() throws Exception { NormData normData = new NormData(); normData.setKey("NORM_FOO"); normData.getValues().add(new NormDataValue("bar", null, null)); JSONObject jsonObj =NormdataResource.addNormDataValuesToJSON(normData, null); Assert.assertNotNull(json...
ContentResource { @GET @Path("/alto/{pi}") @Produces({ "application/zip" }) public StreamingOutput getAltoDocument(@PathParam("pi") String pi) throws PresentationException, ContentLibException, IndexUnreachableException, DAOException, MalformedURLException { setResponseHeader(pi + ".zip"); checkAccess(pi, IPrivilegeHol...
@Test public void getAltoDocument_shouldReturnDocumentCorrectly() throws Exception { Assert.assertNotNull(resource.getAltoDocument(PI, "00000001.xml")); } @Test public void getAltoDocumentZip() throws Exception { StreamingOutput response = resource.getAltoDocument(PI); Path tempFile = Paths.get("test.zip"); if (Files.e...
ContentResource { @GET @Path("/document/{contentFolder}/{pi}/{fileName}") @Produces({ MediaType.TEXT_XML, MediaType.TEXT_PLAIN, MediaType.TEXT_HTML }) public String getContentDocument(@PathParam("contentFolder") String contentFolder, @PathParam("pi") String pi, @PathParam("fileName") String fileName) throws Presentatio...
@Test public void getContentDocument_shouldReturnDocumentCorrectly() throws Exception { Assert.assertNotNull(resource.getContentDocument(null, "fulltext", PI, "00000001.txt")); } @Test(expected = ServiceNotAllowedException.class) public void getContentDocument_shouldThrowContentNotFoundExceptionIfFileNotFound() throws ...
ContentResource { @GET @Path("/fulltext/{pi}") @Produces({ "application/zip" }) public StreamingOutput getFulltextDocument(@PathParam("pi") String pi) throws PresentationException, ContentLibException, IndexUnreachableException, DAOException, IOException { setResponseHeader(pi + ".zip"); checkAccess(pi, IPrivilegeHolde...
@Test(expected = ServiceNotAllowedException.class) public void getFulltextDocument_shouldThrowContentNotFoundExceptionIfFileNotFound() throws Exception { resource.getFulltextDocument("notfound", "00000001.txt"); }
ContentResource { @GET @Path("/tei/{pi}/{lang}") @Produces({ MediaType.APPLICATION_XML }) public String getTeiDocument(@PathParam("pi") String pi, @PathParam("lang") String langCode) throws PresentationException, IndexUnreachableException, DAOException, IOException, ContentLibException { setResponseHeader(""); checkAcc...
@Test public void getTeiDocument_shouldReturnDocumentCorrectly() throws Exception { String tei = resource.getTeiDocument("DE_2013_Riedel_PolitikUndCo_241__248", "de"); Assert.assertNotNull(tei); Assert.assertTrue(tei.contains("Religionen und Sinndeutungssysteme")); } @Test(expected = ContentNotFoundException.class) pub...
ContentResource { public List<java.nio.file.Path> getFiles(String pi, String foldername, String altFoldername, String filter) throws IOException, PresentationException, IndexUnreachableException { java.nio.file.Path folder1 = DataFileTools.getDataFilePath(pi, foldername, null, null); java.nio.file.Path folder2 = DataFi...
@Test public void testGetFiles() throws IOException { Path tempPath = Paths.get("test", "data", "temp"); try { Path folder1 = tempPath.resolve("folder1"); Path folder2 = tempPath.resolve("folder2"); Files.createDirectories(folder1); Files.createDirectories(folder2); createFile(folder1, "A"); createFile(folder1, "B"); c...
CMSPageTemplate implements Serializable { public static CMSPageTemplate loadFromXML(Path file) { if (file == null) { throw new IllegalArgumentException("file may not be null"); } Document doc; try { doc = XmlTools.readXmlFile(file); } catch (IOException | JDOMException e1) { logger.error(e1.toString(), e1); return null...
@Test(expected = IllegalArgumentException.class) public void loadFromXML_shouldThrowIllegalArgumentExceptionIfFileIsNull() throws Exception { CMSPageTemplate.loadFromXML(null); }
SearchHitsNotificationResource { public List<SearchHit> getNewHits(Search search) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException { Search tempSearch = new Search(search); SearchFacets facets = new SearchFacets(); facets.setCurrentFacetString(tempSearch.getFacetString...
@Test public void testcheckSearchUpdate() throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException { SearchHitsNotificationResource resource = new SearchHitsNotificationResource(); Search search = new Search(); search.setQuery("ISWORK:*"); search.setLastHitsCount(200); search....
IdentifierResolver extends HttpServlet { static String constructUrl(SolrDocument targetDoc, boolean pageResolverUrl) { int order = 1; if (targetDoc.containsKey(SolrConstants.THUMBPAGENO)) { order = (int) targetDoc.getFieldValue(SolrConstants.THUMBPAGENO); } else if (targetDoc.containsKey(SolrConstants.ORDER)) { order =...
@Test public void constructUrl_shouldConstructUrlCorrectly() throws Exception { String pi = PI_KLEIUNIV; QueryResponse qr = DataManager.getInstance().getSearchIndex().search(SolrConstants.PI + ":" + pi, 0, 1, null, null, null); Assert.assertEquals(1, qr.getResults().size()); Assert.assertEquals("/object/" + pi + "/1/LO...
IdentifierResolver extends HttpServlet { static void parseFieldValueParameters(Map<String, String[]> parameterMap, Map<Integer, String> moreFields, Map<Integer, String> moreValues) { if (parameterMap == null || parameterMap.isEmpty()) { return; } for (String key : parameterMap.keySet()) { if (parameterMap.get(key) == n...
@Test public void parseFieldValueParameters_shouldParseFieldsAndValuesCorrectly() throws Exception { Map<Integer, String> moreFields = new HashMap<>(); Map<Integer, String> moreValues = new HashMap<>(); Map<String, String[]> parameterMap = new HashMap<>(6); parameterMap.put("field2", new String[] { "FIELD2" }); paramet...
JPAClassLoader extends ClassLoader { static Document scanPersistenceXML(URL masterFileUrl, List<URL> moduleUrls) throws IOException, JDOMException { logger.trace("scanPersistenceXML(): {}", masterFileUrl); Document docMerged = new Document(); Document docMaster = XmlTools.readXmlFile(masterFileUrl); Element eleMasterRo...
@Test public void scanPersistenceXML_shouldMergePersistenceXmlFilesCorrectly() throws Exception { File masterFile = new File("src/main/resources/META-INF/persistence.xml"); Assert.assertTrue(masterFile.isFile()); URL masterUrl = new URL("file: File file = new File("src/test/resources/modules/persistence.xml"); Assert.a...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<User> getAllUsers(boolean refresh) throws DAOException { preQuery(); Query q = em.createQuery("SELECT u FROM User u"); if (refresh) { q.setHint("javax.persistence.cache.storeMode", "REFRESH"); } return q.getResultList(); } JPADAO(); JPADAO(S...
@Test public void getAllUsersTest() throws DAOException { List<User> users = DataManager.getInstance().getDao().getAllUsers(false); Assert.assertEquals(3, users.size()); }
ManifestBuilder extends AbstractBuilder { public IPresentationModelElement generateManifest(StructElement ele) throws URISyntaxException, PresentationException, IndexUnreachableException, ViewerConfigurationException, DAOException { final AbstractPresentationModelElement manifest; if (ele.isAnchor()) { manifest = new C...
@Test public void test() throws PresentationException, IndexUnreachableException, ViewerConfigurationException, DAOException, URISyntaxException, ContentNotFoundException, IOException { DataManager.getInstance().injectConfiguration(new Configuration("src/test/resources/config_viewer.test.xml")); ManifestBuilder builder...
JPADAO implements IDAO { @Override public User getUser(long id) throws DAOException { preQuery(); try { User o = em.getReference(User.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFa...
@Test public void getUserByIdTest() throws DAOException { User user = DataManager.getInstance().getDao().getUser(1); Assert.assertNotNull(user); Assert.assertEquals(2, user.getOpenIdAccounts().size()); }
JPADAO implements IDAO { @Override public User getUserByEmail(String email) throws DAOException { preQuery(); Query q = em.createQuery("SELECT u FROM User u WHERE UPPER(u.email) = :email"); if (email != null) { q.setParameter("email", email.toUpperCase()); } try { User o = (User) q.getSingleResult(); if (o != null) { e...
@Test public void getUserByEmailTest() throws DAOException { User user = DataManager.getInstance().getDao().getUserByEmail("1@UsErS.oRg"); Assert.assertNotNull(user); }
JPADAO implements IDAO { @Override public User getUserByOpenId(String identifier) throws DAOException { preQuery(); Query q = em.createQuery("SELECT u FROM User u WHERE :claimed_identifier MEMBER OF u.openIdAccounts"); q.setParameter("claimed_identifier", identifier); q.setHint("javax.persistence.cache.storeMode", "REF...
@Test public void getUserByOpenIdTest() throws DAOException { User user = DataManager.getInstance().getDao().getUserByOpenId("user_1_claimed_identifier_2"); Assert.assertNotNull(user); }
JPADAO implements IDAO { @Override public User getUserByNickname(String nickname) throws DAOException { if (StringUtils.isBlank(nickname)) { return null; } preQuery(); Query q = em.createQuery("SELECT u FROM User u WHERE UPPER(u.nickName) = :nickname"); q.setParameter("nickname", nickname.trim().toUpperCase()); q.setHi...
@Test public void getUserByNicknameTest() throws DAOException { User user = DataManager.getInstance().getDao().getUserByNickname("admin"); Assert.assertNotNull(user); } @Test public void getUserByNickname_shouldReturnNullIfNicknameEmpty() throws Exception { Assert.assertNull(DataManager.getInstance().getDao().getUserBy...
JPADAO implements IDAO { @Override public boolean addUser(User user) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(user); em.getTransaction().commit(); return true; } finally { em.close(); } } JPADAO(); JPADAO(String inPersistenceUnitN...
@Test public void addUserTest() throws DAOException { User user = new User(); user.setEmail("a@b.com"); user.setPasswordHash("EEEEEE"); user.setPasswordHash("FFFFFF"); user.setFirstName("first"); user.setLastName("last"); user.setNickName("banned_admin"); user.setComments("no"); user.setUseGravatar(true); Date now = ne...
JPADAO implements IDAO { @Override public boolean updateUser(User user) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(user); em.getTransaction().commit(); if (this.em.contains(user)) { this.em.refresh(user); } return true; } finally { em....
@Test public void updateUserTest() throws DAOException { Assert.assertEquals(3, DataManager.getInstance().getDao().getAllUsers(false).size()); User user = DataManager.getInstance().getDao().getUser(1); Assert.assertNotNull(user); user.setEmail("b@b.com"); user.setPasswordHash("EFEFEF"); user.setFirstName("first"); user...
JPADAO implements IDAO { @Override public boolean deleteUser(User user) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); User u = em.getReference(User.class, user.getId()); em.remove(u); em.getTransaction().commit(); return true; } finally { em.close...
@Test public void deleteUserTest() throws DAOException { User user = new User(); user.setEmail("deleteme@b.com"); user.setPasswordHash("DDDDDD"); user.setFirstName("first"); user.setLastName("last"); user.setNickName("banned_admin"); user.setComments("no"); user.setActive(false); user.setSuperuser(true); DataManager.ge...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<UserGroup> getAllUserGroups() throws DAOException { preQuery(); Query q = em.createQuery("SELECT ug FROM UserGroup ug"); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); EntityMan...
@Test public void getAllUserGroupsTest() throws DAOException { List<UserGroup> userGroups = DataManager.getInstance().getDao().getAllUserGroups(); Assert.assertEquals(2, userGroups.size()); }
JPADAO implements IDAO { @Override public UserGroup getUserGroup(long id) throws DAOException { preQuery(); try { UserGroup o = em.getReference(UserGroup.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitName); Entity...
@Test public void getUserGroupByIdTest() throws DAOException { UserGroup ug = DataManager.getInstance().getDao().getUserGroup(1); Assert.assertNotNull(ug); Assert.assertNotNull(ug.getOwner()); Assert.assertEquals(Long.valueOf(1), ug.getOwner().getId()); Assert.assertEquals("user group 1 name", ug.getName()); Assert.ass...
SequenceBuilder extends AbstractBuilder { public Map<AnnotationType, AnnotationList> addOtherContent(StructElement doc, PhysicalElement page, Canvas canvas, boolean populate) throws URISyntaxException, IndexUnreachableException, ViewerConfigurationException { Map<AnnotationType, AnnotationList> annotationMap = new Hash...
@Test public void testAddOtherContent() throws PresentationException, IndexUnreachableException, URISyntaxException, ViewerConfigurationException, DAOException, ContentNotFoundException, IOException { DataManager.getInstance().injectConfiguration(new Configuration("src/test/resources/config_viewer.test.xml")); Manifest...
GeoMapMarker { public String toJSONString() throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(this); } GeoMapMarker(String name); GeoMapMarker(); String getIcon(); void setIcon(String icon); String getMarkerColor(); void setMarkerColor(String markerColor); Stri...
@Test public void testToJSONString() throws JsonProcessingException { String s = testObject.toJSONString(); Assert.assertEquals(testString, s); }
JPADAO implements IDAO { @Override public boolean addUserGroup(UserGroup userGroup) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(userGroup); em.getTransaction().commit(); } finally { em.close(); } return true; } JPADAO(); JPADAO(Strin...
@Test public void addUserGroupTest() throws DAOException { User owner = DataManager.getInstance().getDao().getUser(1); Assert.assertNotNull(owner); UserGroup userGroup = new UserGroup(); userGroup.setOwner(owner); userGroup.setName("added user group name"); userGroup.setDescription("added user group desc"); userGroup.s...
JPADAO implements IDAO { @Override public boolean updateUserGroup(UserGroup userGroup) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(userGroup); em.getTransaction().commit(); if (this.em.contains(userGroup)) { this.em.refresh(userGroup); ...
@Test public void updateUserGroupTest() throws DAOException { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllUserGroups().size()); UserGroup userGroup = DataManager.getInstance().getDao().getUserGroup(1); Assert.assertNotNull(userGroup); Assert.assertEquals("user group 1 name", userGroup.getName()); us...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<UserRole> getAllUserRoles() throws DAOException { preQuery(); Query q = em.createQuery("SELECT ur FROM UserRole ur"); q.setFlushMode(FlushModeType.COMMIT); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityMan...
@Test public void getAllUserRolesTest() throws DAOException { List<UserRole> userRoles = DataManager.getInstance().getDao().getAllUserRoles(); Assert.assertEquals(1, userRoles.size()); }
JPADAO implements IDAO { @Override public boolean addUserRole(UserRole userRole) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(userRole); em.getTransaction().commit(); } finally { em.close(); } return true; } JPADAO(); JPADAO(String in...
@Test public void addUserRoleTest() throws DAOException { User user = DataManager.getInstance().getDao().getUser(2); Assert.assertNotNull(user); UserGroup userGroup = DataManager.getInstance().getDao().getUserGroup(2); Assert.assertNotNull(userGroup); Role role = DataManager.getInstance().getDao().getRole(2); Assert.as...
JPADAO implements IDAO { @Override public boolean updateUserRole(UserRole userRole) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(userRole); em.getTransaction().commit(); return true; } finally { em.close(); } } JPADAO(); JPADAO(String i...
@Test public void updateUserRoleTest() throws DAOException { Assert.assertEquals(1, DataManager.getInstance().getDao().getAllUserRoles().size()); UserRole userRole = DataManager.getInstance().getDao().getAllUserRoles().get(0); Assert.assertNotNull(userRole); Role role1 = DataManager.getInstance().getDao().getRole(1); A...
JPADAO implements IDAO { @Override public boolean deleteUserRole(UserRole userRole) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); UserRole o = em.getReference(UserRole.class, userRole.getId()); em.remove(o); em.getTransaction().commit(); return tr...
@Test public void deleteUserRoleTest() throws DAOException { Assert.assertEquals(1, DataManager.getInstance().getDao().getAllUserRoles().size()); UserRole userRole = DataManager.getInstance().getDao().getAllUserRoles().get(0); Assert.assertTrue(DataManager.getInstance().getDao().deleteUserRole(userRole)); Assert.assert...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<IpRange> getAllIpRanges() throws DAOException { preQuery(); Query q = em.createQuery("SELECT ipr FROM IpRange ipr"); q.setFlushMode(FlushModeType.COMMIT); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityMana...
@Test public void getAllIpRangesTest() throws DAOException { List<IpRange> ipRanges = DataManager.getInstance().getDao().getAllIpRanges(); Assert.assertEquals(2, ipRanges.size()); }
JPADAO implements IDAO { @Override public IpRange getIpRange(long id) throws DAOException { preQuery(); try { IpRange o = em.find(IpRange.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory g...
@Test public void getIpRangeByIdTest() throws DAOException { IpRange ipRange = DataManager.getInstance().getDao().getIpRange(1); Assert.assertNotNull(ipRange); Assert.assertEquals(Long.valueOf(1), ipRange.getId()); Assert.assertEquals("localhost", ipRange.getName()); Assert.assertEquals("1.2.3.4/24", ipRange.getSubnetM...
JPADAO implements IDAO { @Override public boolean addIpRange(IpRange ipRange) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(ipRange); em.getTransaction().commit(); } finally { em.close(); } return true; } JPADAO(); JPADAO(String inPers...
@Test public void addIpRangeTest() throws DAOException { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllIpRanges().size()); IpRange ipRange = new IpRange(); ipRange.setName("ip range to add name"); ipRange.setDescription("ip range to add desc"); ipRange.setSubnetMask("0.0.0.0./0"); Assert.assertTrue(Da...
AbstractBuilder { protected Map<String, List<String>> getEventFields() { List<String> eventStrings = DataManager.getInstance().getConfiguration().getIIIFEventFields(); Map<String, List<String>> events = new HashMap<>(); for (String string : eventStrings) { String event, field; int separatorIndex = string.indexOf("/"); ...
@Test public void testGetEventFields() { Map<String, List<String>> events = builder.getEventFields(); Assert.assertNotNull(events); Assert.assertEquals(3, events.size()); Assert.assertEquals(2, events.get("").size()); Assert.assertEquals(2, events.get("Provenienz").size()); Assert.assertEquals(1, events.get("Expression...
JPADAO implements IDAO { @Override public boolean updateIpRange(IpRange ipRange) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(ipRange); em.getTransaction().commit(); if (this.em.contains(ipRange)) { this.em.refresh(ipRange); } return tru...
@Test public void updateIpRangeTest() throws DAOException { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllIpRanges().size()); IpRange ipRange = DataManager.getInstance().getDao().getIpRange(1); Assert.assertNotNull(ipRange); ipRange.setName("ip range 1 new name"); ipRange.setDescription("ip range 1 ne...
JPADAO implements IDAO { @Override public boolean deleteIpRange(IpRange ipRange) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); IpRange o = em.getReference(IpRange.class, ipRange.getId()); em.remove(o); em.getTransaction().commit(); return true; } ...
@Test public void deleteIpRangeTest() throws DAOException { Assert.assertEquals(2, DataManager.getInstance().getDao().getAllIpRanges().size()); IpRange ipRange = DataManager.getInstance().getDao().getIpRange(1); Assert.assertNotNull(ipRange); Assert.assertTrue(DataManager.getInstance().getDao().deleteIpRange(ipRange));...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Comment> getAllComments() throws DAOException { preQuery(); Query q = em.createQuery("SELECT o FROM Comment o"); q.setFlushMode(FlushModeType.COMMIT); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerF...
@Test public void getAllCommentsTest() throws DAOException { List<Comment> comments = DataManager.getInstance().getDao().getAllComments(); Assert.assertEquals(4, comments.size()); }
JPADAO implements IDAO { @Override public long getCommentCount(Map<String, String> filters) throws DAOException { return getRowCount("Comment", null, filters); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFactory(); EntityManager getEntityManager(); @Override void startTransaction(); @Over...
@Test public void getCommentCount_shouldReturnCorrectCount() throws Exception { Assert.assertEquals(4L, DataManager.getInstance().getDao().getCommentCount(null)); } @Test public void getCommentCount_shouldFilterCorrectly() throws Exception { Map<String, String> filters = new HashMap<>(); filters.put("page", "1"); Asser...
JPADAO implements IDAO { @Override public Comment getComment(long id) throws DAOException { preQuery(); try { Comment o = em.getReference(Comment.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerF...
@Test public void getCommentByIdTest() throws DAOException { Comment comment = DataManager.getInstance().getDao().getComment(1); Assert.assertNotNull(comment); Assert.assertEquals(Long.valueOf(1), comment.getId()); Assert.assertEquals("PI_1", comment.getPi()); Assert.assertEquals(Integer.valueOf(1), comment.getPage());...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Comment> getCommentsForPage(String pi, int page) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder(80); sbQuery.append("SELECT o FROM Comment o WHERE o.pi = :pi AND o.page = :page"); Query q = em.createQuery(sbQuery....
@Test public void getCommentsForPageTest() throws DAOException { List<Comment> comments = DataManager.getInstance().getDao().getCommentsForPage("PI_1", 1); Assert.assertEquals(3, comments.size()); }
JPADAO implements IDAO { @Override public boolean addComment(Comment comment) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(comment); em.getTransaction().commit(); } finally { em.close(); } return true; } JPADAO(); JPADAO(String inPers...
@Test public void addCommentTest() throws DAOException { Assert.assertEquals(4, DataManager.getInstance().getDao().getAllComments().size()); Comment comment = new Comment(); comment.setPi("PI_2"); comment.setPage(1); comment.setText("new comment text"); comment.setOwner(DataManager.getInstance().getDao().getUser(1)); A...
JPADAO implements IDAO { @Override public boolean updateComment(Comment comment) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(comment); em.getTransaction().commit(); return true; } finally { em.close(); } } JPADAO(); JPADAO(String inPer...
@Test public void updateCommentTest() throws DAOException { Assert.assertEquals(4, DataManager.getInstance().getDao().getAllComments().size()); Comment comment = DataManager.getInstance().getDao().getComment(1); Assert.assertNotNull(comment); comment.setText("new comment 1 text"); Date now = new Date(); comment.setDate...
JPADAO implements IDAO { @Override public boolean deleteComment(Comment comment) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); Comment o = em.getReference(Comment.class, comment.getId()); em.remove(o); em.getTransaction().commit(); return true; } ...
@Test public void deleteCommentTest() throws DAOException { Assert.assertEquals(4, DataManager.getInstance().getDao().getAllComments().size()); Comment comment = DataManager.getInstance().getDao().getComment(1); Assert.assertNotNull(comment); Assert.assertTrue(DataManager.getInstance().getDao().deleteComment(comment));...
SearchResultConverter { public SearchHit convertCommentToHit(String queryRegex, String pi, Comment comment) { SearchHit hit = new SearchHit(); String text = comment.getDisplayText(); Matcher m = Pattern.compile(AbstractSearchParser.getSingleWordRegex(queryRegex)).matcher(text); while (m.find()) { String match = m.group...
@Test public void testConvertCommentToHit() { Comment comment = new Comment(pi, pageNo, null, text, null); comment.setId(1l); String query = "in"; String queryRegex = AbstractSearchParser.getQueryRegex(query); SearchHit hit = converter.convertCommentToHit(queryRegex, pi, comment); String url = urls.path(ANNOTATIONS, AN...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<Search> getAllSearches() throws DAOException { preQuery(); Query q = em.createQuery("SELECT o FROM Search o"); q.setFlushMode(FlushModeType.COMMIT); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFac...
@Test public void getAllSearchesTest() throws DAOException { List<Search> list = DataManager.getInstance().getDao().getAllSearches(); Assert.assertEquals(3, list.size()); }
JPADAO implements IDAO { @Override public Search getSearch(long id) throws DAOException { preQuery(); try { Search o = em.find(Search.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitName); EntityManagerFactory getFa...
@Test public void getSearchByIdTest() throws DAOException { Search o = DataManager.getInstance().getDao().getSearch(1); Assert.assertNotNull(o); Assert.assertEquals(Long.valueOf(1), o.getId()); Assert.assertNotNull(o.getOwner()); Assert.assertEquals(Long.valueOf(1), o.getOwner().getId()); Assert.assertEquals("query 1",...
JPADAO implements IDAO { @Override public boolean addSearch(Search search) throws DAOException { logger.debug("addSearch: {}", search.getQuery()); preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.persist(search); em.getTransaction().commit(); } finally { em.close(); } ...
@Test public void addSearchTest() throws DAOException { Assert.assertEquals(3, DataManager.getInstance().getDao().getAllSearches().size()); Search o = new Search(SearchHelper.SEARCH_TYPE_REGULAR, SearchHelper.SEARCH_FILTER_ALL); o.setOwner(DataManager.getInstance().getDao().getUser(1)); o.setName("new search"); o.setQu...
JPADAO implements IDAO { @Override public boolean updateSearch(Search search) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); em.merge(search); em.getTransaction().commit(); return true; } finally { em.close(); } } JPADAO(); JPADAO(String inPersist...
@Test public void updateSearchTest() throws DAOException { Assert.assertEquals(3, DataManager.getInstance().getDao().getAllSearches().size()); Search o = DataManager.getInstance().getDao().getSearch(1); Assert.assertNotNull(o); o.setName("new name"); Date now = new Date(); o.setDateUpdated(now); Assert.assertTrue(DataM...
JPADAO implements IDAO { @Override public boolean deleteSearch(Search search) throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { em.getTransaction().begin(); Search o = em.getReference(Search.class, search.getId()); em.remove(o); em.getTransaction().commit(); return true; } finall...
@Test public void deleteSearchTest() throws DAOException { Assert.assertEquals(3, DataManager.getInstance().getDao().getAllSearches().size()); Search o = DataManager.getInstance().getDao().getSearch(1); Assert.assertNotNull(o); Assert.assertTrue(DataManager.getInstance().getDao().deleteSearch(o)); Assert.assertNull(Dat...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<LicenseType> getAllLicenseTypes() throws DAOException { preQuery(); Query q = em.createQuery("SELECT lt FROM LicenseType lt"); q.setFlushMode(FlushModeType.COMMIT); return q.getResultList(); } JPADAO(); JPADAO(String inPersistenceUnitName); ...
@Test public void getAllLicenseTypesTest() throws DAOException { Assert.assertEquals(NUM_LICENSE_TYPES, DataManager.getInstance().getDao().getAllLicenseTypes().size()); }
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<LicenseType> getRecordLicenseTypes() throws DAOException { preQuery(); EntityManager em = factory.createEntityManager(); try { Query q = em.createQuery("SELECT lt FROM LicenseType lt WHERE lt.core = false"); q.setFlushMode(FlushModeType.COMMI...
@Test public void getRecordTypes_shouldOnlyReturnNonOpenAccessLicenseTypes() throws Exception { List<LicenseType> licenseTypes = DataManager.getInstance().getDao().getRecordLicenseTypes(); Assert.assertEquals(5, licenseTypes.size()); Assert.assertEquals(Long.valueOf(1), licenseTypes.get(0).getId()); Assert.assertEquals...
JPADAO implements IDAO { @Override public LicenseType getLicenseType(long id) throws DAOException { preQuery(); try { LicenseType o = em.getReference(LicenseType.class, id); if (o != null) { em.refresh(o); } return o; } catch (EntityNotFoundException e) { return null; } } JPADAO(); JPADAO(String inPersistenceUnitName)...
@Test public void getLicenseTypeByIdTest() throws DAOException { { LicenseType licenseType = DataManager.getInstance().getDao().getLicenseType(1); Assert.assertNotNull(licenseType); Assert.assertEquals(Long.valueOf(1), licenseType.getId()); Assert.assertEquals("license type 1 name", licenseType.getName()); Assert.asser...
JPADAO implements IDAO { @SuppressWarnings("unchecked") @Override public List<LicenseType> getLicenseTypes(int first, int pageSize, String sortField, boolean descending, Map<String, String> filters) throws DAOException { preQuery(); StringBuilder sbQuery = new StringBuilder("SELECT o FROM LicenseType o WHERE o.core=fal...
@Test public void getLicenseTypes_shouldReturnAllMatchingRows() throws Exception { String[] names = new String[] { "license type 1 name", "license type 2 name" }; List<LicenseType> result = DataManager.getInstance().getDao().getLicenseTypes(Arrays.asList(names)); Assert.assertNotNull(result); Assert.assertEquals(2, res...