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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations