use of com.qcadoo.model.beans.sample.SampleSimpleDatabaseObject in project qcadoo by qcadoo.
the class PriorityTest method shouldNotMoveToPositionAboveMax.
@Test
public void shouldNotMoveToPositionAboveMax() throws Exception {
// given
SampleSimpleDatabaseObject databaseObject = new SampleSimpleDatabaseObject(1L);
databaseObject.setPriority(11);
given(session.get(any(Class.class), Matchers.anyInt())).willReturn(databaseObject);
given(criteria.uniqueResult()).willReturn(5);
given(criteria.list()).willReturn(Lists.newArrayList());
// when
dataDefinition.moveTo(1L, 10);
// then
SampleSimpleDatabaseObject movedDatabaseObject = new SampleSimpleDatabaseObject(1L);
movedDatabaseObject.setPriority(5);
verify(session).update(movedDatabaseObject);
}
use of com.qcadoo.model.beans.sample.SampleSimpleDatabaseObject in project qcadoo by qcadoo.
the class PriorityTest method shouldNotMoveIfPositionDoesNotChange.
@Test
public void shouldNotMoveIfPositionDoesNotChange() throws Exception {
// given
SampleSimpleDatabaseObject databaseObject = new SampleSimpleDatabaseObject(1L);
databaseObject.setPriority(11);
given(criteria.uniqueResult()).willReturn(databaseObject, 11);
given(criteria.list()).willReturn(Lists.newArrayList());
// when
dataDefinition.moveTo(1L, 15);
// then
verify(session, never()).update(Mockito.any(SampleSimpleDatabaseObject.class));
}
use of com.qcadoo.model.beans.sample.SampleSimpleDatabaseObject in project qcadoo by qcadoo.
the class PriorityTest method shouldChangeEntitiesBetweenCurrentAndTargetPriorityWhileMovingTo.
@Test
public void shouldChangeEntitiesBetweenCurrentAndTargetPriorityWhileMovingTo() throws Exception {
// given
SampleSimpleDatabaseObject existingDatabaseObject = new SampleSimpleDatabaseObject(1L);
existingDatabaseObject.setPriority(5);
SampleSimpleDatabaseObject otherDatabaseObject = new SampleSimpleDatabaseObject(2L);
otherDatabaseObject.setPriority(6);
given(session.get(any(Class.class), Matchers.anyInt())).willReturn(existingDatabaseObject);
given(criteria.uniqueResult()).willReturn(6);
given(criteria.list()).willReturn(Lists.newArrayList(otherDatabaseObject));
// when
dataDefinition.moveTo(1L, 6);
// then
SampleSimpleDatabaseObject movedDatabaseObject = new SampleSimpleDatabaseObject(1L);
movedDatabaseObject.setPriority(6);
verify(session).update(movedDatabaseObject);
SampleSimpleDatabaseObject updatedDatabaseObject = new SampleSimpleDatabaseObject(2L);
updatedDatabaseObject.setPriority(5);
verify(session).update(updatedDatabaseObject);
}
use of com.qcadoo.model.beans.sample.SampleSimpleDatabaseObject in project qcadoo by qcadoo.
the class PriorityTest method shouldNotMoveToOffsetAboveMax.
@Test
public void shouldNotMoveToOffsetAboveMax() throws Exception {
// given
SampleSimpleDatabaseObject databaseObject = new SampleSimpleDatabaseObject(1L);
databaseObject.setPriority(11);
given(session.get(any(Class.class), Matchers.anyInt())).willReturn(databaseObject);
given(criteria.uniqueResult()).willReturn(15);
given(criteria.list()).willReturn(Lists.newArrayList());
// when
dataDefinition.moveTo(1L, 20);
// then
SampleSimpleDatabaseObject movedDatabaseObject = new SampleSimpleDatabaseObject(1L);
movedDatabaseObject.setPriority(15);
verify(session).update(movedDatabaseObject);
}
use of com.qcadoo.model.beans.sample.SampleSimpleDatabaseObject in project qcadoo by qcadoo.
the class DataAccessServiceFindTest method createDatabaseObject.
private SampleSimpleDatabaseObject createDatabaseObject(final Long id, final String name, final int age) {
SampleSimpleDatabaseObject simpleDatabaseObject = new SampleSimpleDatabaseObject(id);
simpleDatabaseObject.setName(name);
simpleDatabaseObject.setAge(age);
return simpleDatabaseObject;
}
Aggregations