Search in sources :

Example 11 with ComponentDef

use of com.devonfw.cobigen.openapiplugin.model.ComponentDef in project cobigen by devonfw.

the class OpenAPIInputReaderTest method testRetrievePathsOfComponent.

@Test
public void testRetrievePathsOfComponent() throws Exception {
    List<Object> inputObjects = getInputs("two-components.yaml");
    List<ComponentDef> cmps = new LinkedList<>();
    for (Object o : inputObjects) {
        if (isComponentDef(o)) {
            cmps.add(((ComponentDef) o));
        } else {
            cmps.add(((EntityDef) o).getComponent());
        }
    }
    assertThat(cmps).extracting("paths").hasSize(4);
    List<String> pathURIs = new LinkedList<>();
    for (ComponentDef cmp : cmps) {
        for (PathDef path : cmp.getPaths()) {
            pathURIs.add(path.getPathURI());
        }
    }
    assertThat(pathURIs).hasSize(10);
    assertThat(pathURIs).containsExactly("/table/{id}/", "/table/new/", "/sale/{id}/", "/sale/{bla}/", "/sale/", "/table/{id}/", "/table/new/", "/sale/{id}/", "/sale/{bla}/", "/sale/");
}
Also used : ComponentDef(com.devonfw.cobigen.openapiplugin.model.ComponentDef) PathDef(com.devonfw.cobigen.openapiplugin.model.PathDef) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

ComponentDef (com.devonfw.cobigen.openapiplugin.model.ComponentDef)11 Test (org.junit.Test)8 MatcherTo (com.devonfw.cobigen.api.to.MatcherTo)5 OpenAPIMatcher (com.devonfw.cobigen.openapiplugin.matcher.OpenAPIMatcher)5 PathDef (com.devonfw.cobigen.openapiplugin.model.PathDef)4 LinkedList (java.util.LinkedList)4 GenerationReportTo (com.devonfw.cobigen.api.to.GenerationReportTo)3 VariableAssignmentTo (com.devonfw.cobigen.api.to.VariableAssignmentTo)3 OperationDef (com.devonfw.cobigen.openapiplugin.model.OperationDef)3 ArrayList (java.util.ArrayList)3 EntityDef (com.devonfw.cobigen.openapiplugin.model.EntityDef)2 InvalidConfigurationException (com.devonfw.cobigen.api.exception.InvalidConfigurationException)1 HeaderDef (com.devonfw.cobigen.openapiplugin.model.HeaderDef)1 ParameterDef (com.devonfw.cobigen.openapiplugin.model.ParameterDef)1 ResponseDef (com.devonfw.cobigen.openapiplugin.model.ResponseDef)1 Path (com.reprezen.kaizen.oasparser.model3.Path)1