use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class AbstractStateChangeAspectTest method shouldNotFireListenersIfStateChangeHaveErrorMessages.
@Test
public final void shouldNotFireListenersIfStateChangeHaveErrorMessages() {
// given
AnotherStateChangeService anotherStateChangeService = new AnotherStateChangeService();
EntityList messagesEntityList = mockEntityList(Lists.newArrayList(mockMessage(StateMessageType.FAILURE, "fail")));
given(stateChangeEntity.getHasManyField(DESCRIBER.getMessagesFieldName())).willReturn(messagesEntityList);
given(stateChangeEntity.getField(DESCRIBER.getMessagesFieldName())).willReturn(messagesEntityList);
// when
anotherStateChangeService.changeState(stateChangeContext);
// then
verify(stateChangeEntity, never()).setField("marked", true);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class StateChangePhaseAspectTest method shouldExecutePhaseMethod.
@Test
public final void shouldExecutePhaseMethod() {
// given
List<Entity> messages = Lists.newArrayList();
messages.add(mockMessage(StateMessageType.SUCCESS, "test"));
EntityList messagesEntityList = mockEntityList(messages);
given(stateChangeEntity.getHasManyField(DESCRIBER.getMessagesFieldName())).willReturn(messagesEntityList);
// when
stateChangeService.changeState(stateChangeContext);
// then
verify(stateChangeEntity).setField(TOUCHED_FIELD, true);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class MessagesUtilTest method shouldHasFailureMessagesReturnFalseForEmptyMessages.
@Test
public final void shouldHasFailureMessagesReturnFalseForEmptyMessages() {
// given
List<Entity> messages = Lists.newArrayList();
EntityList messagesEntityList = mockEntityList(messages);
// when
boolean result = MessagesUtil.hasFailureMessages(messagesEntityList);
// then
assertFalse(result);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class MessagesUtilTest method shouldHasFailureMessagesReturnFalse.
@Test
public final void shouldHasFailureMessagesReturnFalse() {
// given
List<Entity> messages = Lists.newArrayList();
messages.add(mockMessage(StateMessageType.SUCCESS, "test"));
EntityList messagesEntityList = mockEntityList(messages);
// when
boolean result = MessagesUtil.hasFailureMessages(messagesEntityList);
// then
assertFalse(result);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class MessagesUtilTest method mockEntityList.
private EntityList mockEntityList(final List<Entity> entities) {
EntityList entityList = mock(EntityList.class);
given(entityList.iterator()).willReturn(entities.iterator());
given(entityList.isEmpty()).willReturn(entities.isEmpty());
return entityList;
}
Aggregations