diff --git a/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/AbstractMediaClassifierTest.java b/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/AbstractMediaClassifierTest.java index dd2baeebe..b1f5bd800 100644 --- a/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/AbstractMediaClassifierTest.java +++ b/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/AbstractMediaClassifierTest.java @@ -8,6 +8,7 @@ import static org.mockito.Mockito.when; import eu.europeana.indexing.tiers.model.MediaTier; +import eu.europeana.indexing.tiers.model.TierClassifier.TierClassification; import eu.europeana.indexing.tiers.view.ContentTierBreakdown; import eu.europeana.indexing.tiers.view.MediaResourceTechnicalMetadata; import eu.europeana.indexing.tiers.view.MediaResourceTechnicalMetadata.MediaResourceTechnicalMetadataBuilder; @@ -73,7 +74,13 @@ void resetMocks() { @Test void testClassify_PreClassify() { final RdfWrapper entity = mock(RdfWrapper.class); - doReturn(MediaTier.T0).when(classifier).preClassifyEntity(entity); + TierClassification mock = new TierClassification<>(MediaTier.T0, new ContentTierBreakdown.Builder() + .setThumbnailAvailable(false) + .setMediaTierBeforeLicenseCorrection(MediaTier.T0) + .setLicenseType(entity.getLicenseType()) + .setMediaResourceTechnicalMetadataList(Collections.emptyList()) + .build()); + doReturn(mock).when(classifier).preClassifyEntity(entity); assertEquals(MediaTier.T0, classifier.classify(entity).getTier()); } diff --git a/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/ImageClassifierTest.java b/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/ImageClassifierTest.java index d1e0154f9..f06455e5e 100644 --- a/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/ImageClassifierTest.java +++ b/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/ImageClassifierTest.java @@ -74,7 +74,7 @@ void testPreClassifyEntity() { doReturn(true).when(entity).hasThumbnails(); assertNull(classifier.preClassifyEntity(entity)); doReturn(false).when(entity).hasThumbnails(); - assertEquals(MediaTier.T0, classifier.preClassifyEntity(entity)); + assertEquals(MediaTier.T0, classifier.preClassifyEntity(entity).getTier()); } @ParameterizedTest(name = "[{index}] - expectedTier:{0} for resolution:{1}") diff --git a/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/MediaClassifierTest.java b/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/MediaClassifierTest.java index 665a82629..524128d1a 100644 --- a/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/MediaClassifierTest.java +++ b/metis-indexing/src/test/java/eu/europeana/indexing/tiers/media/MediaClassifierTest.java @@ -9,8 +9,11 @@ import static org.mockito.Mockito.verify; import eu.europeana.indexing.tiers.model.MediaTier; +import eu.europeana.indexing.tiers.model.TierClassifier.TierClassification; +import eu.europeana.indexing.tiers.view.ContentTierBreakdown; import eu.europeana.indexing.utils.RdfWrapper; import eu.europeana.metis.schema.jibx.EdmType; +import java.util.Collections; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -46,11 +49,41 @@ void testClassify() { // Create entity and tiers for various types final RdfWrapper entity = mock(RdfWrapper.class); - final MediaTier audioTier = MediaTier.T1; - final MediaTier imageTier = MediaTier.T2; - final MediaTier textTier = MediaTier.T3; - final MediaTier videoTier = MediaTier.T4; - final MediaTier threeDTier = MediaTier.T2; + final TierClassification audioTier = + new TierClassification<>(MediaTier.T1, new ContentTierBreakdown.Builder() + .setThumbnailAvailable(false) + .setMediaTierBeforeLicenseCorrection(MediaTier.T1) + .setLicenseType(entity.getLicenseType()) + .setMediaResourceTechnicalMetadataList(Collections.emptyList()) + .build()); + final TierClassification imageTier = + new TierClassification<>(MediaTier.T2, new ContentTierBreakdown.Builder() + .setThumbnailAvailable(false) + .setMediaTierBeforeLicenseCorrection(MediaTier.T2) + .setLicenseType(entity.getLicenseType()) + .setMediaResourceTechnicalMetadataList(Collections.emptyList()) + .build()); + final TierClassification textTier = + new TierClassification<>(MediaTier.T3, new ContentTierBreakdown.Builder() + .setThumbnailAvailable(false) + .setMediaTierBeforeLicenseCorrection(MediaTier.T2) + .setLicenseType(entity.getLicenseType()) + .setMediaResourceTechnicalMetadataList(Collections.emptyList()) + .build()); + final TierClassification videoTier = + new TierClassification<>(MediaTier.T4, new ContentTierBreakdown.Builder() + .setThumbnailAvailable(false) + .setMediaTierBeforeLicenseCorrection(MediaTier.T2) + .setLicenseType(entity.getLicenseType()) + .setMediaResourceTechnicalMetadataList(Collections.emptyList()) + .build()); + final TierClassification threeDTier = + new TierClassification<>(MediaTier.T2, new ContentTierBreakdown.Builder() + .setThumbnailAvailable(false) + .setMediaTierBeforeLicenseCorrection(MediaTier.T2) + .setLicenseType(entity.getLicenseType()) + .setMediaResourceTechnicalMetadataList(Collections.emptyList()) + .build()); doReturn(audioTier).when(audioClassifier).classify(entity); doReturn(imageTier).when(imageClassifier).classify(entity); doReturn(textTier).when(textClassifier).classify(entity); @@ -59,7 +92,7 @@ void testClassify() { // Test audio doReturn(EdmType.SOUND).when(entity).getEdmType(); - assertEquals(audioTier, classifier.classify(entity).getTier()); + assertEquals(audioTier.getTier(), classifier.classify(entity).getTier()); verify(audioClassifier, times(1)).classify(entity); verify(imageClassifier, times(0)).classify(entity); verify(textClassifier, times(0)).classify(entity); @@ -68,7 +101,7 @@ void testClassify() { // Test image doReturn(EdmType.IMAGE).when(entity).getEdmType(); - assertEquals(imageTier, classifier.classify(entity).getTier()); + assertEquals(imageTier.getTier(), classifier.classify(entity).getTier()); verify(audioClassifier, times(1)).classify(entity); verify(imageClassifier, times(1)).classify(entity); verify(textClassifier, times(0)).classify(entity); @@ -77,7 +110,7 @@ void testClassify() { // Test text doReturn(EdmType.TEXT).when(entity).getEdmType(); - assertEquals(textTier, classifier.classify(entity).getTier()); + assertEquals(textTier.getTier(), classifier.classify(entity).getTier()); verify(audioClassifier, times(1)).classify(entity); verify(imageClassifier, times(1)).classify(entity); verify(textClassifier, times(1)).classify(entity); @@ -86,7 +119,7 @@ void testClassify() { // Test video doReturn(EdmType.VIDEO).when(entity).getEdmType(); - assertEquals(videoTier, classifier.classify(entity).getTier()); + assertEquals(videoTier.getTier(), classifier.classify(entity).getTier()); verify(audioClassifier, times(1)).classify(entity); verify(imageClassifier, times(1)).classify(entity); verify(textClassifier, times(1)).classify(entity); @@ -95,7 +128,7 @@ void testClassify() { // Test 3D doReturn(EdmType._3_D).when(entity).getEdmType(); - assertEquals(threeDTier, classifier.classify(entity).getTier()); + assertEquals(threeDTier.getTier(), classifier.classify(entity).getTier()); verify(audioClassifier, times(1)).classify(entity); verify(imageClassifier, times(1)).classify(entity); verify(textClassifier, times(1)).classify(entity);