Search in sources :

Example 1 with GType

use of org.raml.jaxrs.generator.ramltypes.GType 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 GType

use of org.raml.jaxrs.generator.ramltypes.GType 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 GType

use of org.raml.jaxrs.generator.ramltypes.GType 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 4 with GType

use of org.raml.jaxrs.generator.ramltypes.GType in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method finder.

private Map<String, GType> finder(String raml) {
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(new InputStreamReader(this.getClass().getResourceAsStream(raml)), ".");
    if (ramlModelResult.hasErrors()) {
        for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
            System.out.println(validationResult.getMessage());
        }
        throw new AssertionError();
    } else {
        final Map<String, GType> decls = new HashMap<>();
        new V10Finder(null, ramlModelResult.getApiV10()).findTypes(new GFinderListener() {

            @Override
            public void newTypeDeclaration(GType type) {
                decls.put(type.name(), type);
            }
        });
        return decls;
    }
}
Also used : GType(org.raml.jaxrs.generator.ramltypes.GType) GFinderListener(org.raml.jaxrs.generator.GFinderListener) InputStreamReader(java.io.InputStreamReader) RamlModelBuilder(org.raml.v2.api.RamlModelBuilder) HashMap(java.util.HashMap) RamlModelResult(org.raml.v2.api.RamlModelResult) ValidationResult(org.raml.v2.api.model.common.ValidationResult)

Example 5 with GType

use of org.raml.jaxrs.generator.ramltypes.GType in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method shouldExtendingAnotherWithProperties.

@Test
public void shouldExtendingAnotherWithProperties() throws Exception {
    Map<String, GType> finder = finder("extendingAnotherWithProperties.raml");
    ObjectTypeDeclaration object = (ObjectTypeDeclaration) finder.get("ObjectOne").implementation();
    TypeDeclaration extending = findProperty(object, "name");
    ObjectTypeDeclaration extended = (ObjectTypeDeclaration) finder.get(extending.type()).implementation();
    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)

Aggregations

GType (org.raml.jaxrs.generator.ramltypes.GType)5 Test (org.junit.Test)4 ObjectTypeDeclaration (org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration)4 TypeDeclaration (org.raml.v2.api.model.v10.datamodel.TypeDeclaration)4 InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1 GFinderListener (org.raml.jaxrs.generator.GFinderListener)1 RamlModelBuilder (org.raml.v2.api.RamlModelBuilder)1 RamlModelResult (org.raml.v2.api.RamlModelResult)1 ValidationResult (org.raml.v2.api.model.common.ValidationResult)1