-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/test/java/de/gwdg/metadataqa/api/rule/singlefieldchecker/MultilingalCheckerTest.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,49 @@ | ||
package de.gwdg.metadataqa.api.rule.singlefieldchecker; | ||
|
||
import de.gwdg.metadataqa.api.configuration.ConfigurationReader; | ||
import de.gwdg.metadataqa.api.counter.FieldCounter; | ||
import de.gwdg.metadataqa.api.model.selector.JsonSelector; | ||
import de.gwdg.metadataqa.api.model.selector.Selector; | ||
import de.gwdg.metadataqa.api.rule.CheckerTestBase; | ||
import de.gwdg.metadataqa.api.rule.RuleCheckerOutput; | ||
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputStatus; | ||
import de.gwdg.metadataqa.api.rule.RuleCheckingOutputType; | ||
import de.gwdg.metadataqa.api.util.FileUtils; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class MultilingalCheckerTest extends CheckerTestBase { | ||
private Selector cache; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
schema = ConfigurationReader | ||
.readSchemaYaml("src/test/resources/configuration/schema/rules/multilingual/isMultilingual.yaml") | ||
.asSchema(); | ||
cache = new JsonSelector(FileUtils | ||
.readFirstLineFromResource("configuration/schema/rules/multilingual/multilingual.json")); | ||
} | ||
|
||
@Test | ||
public void success() { | ||
MultilingualChecker checker = new MultilingualChecker(schema.getPathByLabel("description")); | ||
|
||
FieldCounter<RuleCheckerOutput> fieldCounter = new FieldCounter<>(); | ||
checker.update(cache, fieldCounter, RuleCheckingOutputType.BOTH); | ||
|
||
assertEquals(2, fieldCounter.size()); | ||
assertEquals("description", checker.getHeaderWithoutId()); | ||
assertTrue(Pattern.compile("^description:\\d+$").matcher(checker.getHeader()).matches()); | ||
Assert.assertEquals( | ||
RuleCheckingOutputStatus.PASSED, | ||
fieldCounter.get(checker.getHeader(RuleCheckingOutputType.STATUS)).getStatus() | ||
); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
src/test/resources/configuration/schema/rules/multilingual/isMultilingual.yaml
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,9 @@ | ||
format: json | ||
fields: | ||
- name: id | ||
path: $.['id'] | ||
- name: description | ||
path: $.['description'] | ||
asLanguageTagged: true | ||
rules: | ||
- isMultilingual: true |
1 change: 1 addition & 0 deletions
1
src/test/resources/configuration/schema/rules/multilingual/multilingual.json
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 @@ | ||
{"id":"1","description":{"de":["Portr\u00e4t"],"zh":["\u8096\u50cf"]}} |