From bc3e13035f067a099b6f6e19e1c8303f278d60f6 Mon Sep 17 00:00:00 2001 From: BartChris Date: Thu, 11 Apr 2024 19:59:03 +0200 Subject: [PATCH 01/10] allow multiple values for the same key in mass import --- .../forms/massimport/MassImportForm.java | 6 +- .../services/data/ImportService.java | 18 +++--- .../services/data/MassImportService.java | 9 +-- .../services/data/ImportServiceIT.java | 60 +++++++++++++++++++ 4 files changed, 78 insertions(+), 15 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/massimport/MassImportForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/massimport/MassImportForm.java index 84955931a18..f7fc69fad95 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/massimport/MassImportForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/massimport/MassImportForm.java @@ -151,7 +151,7 @@ public void startMassImport() { importSuccessMap = new HashMap<>(); PrimeFaces.current().ajax().update("massImportResultDialog"); try { - Map> presetMetadata = massImportService.prepareMetadata(metadataKeys, records); + Map>> presetMetadata = massImportService.prepareMetadata(metadataKeys, records); importRecords(presetMetadata); PrimeFaces.current().executeScript("PF('massImportResultDialog').show();"); PrimeFaces.current().ajax().update("massImportResultDialog"); @@ -174,10 +174,10 @@ public void prepare() { * * @param processMetadata Map containing record IDs as keys and preset metadata lists as values */ - private void importRecords(Map> processMetadata) { + private void importRecords(Map>> processMetadata) { ImportService importService = ServiceManager.getImportService(); PrimeFaces.current().ajax().update("massImportProgressDialog"); - for (Map.Entry> entry : processMetadata.entrySet()) { + for (Map.Entry>> entry : processMetadata.entrySet()) { try { importService.importProcess(entry.getKey(), projectId, templateId, importConfiguration, entry.getValue()); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java index d508e206198..bcf124e82d7 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java @@ -1173,7 +1173,7 @@ public static void processTempProcess(TempProcess tempProcess, RulesetManagement * @return the importedProcess */ public Process importProcess(String ppn, int projectId, int templateId, ImportConfiguration importConfiguration, - Map presetMetadata) throws ImportException { + Map> presetMetadata) throws ImportException { LinkedList processList = new LinkedList<>(); TempProcess tempProcess; Template template; @@ -1256,14 +1256,16 @@ private static Collection getFunctionalMetadata(Ruleset ruleset, Functio return rulesetManagement.getFunctionalKeys(metadata); } - private List createMetadata(Map presetMetadata) { + private List createMetadata(Map> presetMetadata) { List metadata = new LinkedList<>(); - for (Map.Entry presetMetadataEntry : presetMetadata.entrySet()) { - MetadataEntry metadataEntry = new MetadataEntry(); - metadataEntry.setKey(presetMetadataEntry.getKey()); - metadataEntry.setValue(presetMetadataEntry.getValue()); - metadataEntry.setDomain(MdSec.DMD_SEC); - metadata.add(metadataEntry); + for (Map.Entry> presetMetadataEntry : presetMetadata.entrySet()) { + for (String presetMetadataEntryValue : presetMetadataEntry.getValue()) { + MetadataEntry metadataEntry = new MetadataEntry(); + metadataEntry.setKey(presetMetadataEntry.getKey()); + metadataEntry.setValue(presetMetadataEntryValue); + metadataEntry.setDomain(MdSec.DMD_SEC); + metadata.add(metadataEntry); + } } return metadata; } diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/MassImportService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/MassImportService.java index 522fed00b9c..fc0c3fd6d0f 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/MassImportService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/MassImportService.java @@ -114,16 +114,17 @@ public List parseLines(List lines, String separator) { * @param metadataKeys metadata keys for additional metadata added to individual records during import * @param records list of CSV records */ - public Map> prepareMetadata(List metadataKeys, List records) + public Map>> prepareMetadata(List metadataKeys, List records) throws ImportException { - Map> presetMetadata = new LinkedHashMap<>(); + Map>> presetMetadata = new LinkedHashMap<>(); for (CsvRecord record : records) { - Map processMetadata = new HashMap<>(); + Map> processMetadata = new HashMap<>(); // skip first metadata key as it always contains the record ID to be used for search for (int index = 1; index < metadataKeys.size(); index++) { String metadataKey = metadataKeys.get(index); if (StringUtils.isNotBlank(metadataKey)) { - processMetadata.put(metadataKey, record.getCsvCells().get(index).getValue()); + List values = processMetadata.computeIfAbsent(metadataKey, k -> new ArrayList<>()); + values.add(record.getCsvCells().get(index).getValue()); } } presetMetadata.put(record.getCsvCells().get(0).getValue(), processMetadata); diff --git a/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java index 85c2f7f241b..809858d073d 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java @@ -29,6 +29,9 @@ import java.nio.file.Paths; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.SystemUtils; @@ -39,6 +42,9 @@ import org.kitodo.ExecutionPermission; import org.kitodo.MockDatabase; import org.kitodo.SecurityTestUtils; +import org.kitodo.api.Metadata; +import org.kitodo.api.MetadataEntry; +import org.kitodo.api.dataformat.Workpiece; import org.kitodo.config.ConfigCore; import org.kitodo.config.enums.ParameterCore; import org.kitodo.data.database.beans.ImportConfiguration; @@ -46,6 +52,7 @@ import org.kitodo.data.database.beans.UrlParameter; import org.kitodo.data.database.beans.User; import org.kitodo.data.database.exceptions.DAOException; +import org.kitodo.data.exceptions.DataException; import org.kitodo.exceptions.ImportException; import org.kitodo.production.services.ServiceManager; @@ -59,6 +66,8 @@ public class ImportServiceIT { private static final String TEST_FILE_ERROR_RESPONSE_PATH = "src/test/resources/customInterfaceErrorResponse.xml"; private static final String RECORD_ID = "11111"; private static final String CUSTOM_INTERFACE_RECORD_ID = "12345"; + private static final String TITLE = "Title"; + private static final String PLACE = "Place"; private static final int PORT = 8888; private static final String firstProcess = "First process"; @@ -98,6 +107,42 @@ public void testImportProcess() throws Exception { Assert.assertEquals("Not the correct amount of processes found", 8, (long) processService.count()); } + /** + * Tests whether basic catalog metadata import with additional preset metadata to a single process succeeds or not. + * + * @throws DAOException when loading ImportConfiguration or removing test process from test database fails. + * @throws ImportException when importing metadata fails + * @throws IOException when importing metadata fails + */ + @Test + public void testImportProcessWithAdditionalMetadata() throws DAOException, ImportException, IOException, DataException { + Map> presetMetadata = new HashMap<>(); + presetMetadata.put(TITLE, List.of("Band 1")); + presetMetadata.put(PLACE, List.of("Hamburg", "Berlin")); + Process processWithAdditionalMetadata = importProcessWithAdditionalMetadata(RECORD_ID, + MockDatabase.getK10PlusImportConfiguration(), presetMetadata); + Workpiece workpiece = ServiceManager.getMetsService() + .loadWorkpiece(processService.getMetadataFileUri(processWithAdditionalMetadata)); + HashSet metadata = workpiece.getLogicalStructure().getMetadata(); + try { + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, TITLE, "Band 1")); + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, PLACE, "Hamburg")); + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, PLACE, "Berlin")); + } finally { + ProcessService.deleteProcess(processWithAdditionalMetadata.getId()); + } + } + + private boolean assertMetadataSetContainsMetadata(HashSet metadataSet, String metadataKey, String metadataValue) { + return metadataSet.stream() + .filter(metadata -> metadata.getKey().equals(metadataKey)) + .anyMatch(metadata -> metadata instanceof MetadataEntry && + ((MetadataEntry) metadata).getValue().equals(metadataValue)); + } + @Test public void shouldCreateUrlWithCustomParameters() throws DAOException, ImportException, IOException { Process importedProcess = importProcess(CUSTOM_INTERFACE_RECORD_ID, MockDatabase.getCustomTypeImportConfiguration()); @@ -160,4 +205,19 @@ private Process importProcess(String recordId, ImportConfiguration importConfigu } return importedProcess; } + + private Process importProcessWithAdditionalMetadata(String recordId, ImportConfiguration importConfiguration, + Map> presetMetadata) + throws IOException, ImportException { + File script = new File(ConfigCore.getParameter(ParameterCore.SCRIPT_CREATE_DIR_META)); + if (!SystemUtils.IS_OS_WINDOWS) { + ExecutionPermission.setExecutePermission(script); + } + Process importedProcess = importService.importProcess(recordId, 1, 1, + importConfiguration, presetMetadata); + if (!SystemUtils.IS_OS_WINDOWS) { + ExecutionPermission.setNoExecutePermission(script); + } + return importedProcess; + } } From aba9025f7976fa5ce1135f876a4aa33c0a9a96d0 Mon Sep 17 00:00:00 2001 From: BartChris Date: Tue, 16 Apr 2024 14:48:30 +0200 Subject: [PATCH 02/10] Await in selenium test --- .../kitodo/selenium/testframework/pages/ProcessesPage.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java index e0e1dda4ab7..9b6825b9810 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java @@ -498,6 +498,11 @@ public void goToCalendar() throws Exception { if (isNotAt()) { goTo(); } + + await("Wait for openCalendarLink to be clickable") + .pollDelay(100, TimeUnit.MILLISECONDS) + .atMost(5, TimeUnit.SECONDS) + .until(openCalendarLink::isDisplayed); openCalendarLink.click(); } From 3b6bf97dac4196a8585f420747e4136088a8aede Mon Sep 17 00:00:00 2001 From: BartChris Date: Mon, 29 Apr 2024 19:03:03 +0200 Subject: [PATCH 03/10] backport calendar tests handling for better stability of Selenium tests --- .../test/java/org/kitodo/MockDatabase.java | 3 +- .../java/org/kitodo/selenium/CalendarST.java | 5 +- .../testframework/pages/CalendarPage.java | 217 +++++++----------- .../selenium/testframework/pages/Page.java | 8 + .../testframework/pages/ProcessesPage.java | 16 +- 5 files changed, 106 insertions(+), 143 deletions(-) diff --git a/Kitodo/src/test/java/org/kitodo/MockDatabase.java b/Kitodo/src/test/java/org/kitodo/MockDatabase.java index f3f956a78b5..a63a7430192 100644 --- a/Kitodo/src/test/java/org/kitodo/MockDatabase.java +++ b/Kitodo/src/test/java/org/kitodo/MockDatabase.java @@ -725,7 +725,7 @@ public static void removeProcessesForHierarchyTests() throws DataException { } - public static void insertProcessForCalendarHierarchyTests() throws DAOException, DataException { + public static int insertProcessForCalendarHierarchyTests() throws DAOException, DataException { Ruleset fivthRuleset = new Ruleset(); fivthRuleset.setTitle("Newspaper"); fivthRuleset.setFile("newspaper.xml"); @@ -741,6 +741,7 @@ public static void insertProcessForCalendarHierarchyTests() throws DAOException, tenthProcess.setRuleset(ServiceManager.getRulesetService().getById(5)); tenthProcess.setTitle("NewspaperOverallProcess"); ServiceManager.getProcessService().save(tenthProcess); + return tenthProcess.getId(); } private static void insertTemplates() throws DAOException, DataException { diff --git a/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java b/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java index f3372173b75..4792055b03b 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java @@ -31,6 +31,7 @@ public class CalendarST extends BaseTestSelenium { private static ProcessesPage processesPage; private static CalendarPage calendarPage; + private static int newspaperTestProcessId = -1; @BeforeClass public static void setup() throws Exception { @@ -47,11 +48,11 @@ public void logout() throws Exception { @Test public void createProcessFromCalendar() throws Exception { // add process to access calendar - MockDatabase.insertProcessForCalendarHierarchyTests(); + newspaperTestProcessId = MockDatabase.insertProcessForCalendarHierarchyTests(); login(); processesPage.goTo(); - processesPage.goToCalendar(); + processesPage.goToCalendar(newspaperTestProcessId); calendarPage.addBlock(); calendarPage.addIssue("Morning issue"); calendarPage.addIssue("Evening issue"); diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/CalendarPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/CalendarPage.java index 32475a38dfb..3b44cd1d56b 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/CalendarPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/CalendarPage.java @@ -22,15 +22,12 @@ import org.kitodo.selenium.testframework.Browser; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.FindBy; public class CalendarPage extends Page { private static final String BUTTON_CANCEL = "editForm:cancel"; private static final String BUTTON_ADD_BLOCK = "editForm:calendarTabView:addBlock"; private static final String DATEPICKER_FROM = "#editForm\\:calendarTabView\\:blockList td:first-child .p-datepicker input"; - private static final String DATEPICKER_FROM_LINK = "//div[@id='editForm:calendarTabView:blockList:0:blockFirstAppearance_panel']//" - + "a[text()='1']"; private static final String DATEPICKER_TO_LINK = "(//div[@id='editForm:calendarTabView:blockList:0:blockLastAppearance_panel']//" + "a[text()='7'])[last()]"; private static final String DATEPICKER_TO = "#editForm\\:calendarTabView\\:blockList td:last-child .p-datepicker input"; @@ -50,84 +47,10 @@ public class CalendarPage extends Page { private static final String METADATA_TYPE_PANEL = METADATA_TYPE + "_panel"; private static final String METADATA_VALUE = "calendarDayForm:issuesAccordion:0:metadataDataView:0:startValue"; private static final String CALENDAR_DIALOG_CLOSE_BUTTON = "calendarDayForm:close"; + private static final String CALENDAR = "editForm:calendarTabView:calendarTable"; + private static final String CALENDAR_ISSUES = ".issue.match"; - @SuppressWarnings("unused") - @FindBy(id = BUTTON_ADD_BLOCK) - private WebElement buttonAddBlock; - - @SuppressWarnings("unused") - @FindBy(id = BUTTON_CANCEL) - private WebElement buttonCancel; - - @SuppressWarnings("unused") - @FindBy(css = DATEPICKER_FROM) - private WebElement datepickerFrom; - - @SuppressWarnings("unused") - @FindBy(xpath = DATEPICKER_FROM_LINK) - private WebElement datepickerFromLink; - - @SuppressWarnings("unused") - @FindBy(css = DATEPICKER_TO) - private WebElement datepickerTo; - - @SuppressWarnings("unused") - @FindBy(xpath = DATEPICKER_TO_LINK) - private WebElement datepickerToLink; - - @SuppressWarnings("unused") - @FindBy(css = BUTTON_ADD_ISSUE) - private WebElement buttonAddIssue; - - @SuppressWarnings("unused") - @FindBy(css = INPUT_ISSUE) - private WebElement inputIssueName; - - @SuppressWarnings("unused") - @FindBy(id = HEADER_TEXT) - private WebElement headerText; - - @SuppressWarnings("unused") - @FindBy(css = CHECKBOX_MONDAY) - private WebElement checkboxMonday; - - @SuppressWarnings("unused") - @FindBy(css = CHECKBOX_TUESDAY) - private WebElement checkboxTuesday; - - @SuppressWarnings("unused") - @FindBy(xpath = CALENDAR_ENTRY) - private WebElement calendarEntry; - - @SuppressWarnings("unused") - @FindBy(xpath = CALENDAR_ENTRY_BUTTON) - private WebElement calendarEntryButton; - - @SuppressWarnings("unused") - @FindBy(id = BUTTON_ADD_METADATA_TO_THIS) - private WebElement buttonAddMetadataToThis; - - @SuppressWarnings("unused") - @FindBy(id = BUTTON_ADD_METADATA_TO_ALL) - private WebElement buttonAddMetadataToAll; - - @SuppressWarnings("unused") - @FindBy(id = METADATA_TYPE) - private WebElement metadataType; - - @SuppressWarnings("unused") - @FindBy(id = METADATA_TYPE_PANEL) - private WebElement metadataTypePanel; - - @SuppressWarnings("unused") - @FindBy(id = METADATA_VALUE) - private WebElement metadataValue; - - @SuppressWarnings("unused") - @FindBy(id = CALENDAR_DIALOG_CLOSE_BUTTON) - private WebElement calendarDialogCloseButton; - public CalendarPage() { super("pages/calendar.jsf"); } @@ -142,26 +65,35 @@ public CalendarPage goTo() { */ public void addBlock() { await("Wait for button to be displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(buttonAddBlock.isEnabled())); - buttonAddBlock.click(); + .untilAsserted(() -> assertTrue(getById(BUTTON_ADD_BLOCK).isEnabled())); + getById(BUTTON_ADD_BLOCK).click(); await("Wait for datepicker from being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(datepickerFrom.isEnabled())); - datepickerFrom.click(); - datepickerFromLink.click(); + .untilAsserted(() -> assertTrue(getByCSS(DATEPICKER_FROM).isEnabled())); + getByCSS(DATEPICKER_FROM).click(); + getByCSS(DATEPICKER_FROM).sendKeys("01.02.2023"); + getPageHeader().click(); await("Wait for datepicker to being displayed") - .pollDelay(3, TimeUnit.SECONDS) + .pollDelay(2, TimeUnit.SECONDS) + .pollInterval(400, TimeUnit.MILLISECONDS) + .atMost(10, TimeUnit.SECONDS) + .ignoreExceptions() + .untilAsserted(() -> assertTrue(getByXPath(DATEPICKER_TO_LINK).isEnabled())); + getByCSS(DATEPICKER_TO).click(); + await("Wait for datepicker to being displayed") + .pollDelay(2, TimeUnit.SECONDS) + .pollInterval(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(datepickerToLink.isEnabled())); - datepickerToLink.click(); + .untilAsserted(() -> assertTrue(getByXPath(DATEPICKER_TO_LINK).isEnabled())); + getByXPath(DATEPICKER_TO_LINK).click(); } /** @@ -170,47 +102,47 @@ public void addBlock() { */ public void addIssue(String title) { await("Wait for issue button being displayed") - .pollDelay(3, TimeUnit.SECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(buttonAddIssue.isEnabled())); - buttonAddIssue.click(); + .untilAsserted(() -> assertTrue(getByCSS(BUTTON_ADD_ISSUE).isEnabled())); + getByCSS(BUTTON_ADD_ISSUE).click(); await("Wait for issue input being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(inputIssueName.isEnabled())); - inputIssueName.click(); - inputIssueName.sendKeys(title); - headerText.click(); + .untilAsserted(() -> assertTrue(getByCSS(INPUT_ISSUE).isEnabled())); + getByCSS(INPUT_ISSUE).click(); + getByCSS(INPUT_ISSUE).sendKeys(title); + getById(HEADER_TEXT).click(); await("Wait for checkbox being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(checkboxMonday.isDisplayed())); - checkboxMonday.click(); + .untilAsserted(() -> assertTrue(getByCSS(CHECKBOX_MONDAY).isDisplayed())); + getByCSS(CHECKBOX_MONDAY).click(); await("Wait for checkbox being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(checkboxMonday.isDisplayed())); - checkboxTuesday.click(); + .untilAsserted(() -> assertTrue(getByCSS(CHECKBOX_MONDAY).isDisplayed())); + getByCSS(CHECKBOX_TUESDAY).click(); } /** * Add metadata to this issue. Type "Process title" and value "Test" will be inserted. */ public void addMetadataToThis() { - addMetadata("Process title", "Test", buttonAddMetadataToThis); + addMetadata("Process title", "Test", BUTTON_ADD_METADATA_TO_THIS); } /** * Add metadata to this and all following issues. Type "Signatur" and value "1234" will be used. */ public void addMetadataToAll() { - addMetadata("Signatur", "1234", buttonAddMetadataToAll); + addMetadata("Signatur", "1234", BUTTON_ADD_METADATA_TO_ALL); } /** @@ -220,21 +152,22 @@ public void addMetadataToAll() { */ public List getMetadata(String issueName) { await("Wait for calendar entry being displayed") - .pollDelay(3, TimeUnit.SECONDS) + .pollDelay(2, TimeUnit.SECONDS) + .pollInterval(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue( calendarEntry.isDisplayed())); - calendarEntryButton.click(); + .untilAsserted(() -> assertTrue(getByXPath(CALENDAR_ENTRY).isDisplayed())); + getByXPath(CALENDAR_ENTRY_BUTTON).click(); await("Wait for issue '" + issueName + "' being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() .untilAsserted(() -> assertTrue(getIssue(issueName).isDisplayed())); if (Objects.equals(getIssue(issueName).getAttribute("aria-expanded"), "false")) { - Browser.getDriver().findElementByXPath("//div[@aria-expanded='true']").click(); + getByXPath("//div[@aria-expanded='true']").click(); await("Wait for issue '" + issueName + "' being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() .untilAsserted(() -> assertTrue(getIssue(issueName).isDisplayed())); @@ -242,13 +175,13 @@ public List getMetadata(String issueName) { } await("Wait for issue content for '" + issueName + "' being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() .untilAsserted(() -> assertTrue(getIssueContent(issueName).isDisplayed())); List metadataList = readMetadataTypes(issueName); - calendarDialogCloseButton.click(); + getById(CALENDAR_DIALOG_CLOSE_BUTTON).click(); return metadataList; } @@ -257,46 +190,52 @@ public List getMetadata(String issueName) { * Click cancel button and leave calendar. */ public void closePage() { - buttonCancel.click(); + getById(BUTTON_CANCEL).click(); + } + + public int countIssues() { + await("Wait for calendar issues to be displayed") + .untilAsserted(() -> assertTrue(getById(CALENDAR).isDisplayed())); + return getById(CALENDAR).findElements(By.cssSelector(CALENDAR_ISSUES)).size(); } - private void addMetadata(String type, String value, WebElement addButton) { + private void addMetadata(String type, String value, String addButton) { await("Wait for calendar entry being displayed") - .pollDelay(3, TimeUnit.SECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue( calendarEntry.isDisplayed())); - calendarEntryButton.click(); + .untilAsserted(() -> assertTrue(getByXPath(CALENDAR_ENTRY).isDisplayed())); + getByXPath(CALENDAR_ENTRY_BUTTON).click(); await("Wait for button to add metadata to this issue being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(addButton.isEnabled())); - addButton.click(); + .untilAsserted(() -> assertTrue(getById(addButton).isEnabled())); + getById(addButton).click(); await("Wait for button to add metadata to this issue being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(metadataType.isEnabled())); - metadataType.click(); - metadataTypePanel.findElement(By.xpath("//li[text()='" + type + "']")).click(); + .untilAsserted(() -> assertTrue(getById(METADATA_TYPE).isEnabled())); + getById(METADATA_TYPE).click(); + getById(METADATA_TYPE_PANEL).findElement(By.xpath("//li[text()='" + type + "']")).click(); await("Wait for metadata input being displayed") - .pollDelay(700, TimeUnit.MILLISECONDS) + .pollDelay(400, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) .ignoreExceptions() - .untilAsserted(() -> assertTrue(metadataValue.isEnabled())); - metadataValue.sendKeys(value); - calendarDialogCloseButton.click(); + .untilAsserted(() -> assertTrue(getById(METADATA_VALUE).isEnabled())); + getById(METADATA_VALUE).sendKeys(value); + getById(CALENDAR_DIALOG_CLOSE_BUTTON).click(); } - + private WebElement getIssue(String name) { - return Browser.getDriver().findElementByXPath( "//div[text()='" + name + " erschien']"); + return getByXPath( "//div[text()='" + name + " erschien']"); } private WebElement getIssueContent(String name) { - return Browser.getDriver().findElementByXPath("//div[text()='" + name + " erschien']/following-sibling::div"); + return getByXPath("//div[text()='" + name + " erschien']/following-sibling::div"); } private List readMetadataTypes(String issueName) { @@ -304,4 +243,16 @@ private List readMetadataTypes(String issueName) { + " erschien']/following-sibling::div[@aria-hidden='false']//div[@title='Art']/label"); return metadataTypeLabels.stream().map(WebElement::getText).collect(Collectors.toList()); } -} + + private WebElement getById(String id) { + return Browser.getDriver().findElementById(id); + } + + private WebElement getByCSS(String cssSelector) { + return Browser.getDriver().findElementByCssSelector(cssSelector); + } + + private WebElement getByXPath(String xpath) { + return Browser.getDriver().findElementByXPath(xpath); + } +} \ No newline at end of file diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/Page.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/Page.java index b3fc4580c90..7b402f1bd33 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/Page.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/Page.java @@ -70,6 +70,10 @@ public abstract class Page { @FindBy(id = "search-form:search") private WebElement searchButton; + @SuppressWarnings("unused") + @FindBy(id = "portal-header") + private WebElement pageHeader; + private String URL; Page(String URL) { @@ -212,6 +216,10 @@ protected void clickElement(WebElement element) { .ignoreExceptions().until(() -> isButtonClicked.test(element)); } + public WebElement getPageHeader() { + return pageHeader; + } + /** * Get header text. * diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java index 9b6825b9810..ce89b1f3144 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java @@ -50,8 +50,8 @@ public class ProcessesPage extends Page { private static final String WAIT_FOR_ACTIONS_MENU = "Wait for actions menu to open"; private static final String WAIT_FOR_COLUMN_SORT = "Wait for column sorting"; private static final String MULTI_VOLUME_WORK_PROCESS_TITLE = "Multi volume work test process"; - private static final String WAIT_FOR_SELECTION_MENU = "Wait for process selection menu to open"; + private static final String CALENDER_ACTION_XPATH = "//a[@href='/kitodo/pages/calendarEdit.jsf?id=%s']"; @SuppressWarnings("unused") @FindBy(id = PROCESSES_TAB_VIEW) @@ -494,15 +494,17 @@ public void clickProcessesTableHeaderForSorting(int column) { .until(() -> !columnHeader.getAttribute("aria-sort").equals(previousAriaSort)); } - public void goToCalendar() throws Exception { + /** + * Navigate to calendar page to create child processes for process with provided ID 'processId'. + * @param processId ID of process for which child processes are created using the calendar + * @throws Exception when navigating to the calendar page fails + */ + public void goToCalendar(int processId) throws Exception { + String xpath = String.format(CALENDER_ACTION_XPATH, processId); + WebElement openCalendarLink = Browser.getDriver().findElementByXPath(xpath); if (isNotAt()) { goTo(); } - - await("Wait for openCalendarLink to be clickable") - .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(5, TimeUnit.SECONDS) - .until(openCalendarLink::isDisplayed); openCalendarLink.click(); } From 5ccfc3be398d779ccd61eaaa6241239a83d4a347 Mon Sep 17 00:00:00 2001 From: BartChris Date: Mon, 29 Apr 2024 19:33:25 +0200 Subject: [PATCH 04/10] another test related backport for newspaper tests --- .../production/process/NewspaperProcessesGeneratorIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java b/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java index 0f128dba220..a75e4779549 100644 --- a/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java @@ -218,7 +218,7 @@ public void shouldNotGenerateDuplicateProcessTitle() throws DAOException, DataEx Course course = NewspaperCourse.getDuplicatedCourse(); course.splitInto(Granularity.DAYS); GeneratesNewspaperProcessesThread generatesNewspaperProcessesThread = new GeneratesNewspaperProcessesThread(completeEdition, course); - generatesNewspaperProcessesThread.run(); + generatesNewspaperProcessesThread.start(); ProcessDTO byId = ServiceManager.getProcessService().findById(11); Assert.assertNull("Process should not have been created", byId.getTitle()); From 7fc3e455e72be61ac580d2ca48587f3e8de765a2 Mon Sep 17 00:00:00 2001 From: BartChris Date: Tue, 30 Apr 2024 12:18:40 +0200 Subject: [PATCH 05/10] revert change to newspaper generation test --- .../test/java/org/kitodo/MockDatabase.java | 3 +- .../NewspaperProcessesGeneratorIT.java | 2 +- .../java/org/kitodo/selenium/CalendarST.java | 4 +- .../testframework/pages/ProcessesPage.java | 12 ++---- .../src/test/resources/metadata/10/meta.xml | 35 ---------------- Kitodo/src/test/resources/metadata/9/meta.xml | 40 ------------------- .../resources/scripts/not_working_script.sh | 14 ------- .../scripts/script_createDirUserHome.sh | 21 ---------- 8 files changed, 7 insertions(+), 124 deletions(-) delete mode 100644 Kitodo/src/test/resources/metadata/10/meta.xml delete mode 100644 Kitodo/src/test/resources/metadata/9/meta.xml delete mode 100755 Kitodo/src/test/resources/scripts/not_working_script.sh delete mode 100755 Kitodo/src/test/resources/scripts/script_createDirUserHome.sh diff --git a/Kitodo/src/test/java/org/kitodo/MockDatabase.java b/Kitodo/src/test/java/org/kitodo/MockDatabase.java index a63a7430192..f3f956a78b5 100644 --- a/Kitodo/src/test/java/org/kitodo/MockDatabase.java +++ b/Kitodo/src/test/java/org/kitodo/MockDatabase.java @@ -725,7 +725,7 @@ public static void removeProcessesForHierarchyTests() throws DataException { } - public static int insertProcessForCalendarHierarchyTests() throws DAOException, DataException { + public static void insertProcessForCalendarHierarchyTests() throws DAOException, DataException { Ruleset fivthRuleset = new Ruleset(); fivthRuleset.setTitle("Newspaper"); fivthRuleset.setFile("newspaper.xml"); @@ -741,7 +741,6 @@ public static int insertProcessForCalendarHierarchyTests() throws DAOException, tenthProcess.setRuleset(ServiceManager.getRulesetService().getById(5)); tenthProcess.setTitle("NewspaperOverallProcess"); ServiceManager.getProcessService().save(tenthProcess); - return tenthProcess.getId(); } private static void insertTemplates() throws DAOException, DataException { diff --git a/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java b/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java index a75e4779549..0f128dba220 100644 --- a/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java @@ -218,7 +218,7 @@ public void shouldNotGenerateDuplicateProcessTitle() throws DAOException, DataEx Course course = NewspaperCourse.getDuplicatedCourse(); course.splitInto(Granularity.DAYS); GeneratesNewspaperProcessesThread generatesNewspaperProcessesThread = new GeneratesNewspaperProcessesThread(completeEdition, course); - generatesNewspaperProcessesThread.start(); + generatesNewspaperProcessesThread.run(); ProcessDTO byId = ServiceManager.getProcessService().findById(11); Assert.assertNull("Process should not have been created", byId.getTitle()); diff --git a/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java b/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java index 4792055b03b..01a0ee20ed9 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java @@ -48,11 +48,11 @@ public void logout() throws Exception { @Test public void createProcessFromCalendar() throws Exception { // add process to access calendar - newspaperTestProcessId = MockDatabase.insertProcessForCalendarHierarchyTests(); + MockDatabase.insertProcessForCalendarHierarchyTests(); login(); processesPage.goTo(); - processesPage.goToCalendar(newspaperTestProcessId); + processesPage.goToCalendar(); calendarPage.addBlock(); calendarPage.addIssue("Morning issue"); calendarPage.addIssue("Evening issue"); diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java index ce89b1f3144..107dae74c4e 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java @@ -51,7 +51,7 @@ public class ProcessesPage extends Page { private static final String WAIT_FOR_COLUMN_SORT = "Wait for column sorting"; private static final String MULTI_VOLUME_WORK_PROCESS_TITLE = "Multi volume work test process"; private static final String WAIT_FOR_SELECTION_MENU = "Wait for process selection menu to open"; - private static final String CALENDER_ACTION_XPATH = "//a[@href='/kitodo/pages/calendarEdit.jsf?id=%s']"; + private static final String CALENDER_ACTION_XPATH = "//a[@href='/kitodo/pages/calendarEdit.jsf?id=10']"; @SuppressWarnings("unused") @FindBy(id = PROCESSES_TAB_VIEW) @@ -494,14 +494,8 @@ public void clickProcessesTableHeaderForSorting(int column) { .until(() -> !columnHeader.getAttribute("aria-sort").equals(previousAriaSort)); } - /** - * Navigate to calendar page to create child processes for process with provided ID 'processId'. - * @param processId ID of process for which child processes are created using the calendar - * @throws Exception when navigating to the calendar page fails - */ - public void goToCalendar(int processId) throws Exception { - String xpath = String.format(CALENDER_ACTION_XPATH, processId); - WebElement openCalendarLink = Browser.getDriver().findElementByXPath(xpath); + public void goToCalendar() throws Exception { + WebElement openCalendarLink = Browser.getDriver().findElementByXPath(CALENDER_ACTION_XPATH); if (isNotAt()) { goTo(); } diff --git a/Kitodo/src/test/resources/metadata/10/meta.xml b/Kitodo/src/test/resources/metadata/10/meta.xml deleted file mode 100644 index aa3231aa5c3..00000000000 --- a/Kitodo/src/test/resources/metadata/10/meta.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - I-5300 II,III,IV - - - - - - - -
- - -
- - - diff --git a/Kitodo/src/test/resources/metadata/9/meta.xml b/Kitodo/src/test/resources/metadata/9/meta.xml deleted file mode 100644 index 055d31fc1fb..00000000000 --- a/Kitodo/src/test/resources/metadata/9/meta.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Kitodo - kitodo-ugh-3.0-SNAPSHOT - 18-April-2018 13:20:13 - Kitodo - - - - - - - Second process - Second - Proc - - - - - - - - - file:/2/images/Sec_Proc_tif - - - - - - - - - - - - - - diff --git a/Kitodo/src/test/resources/scripts/not_working_script.sh b/Kitodo/src/test/resources/scripts/not_working_script.sh deleted file mode 100755 index 44a8c4df506..00000000000 --- a/Kitodo/src/test/resources/scripts/not_working_script.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# -# (c) Kitodo. Key to digital objects e. V. -# -# This file is part of the Kitodo project. -# -# It is licensed under GNU General Public License version 3 or later. -# -# For the full copyright and license information, please read the -# GPL3-License.txt file that was distributed with this source code. -# - - -Hello World diff --git a/Kitodo/src/test/resources/scripts/script_createDirUserHome.sh b/Kitodo/src/test/resources/scripts/script_createDirUserHome.sh deleted file mode 100755 index d5cf7b41dca..00000000000 --- a/Kitodo/src/test/resources/scripts/script_createDirUserHome.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# (c) Kitodo. Key to digital objects e. V. -# -# This file is part of the Kitodo project. -# -# It is licensed under GNU General Public License version 3 or later. -# -# For the full copyright and license information, please read the -# GPL3-License.txt file that was distributed with this source code. -# - -# -# Note: Ensure that Tomcat has permission to execute the given commands. -# - -User="$1" -Home="$2" - -/bin/mkdir "$Home" -/bin/chmod g+w "$Home" From 1df411d600d6dcd7f1c31f74f98cf96137416aff Mon Sep 17 00:00:00 2001 From: BartChris Date: Tue, 30 Apr 2024 13:59:22 +0200 Subject: [PATCH 06/10] Revert "revert change to newspaper generation test" This reverts commit 47455416691ca6b77e2c69ea6b8f96343246c13c. --- .../java/org/kitodo/selenium/CalendarST.java | 1 - .../src/test/resources/metadata/10/meta.xml | 35 ++++++++++++++++ Kitodo/src/test/resources/metadata/9/meta.xml | 40 +++++++++++++++++++ .../resources/scripts/not_working_script.sh | 14 +++++++ .../scripts/script_createDirUserHome.sh | 21 ++++++++++ 5 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 Kitodo/src/test/resources/metadata/10/meta.xml create mode 100644 Kitodo/src/test/resources/metadata/9/meta.xml create mode 100755 Kitodo/src/test/resources/scripts/not_working_script.sh create mode 100755 Kitodo/src/test/resources/scripts/script_createDirUserHome.sh diff --git a/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java b/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java index 01a0ee20ed9..f3372173b75 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/CalendarST.java @@ -31,7 +31,6 @@ public class CalendarST extends BaseTestSelenium { private static ProcessesPage processesPage; private static CalendarPage calendarPage; - private static int newspaperTestProcessId = -1; @BeforeClass public static void setup() throws Exception { diff --git a/Kitodo/src/test/resources/metadata/10/meta.xml b/Kitodo/src/test/resources/metadata/10/meta.xml new file mode 100644 index 00000000000..aa3231aa5c3 --- /dev/null +++ b/Kitodo/src/test/resources/metadata/10/meta.xml @@ -0,0 +1,35 @@ + + + + + + + + + + I-5300 II,III,IV + + + + + + + +
+ + +
+ + + diff --git a/Kitodo/src/test/resources/metadata/9/meta.xml b/Kitodo/src/test/resources/metadata/9/meta.xml new file mode 100644 index 00000000000..055d31fc1fb --- /dev/null +++ b/Kitodo/src/test/resources/metadata/9/meta.xml @@ -0,0 +1,40 @@ + + + + + Kitodo - kitodo-ugh-3.0-SNAPSHOT - 18-April-2018 13:20:13 + Kitodo + + + + + + + Second process + Second + Proc + + + + + + + + + file:/2/images/Sec_Proc_tif + + + + + + + + + + + + + + diff --git a/Kitodo/src/test/resources/scripts/not_working_script.sh b/Kitodo/src/test/resources/scripts/not_working_script.sh new file mode 100755 index 00000000000..44a8c4df506 --- /dev/null +++ b/Kitodo/src/test/resources/scripts/not_working_script.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# +# (c) Kitodo. Key to digital objects e. V. +# +# This file is part of the Kitodo project. +# +# It is licensed under GNU General Public License version 3 or later. +# +# For the full copyright and license information, please read the +# GPL3-License.txt file that was distributed with this source code. +# + + +Hello World diff --git a/Kitodo/src/test/resources/scripts/script_createDirUserHome.sh b/Kitodo/src/test/resources/scripts/script_createDirUserHome.sh new file mode 100755 index 00000000000..d5cf7b41dca --- /dev/null +++ b/Kitodo/src/test/resources/scripts/script_createDirUserHome.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# (c) Kitodo. Key to digital objects e. V. +# +# This file is part of the Kitodo project. +# +# It is licensed under GNU General Public License version 3 or later. +# +# For the full copyright and license information, please read the +# GPL3-License.txt file that was distributed with this source code. +# + +# +# Note: Ensure that Tomcat has permission to execute the given commands. +# + +User="$1" +Home="$2" + +/bin/mkdir "$Home" +/bin/chmod g+w "$Home" From a6a45551c359af665158c608b0afda929242e5b8 Mon Sep 17 00:00:00 2001 From: BartChris Date: Fri, 3 May 2024 17:35:47 +0200 Subject: [PATCH 07/10] restore original metadata file 10 after ImportServiceIT --- .../kitodo/production/services/data/ImportServiceIT.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java index 809858d073d..22adf086d5f 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Map; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.SystemUtils; import org.junit.AfterClass; @@ -70,6 +71,8 @@ public class ImportServiceIT { private static final String PLACE = "Place"; private static final int PORT = 8888; private static final String firstProcess = "First process"; + private static final File ORIGINAL_META_10 = new File("src/test/resources/metadata/10/meta.xml"); + private static final File BACKUP_META_10 = new File("src/test/resources/metadata/10/meta.xml.1"); @BeforeClass public static void prepareDatabase() throws Exception { @@ -88,13 +91,17 @@ public static void prepareDatabase() throws Exception { }); server = new StubServer(PORT).run(); setupServer(); + FileUtils.copyFile(ORIGINAL_META_10, BACKUP_META_10); } + @AfterClass public static void cleanDatabase() throws Exception { MockDatabase.stopNode(); MockDatabase.cleanDatabase(); server.stop(); + FileUtils.deleteQuietly(ORIGINAL_META_10); + FileUtils.moveFile(BACKUP_META_10, ORIGINAL_META_10); } @Test From 3e4b5d14e70b6c43281aa128d2b1d9d707d22f04 Mon Sep 17 00:00:00 2001 From: BartChris Date: Fri, 3 May 2024 18:38:37 +0200 Subject: [PATCH 08/10] do not delete Process in ImportService IT --- .../services/data/ImportServiceIT.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java index 22adf086d5f..d64e01bdf8a 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java @@ -131,16 +131,12 @@ public void testImportProcessWithAdditionalMetadata() throws DAOException, Impor Workpiece workpiece = ServiceManager.getMetsService() .loadWorkpiece(processService.getMetadataFileUri(processWithAdditionalMetadata)); HashSet metadata = workpiece.getLogicalStructure().getMetadata(); - try { - Assert.assertTrue("Process does not contain correct metadata", - assertMetadataSetContainsMetadata(metadata, TITLE, "Band 1")); - Assert.assertTrue("Process does not contain correct metadata", - assertMetadataSetContainsMetadata(metadata, PLACE, "Hamburg")); - Assert.assertTrue("Process does not contain correct metadata", - assertMetadataSetContainsMetadata(metadata, PLACE, "Berlin")); - } finally { - ProcessService.deleteProcess(processWithAdditionalMetadata.getId()); - } + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, TITLE, "Band 1")); + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, PLACE, "Hamburg")); + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, PLACE, "Berlin")); } private boolean assertMetadataSetContainsMetadata(HashSet metadataSet, String metadataKey, String metadataValue) { From 603946b334fa06c58868a82c097cafa4e61082d9 Mon Sep 17 00:00:00 2001 From: BartChris Date: Fri, 3 May 2024 18:50:44 +0200 Subject: [PATCH 09/10] revert: do not delete Process in ImportService IT --- .../services/data/ImportServiceIT.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java index d64e01bdf8a..22adf086d5f 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/data/ImportServiceIT.java @@ -131,12 +131,16 @@ public void testImportProcessWithAdditionalMetadata() throws DAOException, Impor Workpiece workpiece = ServiceManager.getMetsService() .loadWorkpiece(processService.getMetadataFileUri(processWithAdditionalMetadata)); HashSet metadata = workpiece.getLogicalStructure().getMetadata(); - Assert.assertTrue("Process does not contain correct metadata", - assertMetadataSetContainsMetadata(metadata, TITLE, "Band 1")); - Assert.assertTrue("Process does not contain correct metadata", - assertMetadataSetContainsMetadata(metadata, PLACE, "Hamburg")); - Assert.assertTrue("Process does not contain correct metadata", - assertMetadataSetContainsMetadata(metadata, PLACE, "Berlin")); + try { + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, TITLE, "Band 1")); + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, PLACE, "Hamburg")); + Assert.assertTrue("Process does not contain correct metadata", + assertMetadataSetContainsMetadata(metadata, PLACE, "Berlin")); + } finally { + ProcessService.deleteProcess(processWithAdditionalMetadata.getId()); + } } private boolean assertMetadataSetContainsMetadata(HashSet metadataSet, String metadataKey, String metadataValue) { From 192ef04e5893f5cb8094ca7e45ccd48cccf1b4fb Mon Sep 17 00:00:00 2001 From: BartChris Date: Mon, 6 May 2024 13:27:43 +0200 Subject: [PATCH 10/10] remove unused method from CalendarPage --- .../kitodo/selenium/testframework/pages/CalendarPage.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/CalendarPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/CalendarPage.java index 3b44cd1d56b..0a11eb59343 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/CalendarPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/CalendarPage.java @@ -193,12 +193,6 @@ public void closePage() { getById(BUTTON_CANCEL).click(); } - public int countIssues() { - await("Wait for calendar issues to be displayed") - .untilAsserted(() -> assertTrue(getById(CALENDAR).isDisplayed())); - return getById(CALENDAR).findElements(By.cssSelector(CALENDAR_ISSUES)).size(); - } - private void addMetadata(String type, String value, String addButton) { await("Wait for calendar entry being displayed") .pollDelay(400, TimeUnit.MILLISECONDS)