Search in sources :

Example 16 with EntityList

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);
}
Also used : EntityList(com.qcadoo.model.api.EntityList) Test(org.junit.Test) StateChangeTest(com.qcadoo.mes.states.StateChangeTest)

Example 17 with EntityList

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList) StateChangeTest(com.qcadoo.mes.states.StateChangeTest) Test(org.junit.Test)

Example 18 with EntityList

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList) Test(org.junit.Test)

Example 19 with EntityList

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList) Test(org.junit.Test)

Example 20 with EntityList

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;
}
Also used : EntityList(com.qcadoo.model.api.EntityList)

Aggregations

EntityList (com.qcadoo.model.api.EntityList)103 Entity (com.qcadoo.model.api.Entity)52 Test (org.junit.Test)27 DataDefinition (com.qcadoo.model.api.DataDefinition)16 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)16 Before (org.junit.Before)11 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)10 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)10 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)10 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)10 SecurityService (com.qcadoo.security.api.SecurityService)10 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)10 Objects (java.util.Objects)10 Set (java.util.Set)10 Collectors (java.util.stream.Collectors)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 Service (org.springframework.stereotype.Service)10 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)9 BigDecimal (java.math.BigDecimal)9 StateChangeTest (com.qcadoo.mes.states.StateChangeTest)5