use of com.devonfw.cobigen.openapiplugin.matcher.OpenAPIMatcher in project cobigen by devonfw.
the class OpenAPIMatcherTest method testInvalidComponentDefMatching.
/**
* Test non valid {@link ComponentDef} matching
*/
@Test
public void testInvalidComponentDefMatching() {
ComponentDef componentDef = new ComponentDef();
componentDef.setName("Tablemanagement");
OpenAPIMatcher matcher = new OpenAPIMatcher();
boolean matches = matcher.matches(new MatcherTo("element", "ComponentDefs", componentDef));
assertThat(matches).isFalse();
}
use of com.devonfw.cobigen.openapiplugin.matcher.OpenAPIMatcher in project cobigen by devonfw.
the class OpenAPIMatcherTest method testMissingXRootPackageVariableNotMandatory.
/**
* Test if the generation is successful and the report contains warnings, if a requested but not mandatory variable
* isn't given.
*/
@Test
public void testMissingXRootPackageVariableNotMandatory() {
ComponentDef componentDef = new ComponentDef();
componentDef.setName("Tablemanagement");
OpenAPIMatcher matcher = new OpenAPIMatcher();
GenerationReportTo report = new GenerationReportTo();
List<VariableAssignmentTo> vaOptionalXRootPackage = new ArrayList<>();
vaOptionalXRootPackage.add(new VariableAssignmentTo("extension", "rootPackage", "x-rootpackage", false));
matcher.resolveVariables(new MatcherTo("element", "ComponentDef", componentDef), vaOptionalXRootPackage, report);
assertThat(report.getWarnings().get(0)).containsSequence(Constants.getMandatoryMessage(false, "x-rootpackage"));
List<VariableAssignmentTo> vaMandatoryXRootPackage = new ArrayList<>();
vaMandatoryXRootPackage.add(new VariableAssignmentTo("extension", "rootpackage", "x-rootpackage", true));
matcher.resolveVariables(new MatcherTo("element", "ComponentDef", componentDef), vaMandatoryXRootPackage, report);
assertThat(report.getErrors().get(0).getMessage()).containsSequence(Constants.getMandatoryMessage(true, "x-rootpackage"));
}
use of com.devonfw.cobigen.openapiplugin.matcher.OpenAPIMatcher in project cobigen by devonfw.
the class OpenAPIMatcherTest method testValidEntityDefMatching.
/**
* Test valid {@link EntityDef} matching
*/
@Test
public void testValidEntityDefMatching() {
EntityDef entityDef = new EntityDef();
entityDef.setComponentName("Tablemanagement");
OpenAPIMatcher matcher = new OpenAPIMatcher();
boolean matches = matcher.matches(new MatcherTo("element", "EntityDef", entityDef));
assertThat(matches).isTrue();
}
use of com.devonfw.cobigen.openapiplugin.matcher.OpenAPIMatcher in project cobigen by devonfw.
the class OpenAPIMatcherTest method testValidComponentDefMatching.
/**
* Test valid {@link ComponentDef} matching
*/
@Test
public void testValidComponentDefMatching() {
ComponentDef componentDef = new ComponentDef();
componentDef.setName("Tablemanagement");
OpenAPIMatcher matcher = new OpenAPIMatcher();
boolean matches = matcher.matches(new MatcherTo("element", "ComponentDef", componentDef));
assertThat(matches).isTrue();
}
use of com.devonfw.cobigen.openapiplugin.matcher.OpenAPIMatcher in project cobigen by devonfw.
the class OpenAPIMatcherTest method testXRootPackageVariableAssigned.
/**
* Test if the generation is successful and without warnings, if a requested variable is assigned
*/
@Test
public void testXRootPackageVariableAssigned() {
ComponentDef componentDef = new ComponentDef();
componentDef.setName("Tablemanagement");
componentDef.setUserProperty("x-rootpackage", "com.devonfw");
OpenAPIMatcher matcher = new OpenAPIMatcher();
GenerationReportTo report = new GenerationReportTo();
List<VariableAssignmentTo> va = new ArrayList<>();
va.add(new VariableAssignmentTo("extension", "rootPackage", "x-rootpackage", false));
matcher.resolveVariables(new MatcherTo("element", "ComponentDef", componentDef), va, report);
assertThat(report.getWarnings().size()).isEqualTo(0);
}
Aggregations