Search in sources :

Example 51 with EntityList

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

Example 52 with EntityList

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) HashMap(java.util.HashMap) EntityList(com.qcadoo.model.api.EntityList) DataDefinition(com.qcadoo.model.api.DataDefinition) BigDecimal(java.math.BigDecimal) Before(org.junit.Before)

Example 53 with EntityList

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

Example 54 with EntityList

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

Example 55 with EntityList

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

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