Search in sources :

Example 71 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class DefaultEntityTest method shouldToStringDoNotMakeInfinityCycleWith2Entities.

@Test
public final void shouldToStringDoNotMakeInfinityCycleWith2Entities() {
    // given
    final Entity firstEntity = new DefaultEntity(dataDefinition);
    final Entity secondEntity = new DefaultEntity(dataDefinition);
    firstEntity.setField(BELONGS_TO_FIELD_NAME, secondEntity);
    firstEntity.setId(1L);
    secondEntity.setField(BELONGS_TO_FIELD_NAME, firstEntity);
    secondEntity.setId(2L);
    // when
    try {
        firstEntity.toString();
    } catch (StackOverflowError e) {
        Assert.fail();
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) Test(org.junit.Test)

Example 72 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class DefaultEntityTest method shouldToStringDoNotMakeInfinityCycleWithTwoManyToManyFields.

@Test
public final void shouldToStringDoNotMakeInfinityCycleWithTwoManyToManyFields() {
    // 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.setId(1L);
    secondEntity.setField(MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(firstEntity));
    secondEntity.setField(SECOND_MANY_TO_MANY_FIELD_NAME, Lists.newArrayList(firstEntity));
    secondEntity.setId(2L);
    // when
    try {
        firstEntity.toString();
    } catch (StackOverflowError e) {
        Assert.fail();
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) Test(org.junit.Test)

Example 73 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class DefaultEntityTest method shouldEqualsReturnTrueAndDoNotMakeInfinityCycleWith2Entities.

@Test
public final void shouldEqualsReturnTrueAndDoNotMakeInfinityCycleWith2Entities() {
    // 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(BELONGS_TO_FIELD_NAME, secondEntity);
    firstEntity.setField(STRING_FIELD_NAME, L_FIRST);
    secondEntity.setField(BELONGS_TO_FIELD_NAME, firstEntity);
    secondEntity.setField(STRING_FIELD_NAME, L_SECOND);
    firstOtherEntity.setField(BELONGS_TO_FIELD_NAME, secondOtherEntity);
    firstOtherEntity.setField(STRING_FIELD_NAME, L_FIRST);
    secondOtherEntity.setField(BELONGS_TO_FIELD_NAME, firstOtherEntity);
    secondOtherEntity.setField(STRING_FIELD_NAME, L_SECOND);
    // when
    boolean result = false;
    try {
        result = firstEntity.equals(firstOtherEntity);
    } catch (StackOverflowError e) {
        Assert.fail();
    }
    // then
    assertTrue(result);
}
Also used : Entity(com.qcadoo.model.api.Entity) Test(org.junit.Test)

Example 74 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class DefaultEntityTest method shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWith2Entities.

@Test
public final void shouldEqualsReturnFalseAndDoNotMakeInfinityCycleWith2Entities() {
    // 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(BELONGS_TO_FIELD_NAME, secondEntity);
    firstEntity.setField(STRING_FIELD_NAME, L_FIRST);
    secondEntity.setField(BELONGS_TO_FIELD_NAME, firstEntity);
    secondEntity.setField(STRING_FIELD_NAME, L_SECOND);
    firstOtherEntity.setField(BELONGS_TO_FIELD_NAME, secondOtherEntity);
    firstOtherEntity.setField(STRING_FIELD_NAME, L_FIRST);
    secondOtherEntity.setField(BELONGS_TO_FIELD_NAME, firstOtherEntity);
    secondOtherEntity.setField(STRING_FIELD_NAME, L_DIFFERENCE);
    // when
    boolean result = true;
    try {
        result = firstEntity.equals(firstOtherEntity);
    } catch (StackOverflowError e) {
        Assert.fail();
    }
    // then
    assertFalse(result);
}
Also used : Entity(com.qcadoo.model.api.Entity) Test(org.junit.Test)

Example 75 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class DefaultEntityTest method shouldCopyDoNotMakeInfinityCycleWith4EntitiesWithoutId.

@Test
public final void shouldCopyDoNotMakeInfinityCycleWith4EntitiesWithoutId() {
    // 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(STRING_FIELD_NAME, L_THIRD);
    fourthEntity.setField(BELONGS_TO_FIELD_NAME, firstEntity);
    fourthEntity.setField(STRING_FIELD_NAME, L_FOURTH);
    // when
    Entity copy = null;
    try {
        copy = firstEntity.copy();
    } catch (StackOverflowError e) {
        Assert.fail();
    }
    assertNotSame(firstEntity, copy);
    assertEquals(firstEntity, copy);
    assertNotSame(secondEntity, copy.getBelongsToField(BELONGS_TO_FIELD_NAME));
    assertEquals(secondEntity, copy.getBelongsToField(BELONGS_TO_FIELD_NAME));
    assertNotSame(thirdEntity, copy.getBelongsToField(BELONGS_TO_FIELD_NAME).getBelongsToField(BELONGS_TO_FIELD_NAME));
    assertEquals(thirdEntity, copy.getBelongsToField(BELONGS_TO_FIELD_NAME).getBelongsToField(BELONGS_TO_FIELD_NAME));
    assertNotSame(fourthEntity, copy.getBelongsToField(BELONGS_TO_FIELD_NAME).getBelongsToField(BELONGS_TO_FIELD_NAME).getBelongsToField(BELONGS_TO_FIELD_NAME));
    assertEquals(fourthEntity, copy.getBelongsToField(BELONGS_TO_FIELD_NAME).getBelongsToField(BELONGS_TO_FIELD_NAME).getBelongsToField(BELONGS_TO_FIELD_NAME));
}
Also used : Entity(com.qcadoo.model.api.Entity) Test(org.junit.Test)

Aggregations

Entity (com.qcadoo.model.api.Entity)2833 FormComponent (com.qcadoo.view.api.components.FormComponent)514 Test (org.junit.Test)491 BigDecimal (java.math.BigDecimal)376 DataDefinition (com.qcadoo.model.api.DataDefinition)337 FieldComponent (com.qcadoo.view.api.components.FieldComponent)210 LookupComponent (com.qcadoo.view.api.components.LookupComponent)188 Date (java.util.Date)185 List (java.util.List)149 GridComponent (com.qcadoo.view.api.components.GridComponent)141 Map (java.util.Map)124 Autowired (org.springframework.beans.factory.annotation.Autowired)114 Service (org.springframework.stereotype.Service)112 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)105 Transactional (org.springframework.transaction.annotation.Transactional)101 DefaultEntity (com.qcadoo.model.internal.DefaultEntity)100 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)95 Collectors (java.util.stream.Collectors)87 Lists (com.google.common.collect.Lists)75 SampleSimpleDatabaseObject (com.qcadoo.model.beans.sample.SampleSimpleDatabaseObject)75