Search in sources :

Example 76 with EntityList

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

Example 77 with EntityList

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());
}
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 78 with EntityList

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);
}
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 79 with EntityList

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

Example 80 with EntityList

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;
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) EntityList(com.qcadoo.model.api.EntityList) Iterator(java.util.Iterator)

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