Search in sources :

Example 1 with NamedElement

use of org.applause.lang.applauseDsl.NamedElement 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 NamedElement

use of org.applause.lang.applauseDsl.NamedElement 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 NamedElement

use of org.applause.lang.applauseDsl.NamedElement 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 NamedElement

use of org.applause.lang.applauseDsl.NamedElement 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 NamedElement

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

the class RESTURLsRelativeRESTURLsSpec method dataSourceAccessMethodUrlShouldBe.

public void dataSourceAccessMethodUrlShouldBe(final CharSequence sequence, final String url) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        Iterable<DataSource> _filter = Iterables.<DataSource>filter(_elements, DataSource.class);
        final DataSource datasource = IterableExtensions.<DataSource>head(_filter);
        EList<DataSourceAccessMethod> _methods = datasource.getMethods();
        final DataSourceAccessMethod method = IterableExtensions.<DataSourceAccessMethod>head(_methods);
        RESTSpecification _restSpecification = method.getRestSpecification();
        RESTURL _path = _restSpecification.getPath();
        String _value = this._rESTURLExtensions.value(_path);
        Matcher<String> _is = CoreMatchers.<String>is(url);
        Assert.<String>assertThat(_value, _is);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : DataSourceAccessMethod(org.applause.lang.applauseDsl.DataSourceAccessMethod) RESTSpecification(org.applause.lang.applauseDsl.RESTSpecification) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement) RESTURL(org.applause.lang.applauseDsl.RESTURL) DataSource(org.applause.lang.applauseDsl.DataSource)

Aggregations

Model (org.applause.lang.applauseDsl.Model)14 NamedElement (org.applause.lang.applauseDsl.NamedElement)14 Entity (org.applause.lang.applauseDsl.Entity)5 DataType (org.applause.lang.applauseDsl.DataType)3 Screen (org.applause.lang.applauseDsl.Screen)3 Attribute (org.applause.lang.applauseDsl.Attribute)2 DataSource (org.applause.lang.applauseDsl.DataSource)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 Test (org.junit.Test)2 AbsoluteRESTURL (org.applause.lang.applauseDsl.AbsoluteRESTURL)1 DataSourceAccessMethod (org.applause.lang.applauseDsl.DataSourceAccessMethod)1 DataSourceCall (org.applause.lang.applauseDsl.DataSourceCall)1 Platform (org.applause.lang.applauseDsl.Platform)1 PlatformMapping (org.applause.lang.applauseDsl.PlatformMapping)1 RESTSpecification (org.applause.lang.applauseDsl.RESTSpecification)1 RESTURL (org.applause.lang.applauseDsl.RESTURL)1 Type (org.applause.lang.applauseDsl.Type)1 TypeMapping (org.applause.lang.applauseDsl.TypeMapping)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1