Search in sources :

Example 21 with EntityTree

use of com.qcadoo.model.api.EntityTree in project mes by qcadoo.

the class NormServiceTest method shouldOmmitCheckingIfTheTreeIsntCompleteYet.

@Test
public void shouldOmmitCheckingIfTheTreeIsntCompleteYet() {
    // given
    EntityTree tree = mockEntityTreeIterator(new LinkedList<Entity>());
    given(technology.getTreeField("operationComponents")).willReturn(tree);
    // when
    List<String> messages = normService.checkOperationOutputQuantities(technology);
    // then
    assertTrue(messages.isEmpty());
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityTree(com.qcadoo.model.api.EntityTree) Test(org.junit.Test)

Example 22 with EntityTree

use of com.qcadoo.model.api.EntityTree in project mes by qcadoo.

the class NormServiceTest method shouldNotFreakOutIfItCantFindOutputProductForAnOperationComponent.

@Test
public void shouldNotFreakOutIfItCantFindOutputProductForAnOperationComponent() {
    // given
    EntityTree tree = mockEntityTreeIterator(asList(operComp1));
    given(technology.getTreeField("operationComponents")).willReturn(tree);
    given(technologyService.getProductCountForOperationComponent(operComp1)).willThrow(new IllegalStateException());
    // when
    List<String> messages = normService.checkOperationOutputQuantities(technology);
    // then
    assertTrue(messages.isEmpty());
}
Also used : EntityTree(com.qcadoo.model.api.EntityTree) Test(org.junit.Test)

Example 23 with EntityTree

use of com.qcadoo.model.api.EntityTree in project mes by qcadoo.

the class NormServiceTest method shouldReturnNoErrorsIfTheQuantitiesDoMatch.

@Ignore
@Test
public void shouldReturnNoErrorsIfTheQuantitiesDoMatch() {
    // given
    EntityTree tree = mockEntityTreeIterator(asList(operComp1));
    given(technology.getTreeField("operationComponents")).willReturn(tree);
    given(technologyService.getProductCountForOperationComponent(operComp1)).willReturn(new BigDecimal(13.5));
    given(operComp1.getDecimalField("productionInOneCycle")).willReturn(new BigDecimal(13.500));
    // when
    List<String> messages = normService.checkOperationOutputQuantities(technology);
    // then
    assertEquals(0, messages.size());
}
Also used : EntityTree(com.qcadoo.model.api.EntityTree) BigDecimal(java.math.BigDecimal) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with EntityTree

use of com.qcadoo.model.api.EntityTree in project mes by qcadoo.

the class WorkPlansColumnFillerTest method mockEntityTree.

private EntityTree mockEntityTree(List<Entity> list) {
    EntityTree entityTree = mock(EntityTree.class);
    when(entityTree.iterator()).thenReturn(list.iterator());
    return entityTree;
}
Also used : EntityTree(com.qcadoo.model.api.EntityTree)

Example 25 with EntityTree

use of com.qcadoo.model.api.EntityTree in project mes by qcadoo.

the class WorkPlansColumnFillerTest method shouldReturnCorrectColumnValuesForProducts.

@Test
public void shouldReturnCorrectColumnValuesForProducts() {
    // given
    EntityTree operComps = mockEntityTree(asList(operationComponent));
    EntityTree operComps2 = mockEntityTree(asList(operationComponent));
    given(technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS)).willReturn(operComps, operComps2);
    given(operationComponent.getId()).willReturn(1L);
    EntityList prodInComps = mockEntityList(asList(operationProductComponent));
    EntityList prodInComps2 = mockEntityList(asList(operationProductComponent));
    given(operationProductComponent.getBelongsToField("operationComponent")).willReturn(operationComponent);
    given(operationProductComponent.getBelongsToField(L_PRODUCT)).willReturn(product);
    given(operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS)).willReturn(prodInComps, prodInComps2);
    EntityList prodOutComps = mockEntityList(new ArrayList<Entity>());
    given(operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS)).willReturn(prodOutComps);
    given(operationProductComponent.getDataDefinition()).willReturn(operationProductComponentDD);
    given(operationProductComponentDD.getName()).willReturn(TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT);
    OperationProductComponentWithQuantityContainer quantities = new OperationProductComponentWithQuantityContainer();
    quantities.put(operationProductComponent, new BigDecimal(11));
    given(productQuantitiesService.getProductComponentQuantities(order)).willReturn(quantities);
    // when
    Map<Entity, Map<String, String>> columnValues = workPlansColumnFiller.getValues(asList(order));
    // then
    assertEquals(1, columnValues.size());
    assertEquals("product (123)", columnValues.get(operationProductComponent).get(L_PRODUCT_NAME));
    assertEquals("11.00000 abc", columnValues.get(operationProductComponent).get(L_PLANNED_QUANTITY));
}
Also used : Entity(com.qcadoo.model.api.Entity) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) EntityList(com.qcadoo.model.api.EntityList) EntityTree(com.qcadoo.model.api.EntityTree) Map(java.util.Map) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

EntityTree (com.qcadoo.model.api.EntityTree)52 Entity (com.qcadoo.model.api.Entity)44 Test (org.junit.Test)14 DataDefinition (com.qcadoo.model.api.DataDefinition)10 FormComponent (com.qcadoo.view.api.components.FormComponent)10 BigDecimal (java.math.BigDecimal)8 Map (java.util.Map)7 EntityList (com.qcadoo.model.api.EntityList)6 List (java.util.List)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Service (org.springframework.stereotype.Service)6 EntityTreeNode (com.qcadoo.model.api.EntityTreeNode)5 WindowComponent (com.qcadoo.view.api.components.WindowComponent)4 Set (java.util.Set)4 Sets (com.google.common.collect.Sets)3 ProductQuantitiesService (com.qcadoo.mes.technologies.ProductQuantitiesService)3 Date (java.util.Date)3 Locale (java.util.Locale)3 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2