diff --git a/lphy-base/src/test/java/lphy/base/GeneratorValidationTest.java b/lphy-base/src/test/java/lphy/base/GeneratorValidationTest.java index 440726b7..c92de944 100644 --- a/lphy-base/src/test/java/lphy/base/GeneratorValidationTest.java +++ b/lphy-base/src/test/java/lphy/base/GeneratorValidationTest.java @@ -2,7 +2,9 @@ import lphy.core.model.BasicFunction; import lphy.core.model.GenerativeDistribution; +import lphy.core.model.GeneratorUtils; import lphy.core.model.Value; +import lphy.core.model.annotation.GeneratorInfo; import lphy.core.spi.Extension; import lphy.core.spi.LPhyCoreLoader; import lphy.core.spi.LPhyExtension; @@ -16,7 +18,7 @@ import java.util.Map; import java.util.Set; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.*; /** * Validate if GenerativeDistribution and Function implemented correctly, also see @@ -87,7 +89,13 @@ void validateGenerativeDistributions() { fail(genDistCls.getName() + " does not implement getParams() !"); } - //TODO constructor, @GeneratorInfo + GeneratorInfo ginfo = GeneratorUtils.getGeneratorInfo(genDistCls); + assertNotNull(ginfo, genDistCls.getName()); + // must have name and description + assertTrue(ginfo.name() != null && !ginfo.name().isEmpty(), genDistCls.getName()); + assertTrue(ginfo.description() != null && !ginfo.description().isEmpty(), genDistCls.getName()); + + //TODO constructor, params } @@ -98,18 +106,24 @@ void validateGenerativeDistributions() { @Test void validateFunctions() { - for (Class functionClass : functions) { - System.out.println("Validating function : " + functionClass.getName()); + for (Class funcCls : functions) { + System.out.println("Validating function : " + funcCls.getName()); try { // Value apply() { - Method apply = functionClass.getMethod("apply"); + Method apply = funcCls.getMethod("apply"); } catch (NoSuchMethodException e) { - fail(functionClass.getName() + " does not implement apply() !"); + fail(funcCls.getName() + " does not implement apply() !"); } - } - //TODO constructor, @GeneratorInfo, setParam in constructor, ... + GeneratorInfo ginfo = GeneratorUtils.getGeneratorInfo(funcCls); + assertNotNull(ginfo, funcCls.getName()); + // must have name and description + assertTrue(ginfo.name() != null && !ginfo.name().isEmpty(), funcCls.getName()); + assertTrue(ginfo.description() != null && !ginfo.description().isEmpty(), funcCls.getName()); + + //TODO constructor, params, setParam in constructor, ... + } System.out.println("\nTotal " + functions.size() + " Generative Distributions.\n"); }