use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldEqualsReturnTrueAndDoNotMakeInfinityCycleWithTwoManyToManyFieldsWithoutId2.
@Test
public final void shouldEqualsReturnTrueAndDoNotMakeInfinityCycleWithTwoManyToManyFieldsWithoutId2() {
// given
final Entity firstEntity = new DefaultEntity(dataDefinition);
final Entity secondEntity = new DefaultEntity(dataDefinition);
firstEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(secondEntity));
firstEntity.setField(SECOND_MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(secondEntity));
firstEntity.setField(STRING_FIELD_NAME, L_FIRST);
secondEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(firstEntity));
secondEntity.setField(SECOND_MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(firstEntity));
secondEntity.setField(STRING_FIELD_NAME, L_FIRST);
// when
boolean result = true;
try {
result = firstEntity.equals(secondEntity);
} catch (StackOverflowError e) {
Assert.fail();
}
// then
assertTrue(result);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldGetBelongsToFieldReturnProxyEntityUsingIntegerValue.
@Test
public final void shouldGetBelongsToFieldReturnProxyEntityUsingIntegerValue() throws Exception {
// given
Integer belongsToEntityId = 1;
defaultEntity.setField(BELONGS_TO_FIELD_NAME, belongsToEntityId);
// when
Entity returnedEntity = defaultEntity.getBelongsToField(BELONGS_TO_FIELD_NAME);
// then
assertTrue(returnedEntity.getId() instanceof Long);
assertFalse(belongsToEntityId.equals(returnedEntity.getId()));
assertEquals(belongsToEntityId.longValue(), returnedEntity.getId().longValue());
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldToStringDoNotMakeInfinityCycleWithDeeplyNestedHasManyFieldWithoutId.
@Test
public final void shouldToStringDoNotMakeInfinityCycleWithDeeplyNestedHasManyFieldWithoutId() {
// given
final Entity firstEntity = new DefaultEntity(dataDefinition);
final Entity secondEntity = new DefaultEntity(dataDefinition);
final Entity thirdEntity = new DefaultEntity(dataDefinition);
final Entity fourthEntity = new DefaultEntity(dataDefinition);
firstEntity.setField(BELONGS_TO_FIELD_NAME, secondEntity);
firstEntity.setField(STRING_FIELD_NAME, L_FIRST);
secondEntity.setField(BELONGS_TO_FIELD_NAME, thirdEntity);
secondEntity.setField(STRING_FIELD_NAME, L_SECOND);
thirdEntity.setField(HAS_MANY_FIELD_NAME, Lists.newArrayList(fourthEntity));
thirdEntity.setField(BELONGS_TO_FIELD_NAME, fourthEntity);
thirdEntity.setField(STRING_FIELD_NAME, L_THIRD);
fourthEntity.setField(HAS_MANY_FIELD_NAME, Lists.newArrayList(thirdEntity));
fourthEntity.setField(BELONGS_TO_FIELD_NAME, thirdEntity);
fourthEntity.setField(STRING_FIELD_NAME, L_FOURTH);
// when
try {
firstEntity.toString();
} catch (StackOverflowError e) {
Assert.fail();
}
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldEqualsReturnTrueAndDoNotMakeInfinityCycleWithManyToManyFieldWithoutId.
@Test
public final void shouldEqualsReturnTrueAndDoNotMakeInfinityCycleWithManyToManyFieldWithoutId() {
// given
final Entity firstEntity = new DefaultEntity(dataDefinition);
final Entity secondEntity = new DefaultEntity(dataDefinition);
final Entity firstOtherEntity = new DefaultEntity(dataDefinition);
final Entity secondOtherEntity = new DefaultEntity(dataDefinition);
firstEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(secondEntity));
firstEntity.setField(STRING_FIELD_NAME, L_FIRST);
secondEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(firstEntity));
secondEntity.setField(STRING_FIELD_NAME, L_SECOND);
firstOtherEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(secondOtherEntity));
firstOtherEntity.setField(STRING_FIELD_NAME, L_FIRST);
secondOtherEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(firstOtherEntity));
secondOtherEntity.setField(STRING_FIELD_NAME, L_SECOND);
// when
boolean result = true;
try {
result = firstEntity.equals(firstOtherEntity);
} catch (StackOverflowError e) {
Assert.fail();
}
// then
assertTrue(result);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldToStringDoNotMakeInfinityCycleWithManyToManyField.
@Test
public final void shouldToStringDoNotMakeInfinityCycleWithManyToManyField() {
// given
final Entity firstEntity = new DefaultEntity(dataDefinition);
final Entity secondEntity = new DefaultEntity(dataDefinition);
firstEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(secondEntity));
firstEntity.setId(1L);
secondEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(firstEntity));
secondEntity.setId(2L);
// when
try {
firstEntity.toString();
} catch (StackOverflowError e) {
Assert.fail();
}
}
Aggregations