use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class AbstractStateChangeAspectTest method shouldNotFireChangeStateIfStateChangeHaveErrorMessages.
@Test
public final void shouldNotFireChangeStateIfStateChangeHaveErrorMessages() {
// 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(ownerEntity, never()).setField(Mockito.eq(STATE_FIELD_NAME), Mockito.any());
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class MrpAlgorithmStrategyTSTest method init.
@Before
public void init() {
algorithmStrategyTS = new MrpAlgorithmStrategyTS();
MockitoAnnotations.initMocks(this);
ReflectionTestUtils.setField(algorithmStrategyTS, "productQuantitiesService", productQuantitiesService);
EntityList opComp1InComp = mockEntityListIterator(asList(productInComponent1, productInComponent3));
EntityList opComp1OutComp = mockEntityListIterator(asList(productOutComponent2));
EntityList opComp2InComp = mockEntityListIterator(asList(productInComponent2));
EntityList opComp2OutComp = mockEntityListIterator(asList(productOutComponent4));
when(operComp1.getHasManyField("operationProductInComponents")).thenReturn(opComp1InComp);
when(operComp1.getHasManyField("operationProductOutComponents")).thenReturn(opComp1OutComp);
when(operComp2.getHasManyField("operationProductInComponents")).thenReturn(opComp2InComp);
when(operComp2.getHasManyField("operationProductOutComponents")).thenReturn(opComp2OutComp);
when(productInComponent1.getField("quantity")).thenReturn(new BigDecimal(5));
when(productInComponent3.getField("quantity")).thenReturn(BigDecimal.ONE);
when(productOutComponent2.getField("quantity")).thenReturn(BigDecimal.ONE);
when(productInComponent2.getField("quantity")).thenReturn(new BigDecimal(2));
when(productOutComponent4.getField("quantity")).thenReturn(BigDecimal.ONE);
productComponentQuantities = new OperationProductComponentWithQuantityContainer();
nonComponents = Sets.newHashSet();
productComponentQuantities.put(productInComponent1, new BigDecimal(5));
productComponentQuantities.put(productInComponent3, BigDecimal.ONE);
productComponentQuantities.put(productOutComponent2, BigDecimal.ONE);
productComponentQuantities.put(productOutComponent4, BigDecimal.ONE);
productComponentQuantities.put(productInComponent2, new BigDecimal(2));
nonComponents.add(new OperationProductComponentHolder(productInComponent2));
when(product1.getId()).thenReturn(1L);
when(product2.getId()).thenReturn(2L);
when(product3.getId()).thenReturn(3L);
when(product4.getId()).thenReturn(4L);
when(productInComponent1.getBelongsToField("product")).thenReturn(product1);
when(productInComponent2.getBelongsToField("product")).thenReturn(product2);
when(productInComponent3.getBelongsToField("product")).thenReturn(product3);
when(productOutComponent2.getBelongsToField("product")).thenReturn(product2);
when(productOutComponent4.getBelongsToField("product")).thenReturn(product4);
when(productInComponent1.getBelongsToField("operationComponent")).thenReturn(operComp1);
when(productInComponent3.getBelongsToField("operationComponent")).thenReturn(operComp1);
when(productOutComponent2.getBelongsToField("operationComponent")).thenReturn(operComp1);
when(productInComponent2.getBelongsToField("operationComponent")).thenReturn(operComp2);
when(productOutComponent4.getBelongsToField("operationComponent")).thenReturn(operComp2);
when(ddIn.getName()).thenReturn("productInComponent");
when(ddOut.getName()).thenReturn("productOutComponent");
when(productInComponent1.getDataDefinition()).thenReturn(ddIn);
when(productInComponent2.getDataDefinition()).thenReturn(ddIn);
when(productInComponent3.getDataDefinition()).thenReturn(ddIn);
when(productOutComponent2.getDataDefinition()).thenReturn(ddOut);
when(productOutComponent4.getDataDefinition()).thenReturn(ddOut);
when(ddIn.getName()).thenReturn("operationProductInComponent");
when(ddOut.getName()).thenReturn("operationProductOutComponent");
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class TechnologyTreeValidationServiceImplTest method mockOperationComponent.
private EntityTreeNode mockOperationComponent(final Long id, final String nodeNumber, final Collection<Entity> inputProducts, final Collection<Entity> outputProducts, final List<EntityTreeNode> subOperations) {
EntityTreeNode operationComponent = mock(EntityTreeNode.class);
given(operationComponent.getId()).willReturn(id);
EntityList inputProductsList = mockProductComponentsList(inputProducts);
given(operationComponent.getHasManyField(OPERATION_PRODUCT_IN_COMPONENTS)).willReturn(inputProductsList);
given(operationComponent.getField(OPERATION_PRODUCT_IN_COMPONENTS)).willReturn(inputProductsList);
EntityList outputProductsList = mockProductComponentsList(outputProducts);
given(operationComponent.getHasManyField(OPERATION_PRODUCT_OUT_COMPONENTS)).willReturn(outputProductsList);
given(operationComponent.getField(OPERATION_PRODUCT_OUT_COMPONENTS)).willReturn(outputProductsList);
given(operationComponent.getField(NODE_NUMBER)).willReturn(nodeNumber);
given(operationComponent.getStringField(NODE_NUMBER)).willReturn(nodeNumber);
given(operationComponent.getChildren()).willReturn(subOperations);
return operationComponent;
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class WorkstationCriteriaModifiersTNFO method filterByTOC.
public void filterByTOC(final SearchCriteriaBuilder scb, final FilterValueHolder filterValueHolder) {
Long technologyOperationComponentId = filterValueHolder.getLong(TECHNOLOGY_OPERATION_COMPONENT_ID);
EntityList workstations = getTOCDD().get(technologyOperationComponentId).getHasManyField(TechnologyOperationComponentFields.WORKSTATIONS);
if (!workstations.isEmpty()) {
Set<Long> workstationIds = workstations.stream().map(Entity::getId).collect(Collectors.toSet());
scb.add(SearchRestrictions.in("id", workstationIds));
SearchCriteriaBuilder subCriteria = getTOCDD().findWithAlias(TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).add(SearchRestrictions.idEq(technologyOperationComponentId)).createAlias(TechnologyOperationComponentFieldsTNFO.TECH_OPER_COMP_WORKSTATION_TIMES, TechnologyOperationComponentFieldsTNFO.TECH_OPER_COMP_WORKSTATION_TIMES, JoinType.INNER).createAlias(TechnologyOperationComponentFieldsTNFO.TECH_OPER_COMP_WORKSTATION_TIMES + L_DOT + TechOperCompWorkstationTimeFields.WORKSTATION, TechOperCompWorkstationTimeFields.WORKSTATION, JoinType.INNER).add(SearchRestrictions.eqField(TechOperCompWorkstationTimeFields.WORKSTATION + L_DOT + L_ID, L_THIS_ID)).setProjection(SearchProjections.id());
if (filterValueHolder.has(L_WORKSTATION_ID)) {
scb.add(SearchRestrictions.or(SearchSubqueries.notExists(subCriteria), SearchRestrictions.idEq(filterValueHolder.getLong(L_WORKSTATION_ID))));
} else {
scb.add(SearchSubqueries.notExists(subCriteria));
}
} else {
scb.add(SearchRestrictions.idEq(-1));
}
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class WorkstationCriteriaModifiersTNFO method filterByOperation.
public void filterByOperation(final SearchCriteriaBuilder scb, final FilterValueHolder filterValueHolder) {
Long operationId = filterValueHolder.getLong(L_OPERATION_ID);
EntityList workstations = getOperationDD().get(operationId).getHasManyField(OperationFields.WORKSTATIONS);
if (!workstations.isEmpty()) {
Set<Long> workstationIds = workstations.stream().map(Entity::getId).collect(Collectors.toSet());
scb.add(SearchRestrictions.in("id", workstationIds));
SearchCriteriaBuilder subCriteria = getOperationDD().findWithAlias(TechnologiesConstants.MODEL_OPERATION).add(SearchRestrictions.idEq(operationId)).createAlias(OperationFieldsTFNO.OPERATION_WORKSTATION_TIMES, OperationFieldsTFNO.OPERATION_WORKSTATION_TIMES, JoinType.INNER).createAlias(OperationFieldsTFNO.OPERATION_WORKSTATION_TIMES + L_DOT + OperationWorkstationTimeFields.WORKSTATION, OperationWorkstationTimeFields.WORKSTATION, JoinType.INNER).add(SearchRestrictions.eqField(OperationWorkstationTimeFields.WORKSTATION + L_DOT + L_ID, L_THIS_ID)).setProjection(SearchProjections.id());
if (filterValueHolder.has(L_WORKSTATION_ID)) {
scb.add(SearchRestrictions.or(SearchSubqueries.notExists(subCriteria), SearchRestrictions.idEq(filterValueHolder.getLong(L_WORKSTATION_ID))));
} else {
scb.add(SearchSubqueries.notExists(subCriteria));
}
} else {
scb.add(SearchRestrictions.idEq(-1));
}
}
Aggregations