Search in sources :

Example 11 with EntityDef

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

the class OpenAPIInputReaderTest method testResponse.

@Test
public void testResponse() throws Exception {
    List<Object> inputObjects = getInputs("componentResponseType.yaml");
    boolean found = false;
    for (Object o : inputObjects) {
        if (isEntityDef(o)) {
            EntityDef e = (EntityDef) o;
            ComponentDef c = e.getComponent();
            for (PathDef p : c.getPaths()) {
                if (p.getPathURI().equals("/sampledata/customSearch/")) {
                    for (OperationDef op : p.getOperations()) {
                        for (ResponseDef r : op.getResponses()) {
                            assertThat(r.getType()).isEqualTo("SampleData");
                            found = true;
                        }
                    }
                }
            }
        }
    }
    assertThat(found).isTrue();
}
Also used : ComponentDef(com.devonfw.cobigen.openapiplugin.model.ComponentDef) OperationDef(com.devonfw.cobigen.openapiplugin.model.OperationDef) PathDef(com.devonfw.cobigen.openapiplugin.model.PathDef) ResponseDef(com.devonfw.cobigen.openapiplugin.model.ResponseDef) EntityDef(com.devonfw.cobigen.openapiplugin.model.EntityDef) Test(org.junit.Test)

Example 12 with EntityDef

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

the class OpenAPIInputReaderTest method testRetrieveHeaderInfo.

@Test
public void testRetrieveHeaderInfo() throws Exception {
    List<Object> inputObjects = getInputs("two-components.yaml");
    for (Object o : inputObjects) {
        if (isEntityDef(o)) {
            EntityDef entityDef = (EntityDef) o;
            HeaderDef header = entityDef.getHeader();
            InfoDef info = header.getInfo();
            assertThat(info.getDescription()).isEqualTo("Example of a API definition");
            assertThat(info.getTitle()).isEqualTo("Devon Example");
            List<ServerDef> servers = header.getServers();
            assertThat(servers).hasSize(1);
            ServerDef server = servers.get(0);
            assertThat(server.getDescription()).isEqualTo("Just some data");
            assertThat(server.getURI()).isEqualTo("https://localhost:8081/server/services/rest");
        }
    }
}
Also used : HeaderDef(com.devonfw.cobigen.openapiplugin.model.HeaderDef) InfoDef(com.devonfw.cobigen.openapiplugin.model.InfoDef) EntityDef(com.devonfw.cobigen.openapiplugin.model.EntityDef) ServerDef(com.devonfw.cobigen.openapiplugin.model.ServerDef) Test(org.junit.Test)

Aggregations

EntityDef (com.devonfw.cobigen.openapiplugin.model.EntityDef)12 Test (org.junit.Test)9 PropertyDef (com.devonfw.cobigen.openapiplugin.model.PropertyDef)4 ResponseDef (com.devonfw.cobigen.openapiplugin.model.ResponseDef)3 LinkedList (java.util.LinkedList)3 MatcherTo (com.devonfw.cobigen.api.to.MatcherTo)2 OpenAPIMatcher (com.devonfw.cobigen.openapiplugin.matcher.OpenAPIMatcher)2 ComponentDef (com.devonfw.cobigen.openapiplugin.model.ComponentDef)2 HeaderDef (com.devonfw.cobigen.openapiplugin.model.HeaderDef)2 OperationDef (com.devonfw.cobigen.openapiplugin.model.OperationDef)2 PathDef (com.devonfw.cobigen.openapiplugin.model.PathDef)2 CobiGen (com.devonfw.cobigen.api.CobiGen)1 CobiGenAsserts.assertThat (com.devonfw.cobigen.api.assertj.CobiGenAsserts.assertThat)1 InvalidConfigurationException (com.devonfw.cobigen.api.exception.InvalidConfigurationException)1 GenerationReportTo (com.devonfw.cobigen.api.to.GenerationReportTo)1 TemplateTo (com.devonfw.cobigen.api.to.TemplateTo)1 CobiGenFactory (com.devonfw.cobigen.impl.CobiGenFactory)1 InfoDef (com.devonfw.cobigen.openapiplugin.model.InfoDef)1 OpenAPIFile (com.devonfw.cobigen.openapiplugin.model.OpenAPIFile)1 ServerDef (com.devonfw.cobigen.openapiplugin.model.ServerDef)1