- Fix missing import in groovy test.

- Code polishing.
This commit is contained in:
Lampros Smyrnaios 2023-07-14 14:26:11 +03:00
parent b63f09bfc4
commit 8b4da5c4eb
3 changed files with 9 additions and 13 deletions

View File

@ -32,13 +32,11 @@ public final class SyntheticGuideline extends AbstractGuideline<Document> {
String canonical = Helper.ensureNonEmpty(name, () -> new IllegalArgumentException("Name cannot be empty")); String canonical = Helper.ensureNonEmpty(name, () -> new IllegalArgumentException("Name cannot be empty"));
// Here we define a guideline with a specific elementSpec as origin, we cannot allow null // Here we define a guideline with a specific elementSpec as origin, we cannot allow null
if (elementSpec == null) { if ( elementSpec == null )
throw new IllegalArgumentException("ElementSpec cannot be empty"); throw new IllegalArgumentException("ElementSpec cannot be empty");
}
if (weight < 0) { if ( weight < 0 )
throw new IllegalArgumentException("Weight cannot be negative"); throw new IllegalArgumentException("Weight cannot be negative");
}
SyntheticGuideline guideline = new SyntheticGuideline(canonical, weight); SyntheticGuideline guideline = new SyntheticGuideline(canonical, weight);
guideline.compilationResult = new ElementSpecCompiler().compile(elementSpec, evaluation::get); guideline.compilationResult = new ElementSpecCompiler().compile(elementSpec, evaluation::get);
@ -49,17 +47,14 @@ public final class SyntheticGuideline extends AbstractGuideline<Document> {
public static SyntheticGuideline of(String name, int weight, RequirementLevel requirementLevel, Rule<Document> rule) { public static SyntheticGuideline of(String name, int weight, RequirementLevel requirementLevel, Rule<Document> rule) {
String canonical = Helper.ensureNonEmpty(name, () -> new IllegalArgumentException("Name cannot be empty")); String canonical = Helper.ensureNonEmpty(name, () -> new IllegalArgumentException("Name cannot be empty"));
if (weight < 0) { if ( weight < 0 )
throw new IllegalArgumentException("Weight cannot be negative"); throw new IllegalArgumentException("Weight cannot be negative");
}
if (requirementLevel == null) { if ( requirementLevel == null )
throw new IllegalArgumentException("Requirement level cannot be empty"); throw new IllegalArgumentException("Requirement level cannot be empty");
}
if (rule == null) { if ( rule == null )
throw new IllegalArgumentException("Rule cannot be empty"); throw new IllegalArgumentException("Rule cannot be empty");
}
SyntheticGuideline guideline = new SyntheticGuideline(canonical, weight); SyntheticGuideline guideline = new SyntheticGuideline(canonical, weight);
CompilationResult compilationResult = new CompilationResult(); CompilationResult compilationResult = new CompilationResult();

View File

@ -1,5 +1,6 @@
package eu.dnetlib.validator2.engine package eu.dnetlib.validator2.engine
import eu.dnetlib.validator2.engine.Helper
import groovy.xml.DOMBuilder import groovy.xml.DOMBuilder
import groovy.xml.FactorySupport import groovy.xml.FactorySupport
import org.w3c.dom.Document import org.w3c.dom.Document