Search in sources :

Example 1 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class EntitiesValidationTestHelper method isValidAbstractEntityWithInheritance.

public void isValidAbstractEntityWithInheritance(final CharSequence sequence) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        NamedElement _head = IterableExtensions.<NamedElement>head(_elements);
        final Entity person = ((Entity) _head);
        EList<NamedElement> _elements_1 = model.getElements();
        NamedElement _last = IterableExtensions.<NamedElement>last(_elements_1);
        final Entity employee = ((Entity) _last);
        boolean _isAbstract = person.isAbstract();
        Matcher<Boolean> _is = CoreMatchers.<Boolean>is(Boolean.valueOf(true));
        Assert.<Boolean>assertThat(Boolean.valueOf(_isAbstract), _is);
        Entity _superType = employee.getSuperType();
        Matcher<Entity> _is_1 = CoreMatchers.<Entity>is(person);
        Assert.<Entity>assertThat(_superType, _is_1);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement)

Example 2 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class EntitiesValidationTestHelper method isValidEntityWithInheritance.

public void isValidEntityWithInheritance(final CharSequence sequence) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        NamedElement _head = IterableExtensions.<NamedElement>head(_elements);
        final Entity person = ((Entity) _head);
        EList<NamedElement> _elements_1 = model.getElements();
        NamedElement _last = IterableExtensions.<NamedElement>last(_elements_1);
        final Entity employee = ((Entity) _last);
        Entity _superType = employee.getSuperType();
        Matcher<Entity> _is = CoreMatchers.<Entity>is(person);
        Assert.<Entity>assertThat(_superType, _is);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement)

Example 3 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class EntitiesValidationTestHelper method isValidEntityWithAttributes.

public void isValidEntityWithAttributes(final CharSequence sequence) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        Iterable<Entity> _filter = Iterables.<Entity>filter(_elements, Entity.class);
        final Entity entity = IterableExtensions.<Entity>head(_filter);
        final EList<Attribute> attributes = entity.getAttributes();
        int _size = attributes.size();
        Matcher<Integer> _is = CoreMatchers.<Integer>is(Integer.valueOf(2));
        Assert.<Integer>assertThat(Integer.valueOf(_size), _is);
        EList<NamedElement> _elements_1 = model.getElements();
        final Function1<NamedElement, Boolean> _function = new Function1<NamedElement, Boolean>() {

            public Boolean apply(final NamedElement it) {
                String _name = it.getName();
                boolean _equals = Objects.equal(_name, "Date");
                return Boolean.valueOf(_equals);
            }
        };
        final NamedElement dateType = IterableExtensions.<NamedElement>findFirst(_elements_1, _function);
        EList<NamedElement> _elements_2 = model.getElements();
        final Function1<NamedElement, Boolean> _function_1 = new Function1<NamedElement, Boolean>() {

            public Boolean apply(final NamedElement it) {
                String _name = it.getName();
                boolean _equals = Objects.equal(_name, "String");
                return Boolean.valueOf(_equals);
            }
        };
        final NamedElement stringType = IterableExtensions.<NamedElement>findFirst(_elements_2, _function_1);
        final Attribute firstAttribute = IterableExtensions.<Attribute>head(attributes);
        String _name = firstAttribute.getName();
        Matcher<String> _is_1 = CoreMatchers.<String>is("name");
        Assert.<String>assertThat(_name, _is_1);
        Type _type = firstAttribute.getType();
        Matcher<NamedElement> _is_2 = CoreMatchers.<NamedElement>is(stringType);
        Assert.<Type>assertThat(_type, _is_2);
        final Attribute secondAttribute = IterableExtensions.<Attribute>last(attributes);
        String _name_1 = secondAttribute.getName();
        Matcher<String> _is_3 = CoreMatchers.<String>is("birthdate");
        Assert.<String>assertThat(_name_1, _is_3);
        Type _type_1 = secondAttribute.getType();
        Matcher<NamedElement> _is_4 = CoreMatchers.<NamedElement>is(dateType);
        Assert.<Type>assertThat(_type_1, _is_4);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) Attribute(org.applause.lang.applauseDsl.Attribute) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) Type(org.applause.lang.applauseDsl.Type) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement)

Example 4 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class EntitiesValidationTestHelper method isValidEntityWithOneToManyRelationship.

public void isValidEntityWithOneToManyRelationship(final CharSequence sequence) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        Iterable<Entity> _filter = Iterables.<Entity>filter(_elements, Entity.class);
        final Entity person = IterableExtensions.<Entity>head(_filter);
        EList<Attribute> _attributes = person.getAttributes();
        final Attribute friends = IterableExtensions.<Attribute>head(_attributes);
        boolean _isMany = friends.isMany();
        Matcher<Boolean> _is = CoreMatchers.<Boolean>is(Boolean.valueOf(true));
        Assert.<Boolean>assertThat(Boolean.valueOf(_isMany), _is);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) Attribute(org.applause.lang.applauseDsl.Attribute) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement)

Example 5 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class EntityDataMappingGeneratorSpec method isGeneratedModuleFileFromModel.

public void isGeneratedModuleFileFromModel(final CharSequence expectedGeneratedCode, final String entityName, final CharSequence input) {
    final Entity entity = this.entity(input, entityName);
    final CharSequence result = this._entityDataMappingModuleFileCompiler.compileModuleFile(entity);
    String _string = result.toString();
    String _string_1 = expectedGeneratedCode.toString();
    Matcher<String> _equalTo = CoreMatchers.<String>equalTo(_string_1);
    Assert.<String>assertThat(_string, _equalTo);
}
Also used : Entity(org.applause.lang.applauseDsl.Entity)

Aggregations

Entity (org.applause.lang.applauseDsl.Entity)34 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)17 DataSource (org.applause.lang.applauseDsl.DataSource)5 Model (org.applause.lang.applauseDsl.Model)5 NamedElement (org.applause.lang.applauseDsl.NamedElement)5 DataSourceAccessMethod (org.applause.lang.applauseDsl.DataSourceAccessMethod)4 RESTSpecification (org.applause.lang.applauseDsl.RESTSpecification)4 RESTURL (org.applause.lang.applauseDsl.RESTURL)4 Attribute (org.applause.lang.applauseDsl.Attribute)3 DataSourceCall (org.applause.lang.applauseDsl.DataSourceCall)3 Screen (org.applause.lang.applauseDsl.Screen)3 EList (org.eclipse.emf.common.util.EList)3 EObject (org.eclipse.emf.ecore.EObject)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Type (org.applause.lang.applauseDsl.Type)1 UIComponentMemberConfiguration (org.applause.lang.applauseDsl.UIComponentMemberConfiguration)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)1