use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class RunInPhaseAspectTest method init.
@Before
public final void init() {
MockitoAnnotations.initMocks(this);
stateChangeService = new TestStateChangeAspect();
final EntityList emptyEntityList = mockEntityList(Collections.<Entity>emptyList());
stubStateChangeEntity(DESCRIBER);
stubStateChangeContext();
stubOwner();
given(stateChangeEntity.getHasManyField(DESCRIBER.getMessagesFieldName())).willReturn(emptyEntityList);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class StateChangePhaseAspectTest method shouldNotExecutePhaseMethodIfValidationErrorOccured.
@Test
public final void shouldNotExecutePhaseMethodIfValidationErrorOccured() {
// given
List<Entity> messages = Lists.newArrayList();
Entity validationErrorMessage = mockMessage(StateMessageType.VALIDATION_ERROR, "test");
messages.add(validationErrorMessage);
EntityList messagesEntityList = mockEntityList(messages);
given(stateChangeEntity.getHasManyField(DESCRIBER.getMessagesFieldName())).willReturn(messagesEntityList);
// when
stateChangeService.changeState(stateChangeContext);
// then
verify(stateChangeEntity, never()).setField(TOUCHED_FIELD, true);
verify(stateChangeEntity, never()).setField(Mockito.eq(TOUCHED_PHASE), Mockito.anyInt());
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class StateChangePhaseAspectTest method shouldNotExecutePhaseMethod.
@Test
public final void shouldNotExecutePhaseMethod() {
// given
List<Entity> messages = Lists.newArrayList();
messages.add(mockMessage(StateMessageType.FAILURE, "test"));
EntityList messagesEntityList = mockEntityList(messages);
given(stateChangeEntity.getHasManyField(DESCRIBER.getMessagesFieldName())).willReturn(messagesEntityList);
// when
stateChangeService.changeState(stateChangeContext);
// then
verify(stateChangeEntity, never()).setField(TOUCHED_FIELD, true);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class MessagesUtilTest method shouldHasFailureMessagesReturnTrue.
@Test
public final void shouldHasFailureMessagesReturnTrue() {
// given
List<Entity> messages = Lists.newArrayList();
messages.add(mockMessage(StateMessageType.FAILURE, "test"));
EntityList messagesEntityList = mockEntityList(messages);
// when
boolean result = MessagesUtil.hasFailureMessages(messagesEntityList);
// then
assertTrue(result);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class StateChangeTest method mockEntityList.
protected EntityList mockEntityList(final List<Entity> entities) {
final EntityList entityList = mock(EntityList.class);
given(entityList.iterator()).willAnswer(new Answer<Iterator<Entity>>() {
@Override
public Iterator<Entity> answer(final InvocationOnMock invocation) throws Throwable {
return ImmutableList.copyOf(entities).iterator();
}
});
given(entityList.isEmpty()).willReturn(entities.isEmpty());
return entityList;
}
Aggregations