-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MET-6211 Remove deprecations in metis indexing and cleanup (#698)
* MET-6211 Remove deprecations in metis indexing and cleanup * MET-6211 Process review
- Loading branch information
Showing
11 changed files
with
215 additions
and
67 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
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
88 changes: 88 additions & 0 deletions
88
...mon/metis-common-utils/src/test/java/eu/europeana/metis/utils/CommonStringValuesTest.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,88 @@ | ||
package eu.europeana.metis.utils; | ||
|
||
import static eu.europeana.metis.utils.CommonStringValues.BATCH_OF_DATASETS_RETURNED; | ||
import static eu.europeana.metis.utils.CommonStringValues.CRLF_PATTERN; | ||
import static eu.europeana.metis.utils.CommonStringValues.DATE_FORMAT; | ||
import static eu.europeana.metis.utils.CommonStringValues.DATE_FORMAT_FOR_REQUEST_PARAM; | ||
import static eu.europeana.metis.utils.CommonStringValues.DATE_FORMAT_FOR_SCHEDULING; | ||
import static eu.europeana.metis.utils.CommonStringValues.DATE_FORMAT_Z; | ||
import static eu.europeana.metis.utils.CommonStringValues.EUROPEANA_ID_CREATOR_INITIALIZATION_FAILED; | ||
import static eu.europeana.metis.utils.CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE; | ||
import static eu.europeana.metis.utils.CommonStringValues.PAGE_COUNT_CANNOT_BE_ZERO_OR_NEGATIVE; | ||
import static eu.europeana.metis.utils.CommonStringValues.PLUGIN_EXECUTION_NOT_ALLOWED; | ||
import static eu.europeana.metis.utils.CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX; | ||
import static eu.europeana.metis.utils.CommonStringValues.S_DATA_PROVIDERS_S_DATA_SETS_S_TEMPLATE; | ||
import static eu.europeana.metis.utils.CommonStringValues.UNAUTHORIZED; | ||
import static eu.europeana.metis.utils.CommonStringValues.WRONG_ACCESS_TOKEN; | ||
import static eu.europeana.metis.utils.CommonStringValues.sanitizeCRLF; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import java.util.regex.Pattern; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class CommonStringValuesTest { | ||
|
||
@Test | ||
void testFieldsAreUsed() { | ||
assertNotNull(WRONG_ACCESS_TOKEN); | ||
assertNotNull(BATCH_OF_DATASETS_RETURNED); | ||
assertNotNull(NEXT_PAGE_CANNOT_BE_NEGATIVE); | ||
assertNotNull(PAGE_COUNT_CANNOT_BE_ZERO_OR_NEGATIVE); | ||
assertNotNull(PLUGIN_EXECUTION_NOT_ALLOWED); | ||
assertNotNull(UNAUTHORIZED); | ||
assertNotNull(EUROPEANA_ID_CREATOR_INITIALIZATION_FAILED); | ||
assertNotNull(DATE_FORMAT); | ||
assertNotNull(DATE_FORMAT_Z); | ||
assertNotNull(DATE_FORMAT_FOR_SCHEDULING); | ||
assertNotNull(DATE_FORMAT_FOR_REQUEST_PARAM); | ||
assertNotNull(S_DATA_PROVIDERS_S_DATA_SETS_S_TEMPLATE); | ||
assertNotNull(REPLACEABLE_CRLF_CHARACTERS_REGEX); | ||
assertNotNull(CRLF_PATTERN); | ||
} | ||
|
||
@Test | ||
void testPattern() { | ||
Pattern expectedPattern = Pattern.compile("[\r\n\t]"); | ||
assertEquals(expectedPattern.pattern(), CRLF_PATTERN.pattern()); | ||
} | ||
|
||
@Test | ||
void testSanitizeCRLF_NullInput() { | ||
assertNull(sanitizeCRLF(null)); | ||
} | ||
|
||
@Test | ||
void testSanitizeStringForLogging_EmptyString() { | ||
String input = ""; | ||
assertEquals("", sanitizeCRLF(input)); | ||
} | ||
|
||
@Test | ||
void testSanitizeCRLF_NoSpecialCharacters() { | ||
String input = "This is a test."; | ||
assertEquals("This is a test.", sanitizeCRLF(input)); | ||
} | ||
|
||
@Test | ||
void testSanitizeCRLF_WithCRLFCharacters() { | ||
String input = "This is a test.\nThis is a new line.\rThis is a carriage return.\tThis is a tab."; | ||
String expected = "This is a test.This is a new line.This is a carriage return.This is a tab."; | ||
assertEquals(expected, sanitizeCRLF(input)); | ||
} | ||
|
||
@Test | ||
void testSanitizeCRLF_MixedInput() { | ||
String input = "\r\n\tThis string has special characters at the start.\r\n"; | ||
String expected = "This string has special characters at the start."; | ||
assertEquals(expected, sanitizeCRLF(input)); | ||
} | ||
|
||
@Test | ||
void testSanitizeCRLF_NoCRLFCharacters() { | ||
String input = "Regular string without CRLF."; | ||
assertEquals("Regular string without CRLF.", sanitizeCRLF(input)); | ||
} | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
...on/metis-common-utils/src/test/java/eu/europeana/metis/utils/DepublicationReasonTest.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 @@ | ||
package eu.europeana.metis.utils; | ||
|
||
import static eu.europeana.metis.utils.DepublicationReason.BROKEN_MEDIA_LINKS; | ||
import static eu.europeana.metis.utils.DepublicationReason.GDPR; | ||
import static eu.europeana.metis.utils.DepublicationReason.GENERIC; | ||
import static eu.europeana.metis.utils.DepublicationReason.PERMISSION_ISSUES; | ||
import static eu.europeana.metis.utils.DepublicationReason.REMOVED_DATA_AT_SOURCE; | ||
import static eu.europeana.metis.utils.DepublicationReason.SENSITIVE_CONTENT; | ||
import static eu.europeana.metis.utils.DepublicationReason.UNKNOWN; | ||
import static eu.europeana.metis.utils.DepublicationReason.values; | ||
import static java.util.Arrays.asList; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class DepublicationReasonTest { | ||
|
||
@Test | ||
void testValues() { | ||
Arrays.stream(values()).forEach(depublicationReason -> { | ||
assertNotNull(depublicationReason.getTitle()); | ||
assertNotNull(depublicationReason.getUrl()); | ||
}); | ||
} | ||
|
||
@Test | ||
void testToStringMethod() { | ||
assertEquals("Broken media links", BROKEN_MEDIA_LINKS.toString()); | ||
assertEquals("GDPR", GDPR.toString()); | ||
assertEquals("Permission issues", PERMISSION_ISSUES.toString()); | ||
assertEquals("Sensitive content", SENSITIVE_CONTENT.toString()); | ||
assertEquals("Removed data at source", REMOVED_DATA_AT_SOURCE.toString()); | ||
assertEquals("Generic", GENERIC.toString()); | ||
assertEquals("Unknown", UNKNOWN.toString()); | ||
} | ||
|
||
@Test | ||
void testEnumValuePresence() { | ||
List<DepublicationReason> depublicationReasons = asList(values()); | ||
assertEquals(7, depublicationReasons.size()); | ||
|
||
assertTrue(depublicationReasons.contains(BROKEN_MEDIA_LINKS)); | ||
assertTrue(depublicationReasons.contains(GDPR)); | ||
assertTrue(depublicationReasons.contains(PERMISSION_ISSUES)); | ||
assertTrue(depublicationReasons.contains(SENSITIVE_CONTENT)); | ||
assertTrue(depublicationReasons.contains(REMOVED_DATA_AT_SOURCE)); | ||
assertTrue(depublicationReasons.contains(GENERIC)); | ||
assertTrue(depublicationReasons.contains(UNKNOWN)); | ||
} | ||
} |
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
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
Oops, something went wrong.