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());
}
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());
}
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());
}
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;
}
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));
}
Aggregations