From d978e671b86453b1486b2f84cda4030971154310 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Wed, 24 Jan 2024 14:59:34 +0100 Subject: [PATCH] Changes regarding review --- .../forms/dataeditor/StructurePanel.java | 2 +- .../resources/messages/messages_de.properties | 2 +- .../resources/messages/messages_en.properties | 2 +- .../metadataEditor/logicalStructure.xhtml | 6 ++-- .../media-detail-media-formatted-time.xhtml | 2 +- .../metadataEditor/physicalStructure.xhtml | 2 +- .../dataeditor/MediaPartialFormTest.java | 13 +++---- .../dataeditor/MediaPartialPanelTest.java | 34 +++++++++---------- 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructurePanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructurePanel.java index 2d06c366afd..cf129a4dfc5 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructurePanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructurePanel.java @@ -227,7 +227,7 @@ private void getAllSubViews(LogicalDivision selectedStructure, Collection } void deleteSelectedPhysicalDivision() { - if (Objects.nonNull(selectedLogicalNode) && StructurePanel.MEDIA_PARTIAL_NODE_TYPE.equals( + if (Objects.nonNull(selectedLogicalNode) && MEDIA_PARTIAL_NODE_TYPE.equals( selectedLogicalNode.getType()) && selectedLogicalNode.getData() instanceof StructureTreeNode) { StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData(); PhysicalDivision physicalDivision = ((View) structureTreeNode.getDataObject()).getPhysicalDivision(); diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 28b5ff447d6..26683af5016 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -661,7 +661,7 @@ jumpBackwardTenMilliseconds=10 Millisekunden zur\u00FCckspringen jumpBackwardOneMillisecond=1 Millisekunde zur\u00FCckspringen jumpForwardOneMillisecond=1 Millisekunde vorspringen jumpForwardTenMilliseconds=10 Millisekunden vorspringen -jumpForwardOnHundredMilliseconds=100 Millisekunden vorspringen +jumpForwardOneHundredMilliseconds=100 Millisekunden vorspringen jumpForwardOneSecond=1 Sekunde vorspringen kitodoScript.generateImages.error.noSourceFiles=Bilder f\u00FCr Vorgang {0} k\u00F6nnen nicht erzeugt werden: Quellordner {1} hat keinen Inhalt. kitodoScript.generateImages.error.noSourceFolder=Bilder f\u00FCr Vorgang {0} k\u00F6nnen nicht erzeugt werden: Im Projekt {1} wurde kein Quellordner festgelegt. diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index b97f580415e..55ac1627ab3 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -662,7 +662,7 @@ jumpBackwardTenMilliseconds=Jump backward 10 milliseconds jumpBackwardOneMillisecond=Jump backward 1 millisecond jumpForwardOneMillisecond=Jump forward 1 millisecond jumpForwardTenMilliseconds=Jump forward 10 milliseconds -jumpForwardOnHundredMilliseconds=Jump forward 100 milliseconds +jumpForwardOneHundredMilliseconds=Jump forward 100 milliseconds jumpForwardOneSecond=Jump forward 1 second kitodoScript.generateImages.error.noSourceFiles=Cannot generate images for process {0}: No contents found in source folder {1} kitodoScript.generateImages.error.noSourceFolder=Cannot generate images for process {0}: Project {1} has no source folder defined. diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/logicalStructure.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/logicalStructure.xhtml index 4406dbc9572..416324bda5c 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/logicalStructure.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/logicalStructure.xhtml @@ -138,7 +138,7 @@ rendered="#{logicalNode.assignedSeveralTimes}" styleClass="assigned-several-times"/> - - - ancestorsOfPhysicalDivision = new LinkedList<>(); ancestorsOfPhysicalDivision.add(new PhysicalDivision()); - MockedStatic metadataEditorMockedStatic = Mockito.mockStatic(MetadataEditor.class); - metadataEditorMockedStatic.when(() -> MetadataEditor.getAncestorsOfPhysicalDivision(physicalDivision, physicalStructure)) - .thenReturn(ancestorsOfPhysicalDivision); + try (MockedStatic metadataEditorMockedStatic = Mockito.mockStatic(MetadataEditor.class)) { + metadataEditorMockedStatic.when(() -> MetadataEditor.getAncestorsOfPhysicalDivision(physicalDivision, physicalStructure)) + .thenReturn(ancestorsOfPhysicalDivision); + } // add media partial diff --git a/Kitodo/src/test/java/org/kitodo/production/forms/dataeditor/MediaPartialPanelTest.java b/Kitodo/src/test/java/org/kitodo/production/forms/dataeditor/MediaPartialPanelTest.java index feab72ddf5a..6facb0e0b60 100644 --- a/Kitodo/src/test/java/org/kitodo/production/forms/dataeditor/MediaPartialPanelTest.java +++ b/Kitodo/src/test/java/org/kitodo/production/forms/dataeditor/MediaPartialPanelTest.java @@ -11,7 +11,8 @@ package org.kitodo.production.forms.dataeditor; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -19,7 +20,6 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kitodo.api.dataformat.LogicalDivision; @@ -47,22 +47,22 @@ public void initTest() { @Test public void testGenerateExtentAndSortMediaPartials() { List logicalDivisions = new ArrayList<>(); - logicalDivisions.add(getLogicalDivisionWithMediaPartial("Lorem ipsum", "00:00:45.001")); - logicalDivisions.add(getLogicalDivisionWithMediaPartial("Lorem ipsum", "00:00:00.002")); - logicalDivisions.add(getLogicalDivisionWithMediaPartial("Lorem ipsum", "00:00:55.894")); - logicalDivisions.add(getLogicalDivisionWithMediaPartial("Lorem ipsum", "00:00:35.123")); + logicalDivisions.add(getLogicalDivisionWithMediaPartial("00:00:45.001")); + logicalDivisions.add(getLogicalDivisionWithMediaPartial("00:00:00.002")); + logicalDivisions.add(getLogicalDivisionWithMediaPartial("00:00:55.894")); + logicalDivisions.add(getLogicalDivisionWithMediaPartial("00:00:35.123")); // one minute media duration MediaPartialHelper.calculateExtentAndSortMediaPartials(logicalDivisions, 60000L); - Assert.assertEquals("00:00:00.002", getMediaPartialOfLogicalDivision(logicalDivisions, 0).getBegin()); - Assert.assertEquals("00:00:35.121", getMediaPartialOfLogicalDivision(logicalDivisions, 0).getExtent()); - Assert.assertEquals("00:00:35.123", getMediaPartialOfLogicalDivision(logicalDivisions, 1).getBegin()); - Assert.assertEquals("00:00:09.878", getMediaPartialOfLogicalDivision(logicalDivisions, 1).getExtent()); - Assert.assertEquals("00:00:45.001", getMediaPartialOfLogicalDivision(logicalDivisions, 2).getBegin()); - Assert.assertEquals("00:00:10.893", getMediaPartialOfLogicalDivision(logicalDivisions, 2).getExtent()); - Assert.assertEquals("00:00:55.894", getMediaPartialOfLogicalDivision(logicalDivisions, 3).getBegin()); - Assert.assertEquals("00:00:04.106", getMediaPartialOfLogicalDivision(logicalDivisions, 3).getExtent()); + assertEquals("00:00:00.002", getMediaPartialOfLogicalDivision(logicalDivisions, 0).getBegin()); + assertEquals("00:00:35.121", getMediaPartialOfLogicalDivision(logicalDivisions, 0).getExtent()); + assertEquals("00:00:35.123", getMediaPartialOfLogicalDivision(logicalDivisions, 1).getBegin()); + assertEquals("00:00:09.878", getMediaPartialOfLogicalDivision(logicalDivisions, 1).getExtent()); + assertEquals("00:00:45.001", getMediaPartialOfLogicalDivision(logicalDivisions, 2).getBegin()); + assertEquals("00:00:10.893", getMediaPartialOfLogicalDivision(logicalDivisions, 2).getExtent()); + assertEquals("00:00:55.894", getMediaPartialOfLogicalDivision(logicalDivisions, 3).getBegin()); + assertEquals("00:00:04.106", getMediaPartialOfLogicalDivision(logicalDivisions, 3).getExtent()); } private static MediaPartial getMediaPartialOfLogicalDivision(List logicalDivisions, int index) { @@ -78,7 +78,7 @@ public void testMediaDurationValidation() { when(mediaPartialsPanel.getMediaDuration()).thenReturn("123456"); assertEquals("mediaPartialFormMediaDurationWrongTimeFormat", mediaPartialsPanel.validateMediaDuration()); when(mediaPartialsPanel.getMediaDuration()).thenReturn("00:01:00.000"); - Assert.assertNull(mediaPartialsPanel.validateMediaDuration()); + assertNull(mediaPartialsPanel.validateMediaDuration()); } /** @@ -90,9 +90,9 @@ public void testConverting() { assertEquals("01:01:01.120", MediaPartialHelper.convertMillisecondsToFormattedTime(3661120L)); } - private static LogicalDivision getLogicalDivisionWithMediaPartial(String label, String begin) { + private static LogicalDivision getLogicalDivisionWithMediaPartial(String begin) { LogicalDivision logicalDivision = new LogicalDivision(); - logicalDivision.setLabel(label); + logicalDivision.setLabel("Lorem ipsum"); PhysicalDivision physicalDivision = new PhysicalDivision(); MediaPartial mediaPartial = new MediaPartial(begin); physicalDivision.setMediaPartial(mediaPartial);