Search in sources :

Example 1 with ObjectTypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method shouldExtendingAnotherMultipleInheritance.

@Test
public void shouldExtendingAnotherMultipleInheritance() throws Exception {
    Map<String, GType> finder = finder("extendObjectMultipleIneritance.raml");
    ObjectTypeDeclaration object = (ObjectTypeDeclaration) finder.get("ObjectOne").implementation();
    TypeDeclaration extending = findProperty(object, "name");
    ObjectTypeDeclaration extended = (ObjectTypeDeclaration) finder.get(extending.type());
    assertTrue(TypeUtils.shouldCreateNewClass(extending, extended));
}
Also used : GType(org.raml.jaxrs.generator.ramltypes.GType) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) TypeDeclaration(org.raml.v2.api.model.v10.datamodel.TypeDeclaration) Test(org.junit.Test)

Example 2 with ObjectTypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method shouldExtendingAnother.

@Test
public void shouldExtendingAnother() throws Exception {
    Map<String, GType> finder = finder("extendingAnother.raml");
    ObjectTypeDeclaration object = (ObjectTypeDeclaration) finder.get("ObjectOne").implementation();
    TypeDeclaration extending = findProperty(object, "name");
    ObjectTypeDeclaration extended = (ObjectTypeDeclaration) finder.get(extending.type()).implementation();
    assertFalse(TypeUtils.shouldCreateNewClass(extending, extended));
}
Also used : GType(org.raml.jaxrs.generator.ramltypes.GType) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) TypeDeclaration(org.raml.v2.api.model.v10.datamodel.TypeDeclaration) Test(org.junit.Test)

Example 3 with ObjectTypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class JustLoadTest method justLoad.

@Test
public void justLoad() throws URISyntaxException {
    /*
     * RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(new
     * File(JustLoadTest.class.getResource("/jaxrs-test-resources.raml").toURI()));
     */
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(new File("target/generated-sources/raml-jaxrs/jaxrs-test-resources.raml"));
    if (ramlModelResult.hasErrors()) {
        for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
            System.out.println(validationResult.getMessage());
        }
        fail("Cant load");
    }
    Api api = ramlModelResult.getApiV10();
/*
     * Api api = ramlModelResult.getApiV10(); ObjectTypeDeclaration otd = (ObjectTypeDeclaration) api.types().get(0);
     * ArrayTypeDeclaration atd = (ArrayTypeDeclaration) otd.properties().get(0); ObjectTypeDeclaration arrayItems =
     * (ObjectTypeDeclaration) atd.items(); System.err.println(arrayItems.type());
     */
}
Also used : RamlModelBuilder(org.raml.v2.api.RamlModelBuilder) Api(org.raml.v2.api.model.v10.api.Api) RamlModelResult(org.raml.v2.api.RamlModelResult) ValidationResult(org.raml.v2.api.model.common.ValidationResult) File(java.io.File) Test(org.junit.Test)

Example 4 with ObjectTypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method bigRaml.

@Test
public void bigRaml() throws Exception {
    Map<String, GType> finder = finder("big.raml");
    ObjectTypeDeclaration object = (ObjectTypeDeclaration) finder.get("RamlDataType").implementation();
    TypeDeclaration extending = findProperty(object, "NilValue");
    ObjectTypeDeclaration extended = (ObjectTypeDeclaration) finder.get(extending.type());
    assertTrue(TypeUtils.shouldCreateNewClass(extending, extended));
}
Also used : GType(org.raml.jaxrs.generator.ramltypes.GType) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) TypeDeclaration(org.raml.v2.api.model.v10.datamodel.TypeDeclaration) Test(org.junit.Test)

Example 5 with ObjectTypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method shouldExtendingObjectWithProperties.

@Test
public void shouldExtendingObjectWithProperties() throws Exception {
    ObjectTypeDeclaration typeDeclaration = (ObjectTypeDeclaration) finder("extendObjectWithProperties.raml").get("ObjectOne").implementation();
    TypeDeclaration property = findProperty(typeDeclaration, "name");
    assertTrue(TypeUtils.shouldCreateNewClass(property, null));
}
Also used : ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) TypeDeclaration(org.raml.v2.api.model.v10.datamodel.TypeDeclaration) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 ObjectTypeDeclaration (org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration)8 TypeDeclaration (org.raml.v2.api.model.v10.datamodel.TypeDeclaration)8 GType (org.raml.jaxrs.generator.ramltypes.GType)4 File (java.io.File)1 RamlModelBuilder (org.raml.v2.api.RamlModelBuilder)1 RamlModelResult (org.raml.v2.api.RamlModelResult)1 ValidationResult (org.raml.v2.api.model.common.ValidationResult)1 Api (org.raml.v2.api.model.v10.api.Api)1 FileTypeDeclaration (org.raml.v2.api.model.v10.datamodel.FileTypeDeclaration)1