-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef9c929
commit 1f770b4
Showing
6 changed files
with
299 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
Kitodo/src/test/java/org/kitodo/production/forms/ProcessFormIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* 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. | ||
*/ | ||
|
||
package org.kitodo.production.forms; | ||
|
||
import java.sql.Date; | ||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.kitodo.MockDatabase; | ||
import org.kitodo.SecurityTestUtils; | ||
import org.kitodo.data.database.beans.Process; | ||
import org.kitodo.data.database.beans.Project; | ||
import org.kitodo.data.database.beans.Template; | ||
import org.kitodo.production.services.ServiceManager; | ||
|
||
public class ProcessFormIT { | ||
|
||
private ProcessForm processForm = new ProcessForm(); | ||
|
||
/** | ||
* Setup Database and start elasticsearch. | ||
* | ||
* @throws Exception If databaseConnection failed. | ||
*/ | ||
@BeforeClass | ||
public static void prepareDatabase() throws Exception { | ||
MockDatabase.startNode(); | ||
MockDatabase.insertProcessesFull(); | ||
addProcesses(); | ||
SecurityTestUtils.addUserDataToSecurityContext(ServiceManager.getUserService().getById(1), 1); | ||
} | ||
|
||
private static void addProcesses() throws Exception { | ||
Project projectOne = ServiceManager.getProjectService().getById(1); | ||
Template template = ServiceManager.getTemplateService().getById(1); | ||
|
||
Process forthProcess = new Process(); | ||
forthProcess.setTitle("Forth process"); | ||
LocalDate localDate = LocalDate.of(2020, 3, 20); | ||
forthProcess.setCreationDate(Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())); | ||
forthProcess.setWikiField("SelectionTest"); | ||
forthProcess.setDocket(ServiceManager.getDocketService().getById(1)); | ||
forthProcess.setProject(projectOne); | ||
forthProcess.setRuleset(ServiceManager.getRulesetService().getById(1)); | ||
forthProcess.setTemplate(template); | ||
ServiceManager.getProcessService().save(forthProcess); | ||
|
||
Process fifthProcess = new Process(); | ||
fifthProcess.setTitle("Fifth process"); | ||
localDate = LocalDate.of(2020, 4, 20); | ||
fifthProcess.setCreationDate(Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())); | ||
fifthProcess.setWikiField("SelectionTest"); | ||
fifthProcess.setDocket(ServiceManager.getDocketService().getById(1)); | ||
fifthProcess.setProject(projectOne); | ||
fifthProcess.setRuleset(ServiceManager.getRulesetService().getById(1)); | ||
fifthProcess.setTemplate(template); | ||
ServiceManager.getProcessService().save(fifthProcess); | ||
} | ||
|
||
/** | ||
* Cleanup the database and stop elasticsearch. | ||
* | ||
* @throws Exception if elasticsearch could not been stopped. | ||
*/ | ||
@AfterClass | ||
public static void cleanDatabase() throws Exception { | ||
MockDatabase.stopNode(); | ||
MockDatabase.cleanDatabase(); | ||
} | ||
|
||
/** | ||
* Tests the selection in the process data table. | ||
*/ | ||
@Test | ||
public void testProcessesSelection() throws Exception { | ||
List<Integer> selectedIds; | ||
processForm.setAllSelected(true); | ||
|
||
selectedIds = processForm.getSelectedProcesses() | ||
.stream().map(Process::getId).sorted().collect(Collectors.toList()); | ||
Assert.assertEquals(new ArrayList<>(Arrays.asList(1, 2, 4, 5)), selectedIds); | ||
|
||
processForm.getExcludedProcessIds().add(4); | ||
selectedIds = processForm.getSelectedProcesses() | ||
.stream().map(Process::getId).sorted().collect(Collectors.toList()); | ||
|
||
Assert.assertEquals(new ArrayList<>(Arrays.asList(1, 2, 5)), selectedIds); | ||
|
||
processForm.setAllSelected(false); | ||
processForm.selectedProcessesOrProcessDTOs = ServiceManager.getProcessService().findByAnything("SelectionTest"); | ||
selectedIds = processForm.getSelectedProcesses() | ||
.stream().map(Process::getId).sorted().collect(Collectors.toList()); | ||
Assert.assertEquals(new ArrayList<>(Arrays.asList(4, 5)), selectedIds); | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
Kitodo/src/test/java/org/kitodo/selenium/ProcessesSelectingST.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* 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. | ||
*/ | ||
|
||
package org.kitodo.selenium; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.sql.Date; | ||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.kitodo.data.database.beans.Process; | ||
import org.kitodo.data.database.beans.Project; | ||
import org.kitodo.data.database.beans.Template; | ||
import org.kitodo.data.database.beans.User; | ||
import org.kitodo.production.services.ServiceManager; | ||
import org.kitodo.selenium.testframework.BaseTestSelenium; | ||
import org.kitodo.selenium.testframework.Pages; | ||
import org.kitodo.selenium.testframework.pages.ProcessesPage; | ||
|
||
public class ProcessesSelectingST extends BaseTestSelenium { | ||
|
||
private static ProcessesPage processesPage; | ||
|
||
/** | ||
* Set up process selecting tests. | ||
* @throws Exception as exception | ||
*/ | ||
@BeforeClass | ||
public static void setup() throws Exception { | ||
|
||
User user = ServiceManager.getUserService().getById(1); | ||
user.setTableSize(2); | ||
ServiceManager.getUserService().saveToDatabase(user); | ||
addProcesses(); | ||
processesPage = Pages.getProcessesPage(); | ||
} | ||
|
||
private static void addProcesses() throws Exception { | ||
Project projectOne = ServiceManager.getProjectService().getById(1); | ||
Template template = ServiceManager.getTemplateService().getById(1); | ||
|
||
Process forthProcess = new Process(); | ||
forthProcess.setTitle("Forth process"); | ||
LocalDate localDate = LocalDate.of(2020, 3, 20); | ||
forthProcess.setCreationDate(Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())); | ||
forthProcess.setWikiField("SelectionTest"); | ||
forthProcess.setDocket(ServiceManager.getDocketService().getById(1)); | ||
forthProcess.setProject(projectOne); | ||
forthProcess.setRuleset(ServiceManager.getRulesetService().getById(1)); | ||
forthProcess.setTemplate(template); | ||
ServiceManager.getProcessService().save(forthProcess); | ||
|
||
Process fifthProcess = new Process(); | ||
fifthProcess.setTitle("Fifth process"); | ||
localDate = LocalDate.of(2020, 4, 20); | ||
fifthProcess.setCreationDate(Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())); | ||
fifthProcess.setWikiField("SelectionTest"); | ||
fifthProcess.setDocket(ServiceManager.getDocketService().getById(1)); | ||
fifthProcess.setProject(projectOne); | ||
fifthProcess.setRuleset(ServiceManager.getRulesetService().getById(1)); | ||
fifthProcess.setTemplate(template); | ||
ServiceManager.getProcessService().save(fifthProcess); | ||
} | ||
|
||
@Before | ||
public void login() throws Exception { | ||
Pages.getLoginPage().goTo().performLoginAsAdmin(); | ||
} | ||
|
||
@After | ||
public void logout() throws Exception { | ||
Pages.getTopNavigation().logout(); | ||
} | ||
|
||
/** | ||
* Tests selection of all processes on one page in the processes data table. | ||
* @throws Exception as exception | ||
*/ | ||
@Test | ||
public void selectAllProcessesOnPageTest() throws Exception { | ||
processesPage.goTo(); | ||
|
||
processesPage.selectAllRowsOnPage(); | ||
assertEquals(processesPage.countListedSelectedProcesses(), 2); | ||
|
||
processesPage.goToNextPage(); | ||
assertEquals(processesPage.countListedSelectedProcesses(), 0); | ||
} | ||
|
||
/** | ||
*Tests selection of all processes in the processes data table. | ||
* @throws Exception as exception | ||
*/ | ||
@Test | ||
public void selectAllProcessesTest() throws Exception { | ||
processesPage.goTo(); | ||
|
||
processesPage.selectAllRows(); | ||
assertEquals(processesPage.countListedSelectedProcesses(), 2); | ||
|
||
processesPage.goToNextPage(); | ||
assertEquals(processesPage.countListedSelectedProcesses(), 2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters