Search in sources :

Example 6 with PathDef

use of com.devonfw.cobigen.openapiplugin.model.PathDef 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

PathDef (com.devonfw.cobigen.openapiplugin.model.PathDef)6 OperationDef (com.devonfw.cobigen.openapiplugin.model.OperationDef)5 ComponentDef (com.devonfw.cobigen.openapiplugin.model.ComponentDef)4 LinkedList (java.util.LinkedList)4 Test (org.junit.Test)4 EntityDef (com.devonfw.cobigen.openapiplugin.model.EntityDef)2 ResponseDef (com.devonfw.cobigen.openapiplugin.model.ResponseDef)2 ParameterDef (com.devonfw.cobigen.openapiplugin.model.ParameterDef)1 Operation (com.reprezen.kaizen.oasparser.model3.Operation)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1