use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWith4Entities.
@Test
public final void shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWith4Entities() {
// 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, firstEntity);
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, firstOtherEntity);
fourthOtherEntity.setField(STRING_FIELD_NAME, L_DIFFERENCE);
// when
boolean result = true;
try {
result = firstEntity.equals(firstOtherEntity);
} catch (StackOverflowError e) {
Assert.fail();
}
assertFalse(result);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWithManyToManyField.
@Test
public final void shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWithManyToManyField() {
// 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
boolean result = true;
try {
result = firstEntity.equals(secondEntity);
} catch (StackOverflowError e) {
Assert.fail();
}
// then
assertFalse(result);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWithHasManyField.
@Test
public final void shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWithHasManyField() {
// given
final Entity firstEntity = new DefaultEntity(dataDefinition);
final Entity secondEntity = new DefaultEntity(dataDefinition);
firstEntity.setField(HAS_MANY_FIELD_NAME, Lists.newArrayList(secondEntity));
firstEntity.setField(BELONGS_TO_FIELD_NAME, secondEntity);
firstEntity.setId(1L);
secondEntity.setField(HAS_MANY_FIELD_NAME, Lists.newArrayList(firstEntity));
secondEntity.setField(BELONGS_TO_FIELD_NAME, firstEntity);
secondEntity.setId(2L);
// when
boolean result = true;
try {
result = firstEntity.equals(secondEntity);
} catch (StackOverflowError e) {
Assert.fail();
}
// then
assertFalse(result);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldCopyDoNotMakeInfinityCycleWithManyToManyField.
@Test
public final void shouldCopyDoNotMakeInfinityCycleWithManyToManyField() {
// 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
Entity copy = null;
try {
copy = firstEntity.copy();
} catch (StackOverflowError e) {
Assert.fail();
}
// then
assertNotSame(firstEntity, copy);
assertEquals(firstEntity, copy);
assertSame(secondEntity, firstEntity.getManyToManyField(MANY_TO_MANY_FIELD_NAME).get(0));
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class DefaultEntityTest method shouldHashCodeDoNotMakeInfinityCycleWith3Entities.
@Test
public final void shouldHashCodeDoNotMakeInfinityCycleWith3Entities() {
// given
final Entity firstEntity = new DefaultEntity(dataDefinition);
final Entity secondEntity = new DefaultEntity(dataDefinition);
final Entity thirdEntity = new DefaultEntity(dataDefinition);
firstEntity.setId(1L);
firstEntity.setField(BELONGS_TO_FIELD_NAME, secondEntity);
secondEntity.setId(2L);
secondEntity.setField(BELONGS_TO_FIELD_NAME, thirdEntity);
thirdEntity.setId(3L);
thirdEntity.setField(BELONGS_TO_FIELD_NAME, firstEntity);
// when
try {
firstEntity.hashCode();
} catch (StackOverflowError e) {
Assert.fail();
}
}
Aggregations