use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class OperationWorkTimeServiceTest method shouldEstimateTotalOrderTimeWithTpzAndAdditionalTime.
@Test
public void shouldEstimateTotalOrderTimeWithTpzAndAdditionalTime() throws Exception {
// given
EntityList operationComponents = mockEntityList(Arrays.asList(operComp1, operComp2, operComp3));
// when
operationWorkTime = operationWorkTimeService.estimateTotalWorkTime(operationComponents, operationRuns, true, true, false);
// then
assertEquals(operationWorkTime.getLaborWorkTime(), new Integer(9750));
assertEquals(operationWorkTime.getMachineWorkTime(), new Integer(5130));
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class OrderRealizationTimeServiceImplTest method init.
@Before
public void init() {
MockitoAnnotations.initMocks(this);
orderRealizationTimeServiceImpl = new OrderRealizationTimeServiceImpl();
when(opComp1.getStringField("nextOperationAfterProducedType")).thenReturn("01all");
when(opComp2.getStringField("nextOperationAfterProducedType")).thenReturn("01all");
when(opComp1.getField("tj")).thenReturn(1);
when(opComp2.getField("tj")).thenReturn(1);
when(opComp1.getField("nextOperationAfterProducedQuantity")).thenReturn(new BigDecimal(1));
when(opComp2.getField("nextOperationAfterProducedQuantity")).thenReturn(new BigDecimal(1));
when(opComp1.getField("tpz")).thenReturn(1);
when(opComp2.getField("tpz")).thenReturn(1);
when(opComp1.getField("timeNextOperation")).thenReturn(1);
when(opComp2.getField("timeNextOperation")).thenReturn(1);
when(opComp2.getBelongsToField("parent")).thenReturn(opComp1);
EntityList opComp1Children = mockEntityListIterator(Collections.singletonList(opComp2));
when(opComp1.getHasManyField("children")).thenReturn(opComp1Children);
EntityList opComp2Children = mockEntityListIterator(new LinkedList<>());
when(opComp2.getHasManyField("children")).thenReturn(opComp2Children);
Map<Entity, BigDecimal> operationRuns = new HashMap<>();
operationRuns.put(opComp1, new BigDecimal(2));
operationRuns.put(opComp2, new BigDecimal(4));
DataDefinition dd = mock(DataDefinition.class);
when(dd.getName()).thenReturn("technologyOperationComponent");
when(opComp1.getDataDefinition()).thenReturn(dd);
when(opComp2.getDataDefinition()).thenReturn(dd);
given(opComp1.getId()).willReturn(1L);
given(opComp2.getId()).willReturn(2L);
given(dd.get(1L)).willReturn(opComp1);
given(dd.get(2L)).willReturn(opComp2);
ReflectionTestUtils.setField(orderRealizationTimeServiceImpl, "operationRunsField", operationRuns);
ReflectionTestUtils.setField(orderRealizationTimeServiceImpl, "productQuantitiesService", productQuantitiesService);
ReflectionTestUtils.setField(orderRealizationTimeServiceImpl, "numberService", numberService);
ReflectionTestUtils.setField(orderRealizationTimeServiceImpl, "productionLinesService", productionLinesService);
mathContext = MathContext.DECIMAL64;
when(numberService.getMathContext()).thenReturn(mathContext);
when(productionLinesService.getWorkstationTypesCount(opComp1, productionLine)).thenReturn(1);
when(productionLinesService.getWorkstationTypesCount(opComp2, productionLine)).thenReturn(1);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class AdvancedGenealogyTreeServiceTest method shouldReturnOnlyTheRootIfThereAreNoRelatedBatchesForProducedFromTree.
@Test
public void shouldReturnOnlyTheRootIfThereAreNoRelatedBatchesForProducedFromTree() {
// given
Entity batch = mock(Entity.class);
when(batch.getBelongsToField("product")).thenReturn(product1);
when(product1.getStringField("name")).thenReturn(productName1);
when(product1.getStringField("number")).thenReturn(productNumber1);
EntityList trackingRecords = mockEntityList(new LinkedList<Entity>());
when(batch.getHasManyField("trackingRecords")).thenReturn(trackingRecords);
// when
List<Entity> tree = treeService.getProducedFromTree(batch, true, false);
// then
assertEquals(1, tree.size());
assertEquals(batch, tree.get(0));
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class AdvancedGenealogyTreeServiceTest method shouldReturnCorrectUsedToProduceTreeForOrders.
@Test
@Ignore
public void shouldReturnCorrectUsedToProduceTreeForOrders() {
// given
Plugin plugin = mock(Plugin.class);
when(pluginAccessor.getPlugin("advancedGenealogyForOrders")).thenReturn(plugin);
when(batch1Tr.getStringField("entityType")).thenReturn(TrackingRecordType.FOR_ORDER);
Entity genProdInComp = mock(Entity.class);
EntityList genProdInComps = mockEntityList(asList(genProdInComp));
Entity prodInBatch = mock(Entity.class);
when(prodInBatch.getBelongsToField("batch")).thenReturn(batch2);
EntityList prodInBatches = mockEntityList(asList(prodInBatch));
when(genProdInComp.getHasManyField("productInBatches")).thenReturn(prodInBatches);
when(batch1Tr.getHasManyField("genealogyProductInComponents")).thenReturn(genProdInComps);
// when
List<Entity> tree = treeService.getUsedToProduceTree(batch2, true, false);
// then
assertEquals(2, tree.size());
assertEquals(batch2, tree.get(0));
assertEquals(batch1, tree.get(1));
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class AdvancedGenealogyTreeServiceTest method shouldReturnCorrectProducedFromTreeForOrders.
@Test
@Ignore
public void shouldReturnCorrectProducedFromTreeForOrders() {
// given
Plugin plugin = mock(Plugin.class);
when(pluginAccessor.getPlugin("advancedGenealogyForOrders")).thenReturn(plugin);
when(batch1Tr.getStringField("entityType")).thenReturn(TrackingRecordType.FOR_ORDER);
Entity genProdInComp = mock(Entity.class);
EntityList genProdInComps = mockEntityList(asList(genProdInComp));
Entity prodInBatch = mock(Entity.class);
when(prodInBatch.getBelongsToField("batch")).thenReturn(batch2);
EntityList prodInBatches = mockEntityList(asList(prodInBatch));
when(genProdInComp.getHasManyField("productInBatches")).thenReturn(prodInBatches);
when(batch1Tr.getHasManyField("genealogyProductInComponents")).thenReturn(genProdInComps);
// when
List<Entity> tree = treeService.getProducedFromTree(batch1, true, false);
// then
assertEquals(2, tree.size());
assertEquals(batch1, tree.get(0));
assertEquals(batch2, tree.get(1));
}
Aggregations