forked from kitodo/kitodo-production
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kitodo#5977 from slub/add_clone_to_course
Add missing clone method to Course class
- Loading branch information
Showing
3 changed files
with
197 additions
and
0 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
54 changes: 54 additions & 0 deletions
54
Kitodo/src/test/java/org/kitodo/production/model/bibliography/course/CourseTest.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,54 @@ | ||
/* | ||
* (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.model.bibliography.course; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
import javax.xml.parsers.ParserConfigurationException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.kitodo.production.helper.XMLUtils; | ||
import org.w3c.dom.Document; | ||
import org.xml.sax.SAXException; | ||
|
||
public class CourseTest { | ||
|
||
@Test | ||
public void testCloneMethod() throws IOException, ParserConfigurationException, SAXException { | ||
String xmlString = new String(Files.readAllBytes(new File("src/test/resources/newspaper-course.xml").toPath())); | ||
Document xmlDocument = XMLUtils.parseXMLString(xmlString); | ||
Course course = new Course(xmlDocument); | ||
|
||
// assert / check some data from the xml file | ||
assertEquals(23L, course.getIndividualIssues().size()); | ||
assertEquals(23, course.countIndividualIssues()); | ||
assertEquals("", course.getYearName()); | ||
|
||
// clone course | ||
Course clonedCourse = course.clone(); | ||
// courses should have same data | ||
assertEquals(course.countIndividualIssues(), clonedCourse.countIndividualIssues()); | ||
assertEquals(course.getNumberOfProcesses(), clonedCourse.getNumberOfProcesses()); | ||
assertEquals(course.getYearName(), clonedCourse.getYearName()); | ||
|
||
// change year name of not cloned course | ||
course.setYearName("Year 2024"); | ||
// year name should now differ | ||
assertEquals("", clonedCourse.getYearName()); | ||
assertNotEquals(course.getYearName(), clonedCourse.getYearName()); | ||
} | ||
} |
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,133 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
* | ||
* (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. | ||
* | ||
--> | ||
<course> | ||
<description>Die Zeitung erschien vom 1. Januar 2024 bis zum 31. Januar 2024 regelmäßig an allen Montagen, Dienstagen, Mittwochen, Donnerstagen und Freitagen.</description> | ||
<processes> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-01"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-02"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-03"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-04"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-05"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-08"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-09"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-10"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-11"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-12"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-15"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-16"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-17"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-18"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-19"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-22"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-23"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-24"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-25"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-26"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-29"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-30"/> | ||
</title> | ||
</process> | ||
<process> | ||
<title index="1"> | ||
<appeared date="2024-01-31"/> | ||
</title> | ||
</process> | ||
</processes> | ||
</course> |