Skip to content

Commit

Permalink
Replace Junit4 with Junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
henning-gerhardt committed Jul 10, 2024
1 parent 5981cfa commit e486991
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 36 deletions.
4 changes: 0 additions & 4 deletions Kitodo-DataFormat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@

package org.kitodo.dataformat;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class DataFormatVersionProviderTest {

private DataFormatVersionProvider versionProvider = new DataFormatVersionProvider();
private final DataFormatVersionProvider versionProvider = new DataFormatVersionProvider();

@Test
public void getDataFormatVersionTest() {
Assert.assertEquals("Data format version was not correct", "1.0", versionProvider.getDataFormatVersion());
assertEquals("1.0", versionProvider.getDataFormatVersion(), "Data format version was not correct");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

package org.kitodo.dataformat.access;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -28,13 +29,14 @@
import java.util.List;
import java.util.stream.Collectors;

import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.kitodo.api.MdSec;
import org.kitodo.api.MetadataEntry;
import org.kitodo.api.MetadataGroup;
import org.kitodo.api.dataformat.LogicalDivision;
import org.kitodo.api.dataformat.PhysicalDivision;
import org.kitodo.api.dataformat.MediaVariant;
import org.kitodo.api.dataformat.PhysicalDivision;
import org.kitodo.api.dataformat.ProcessingNote;
import org.kitodo.api.dataformat.View;
import org.kitodo.api.dataformat.Workpiece;
Expand Down Expand Up @@ -252,41 +254,41 @@ public void testSave() throws Exception {
@Test
public void missingMetsHeaderCreationDateDidNotThrowNullPointerException() throws IOException {
Workpiece workpiece = new MetsXmlElementAccess()
.read(new FileInputStream(new File("src/test/resources/meta_missing_createdate.xml")));
.read(new FileInputStream("src/test/resources/meta_missing_createdate.xml"));
assertNotNull(workpiece.getCreationDate());
}

@Test
public void missingMetsFileForPointer() throws Exception {
try {
new MetsXmlElementAccess().read(new FileInputStream(new File("src/test/resources/meta_missing_file.xml")));
} catch (IllegalArgumentException e) {
assertEquals("Corrupt file: file id for <mets:fptr> not found for div PHYS_0001", e.getMessage());
};
public void missingMetsFileForPointer() {
Exception exception = assertThrows(IllegalArgumentException.class,
() -> new MetsXmlElementAccess().read(
new FileInputStream("src/test/resources/meta_missing_file.xml")
)
);

assertEquals("Corrupt file: file id for <mets:fptr> not found for div PHYS_0001", exception.getMessage());
}

@Test
public void duplicateMetsFileDefinition() throws Exception {
try {
new MetsXmlElementAccess().read(
new FileInputStream(new File("src/test/resources/meta_duplicate_file.xml"))
@Disabled("See GitHub discussion https://github.com/kitodo/kitodo-production/discussions/6087")
public void duplicateMetsFileDefinition() {
Exception exception = assertThrows(IllegalArgumentException.class,
() -> new MetsXmlElementAccess().read(
new FileInputStream("src/test/resources/meta_duplicate_file.xml")
)
);
} catch (IllegalArgumentException e) {
assertEquals("Corrupt file: file with id FILE_0001 is part of multiple groups", e.getMessage());
};

assertEquals("Corrupt file: file with id FILE_0001 is part of multiple groups", exception.getMessage());
}

@Test
public void missingMetsFileGroupUse() throws Exception {
try {
new MetsXmlElementAccess().read(
new FileInputStream(new File("src/test/resources/meta_missing_file_use.xml"))
);
} catch (IllegalArgumentException e) {
assertEquals(
"Corrupt file: file use for <mets:fptr> with id FILE_0001 not found in <mets:fileGrp>",
e.getMessage()
public void missingMetsFileGroupUse() {
Exception exception = assertThrows(IllegalArgumentException.class,
() -> new MetsXmlElementAccess().read(
new FileInputStream("src/test/resources/meta_missing_file_use.xml")
)
);
};

assertEquals("Corrupt file: file use for <mets:fptr> with id FILE_0001 not found in <mets:fileGrp>", exception.getMessage());
}
}

0 comments on commit e486991

Please sign in to comment.