use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldEqualsReturnTrueAndDoNotMakeInfinityCycleWith2DeeplyNestedEntities.
@Test
public final void shouldEqualsReturnTrueAndDoNotMakeInfinityCycleWith2DeeplyNestedEntities() {
// 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);
final Entity firstOtherEntity = new DefaultEntity(dataDefinition);
final Entity secondOtherEntity = new DefaultEntity(dataDefinition);
final Entity thirdOtherEntity = new DefaultEntity(dataDefinition);
final Entity fourthOtherEntity = 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(BELONGS_TO_FIELD_NAME, fourthEntity);
thirdEntity.setField(STRING_FIELD_NAME, L_THIRD);
fourthEntity.setField(BELONGS_TO_FIELD_NAME, thirdEntity);
fourthEntity.setField(STRING_FIELD_NAME, L_FOURTH);
firstOtherEntity.setField(BELONGS_TO_FIELD_NAME, secondOtherEntity);
firstOtherEntity.setField(STRING_FIELD_NAME, L_FIRST);
secondOtherEntity.setField(BELONGS_TO_FIELD_NAME, thirdOtherEntity);
secondOtherEntity.setField(STRING_FIELD_NAME, L_SECOND);
thirdOtherEntity.setField(BELONGS_TO_FIELD_NAME, fourthOtherEntity);
thirdOtherEntity.setField(STRING_FIELD_NAME, L_THIRD);
fourthOtherEntity.setField(BELONGS_TO_FIELD_NAME, thirdOtherEntity);
fourthOtherEntity.setField(STRING_FIELD_NAME, L_FOURTH);
// when
boolean result = false;
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 shouldToStringDoNotMakeInfinityCycleWithTwoDeeplyNestedManyToManyFieldsWithoutId.
@Test
public final void shouldToStringDoNotMakeInfinityCycleWithTwoDeeplyNestedManyToManyFieldsWithoutId() {
// 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(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(fourthEntity));
thirdEntity.setField(SECOND_MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(fourthEntity));
thirdEntity.setField(STRING_FIELD_NAME, L_THIRD);
fourthEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(thirdEntity));
fourthEntity.setField(SECOND_MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(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 shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWith2DeeplyNestedEntities.
@Test
public final void shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWith2DeeplyNestedEntities() {
// 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);
final Entity firstOtherEntity = new DefaultEntity(dataDefinition);
final Entity secondOtherEntity = new DefaultEntity(dataDefinition);
final Entity thirdOtherEntity = new DefaultEntity(dataDefinition);
final Entity fourthOtherEntity = 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(BELONGS_TO_FIELD_NAME, fourthEntity);
thirdEntity.setField(STRING_FIELD_NAME, L_THIRD);
fourthEntity.setField(BELONGS_TO_FIELD_NAME, thirdEntity);
fourthEntity.setField(STRING_FIELD_NAME, L_FOURTH);
firstOtherEntity.setField(BELONGS_TO_FIELD_NAME, secondOtherEntity);
firstOtherEntity.setField(STRING_FIELD_NAME, L_FIRST);
secondOtherEntity.setField(BELONGS_TO_FIELD_NAME, thirdOtherEntity);
secondOtherEntity.setField(STRING_FIELD_NAME, L_SECOND);
thirdOtherEntity.setField(BELONGS_TO_FIELD_NAME, fourthOtherEntity);
thirdOtherEntity.setField(STRING_FIELD_NAME, L_THIRD);
fourthOtherEntity.setField(BELONGS_TO_FIELD_NAME, thirdOtherEntity);
fourthOtherEntity.setField(STRING_FIELD_NAME, L_DIFFERENCE);
// when
boolean result = true;
try {
result = firstEntity.equals(firstOtherEntity);
} catch (StackOverflowError e) {
Assert.fail();
}
// then
assertFalse(result);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldHashCodeDoNotMakeInfinityCycleWithDeeplyNestedHasManyFieldsWithoutId.
@Test
public final void shouldHashCodeDoNotMakeInfinityCycleWithDeeplyNestedHasManyFieldsWithoutId() {
// 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(BELONGS_TO_FIELD_NAME, fourthEntity);
thirdEntity.setField(HAS_MANY_FIELD_NAME, fourthEntity);
thirdEntity.setField(STRING_FIELD_NAME, L_THIRD);
fourthEntity.setField(BELONGS_TO_FIELD_NAME, thirdEntity);
fourthEntity.setField(HAS_MANY_FIELD_NAME, thirdEntity);
fourthEntity.setField(STRING_FIELD_NAME, L_FOURTH);
// when
try {
firstEntity.hashCode();
} catch (StackOverflowError e) {
Assert.fail();
}
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldToStringDoNotMakeInfinityCycleWith2DeeplyNestedEntities.
@Test
public final void shouldToStringDoNotMakeInfinityCycleWith2DeeplyNestedEntities() {
// 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.setId(1L);
secondEntity.setField(BELONGS_TO_FIELD_NAME, thirdEntity);
secondEntity.setId(2L);
thirdEntity.setField(BELONGS_TO_FIELD_NAME, fourthEntity);
thirdEntity.setId(3L);
fourthEntity.setField(BELONGS_TO_FIELD_NAME, thirdEntity);
fourthEntity.setId(4L);
// when
try {
firstEntity.toString();
} catch (StackOverflowError e) {
Assert.fail();
}
}
Aggregations