Search in sources :

Example 1 with EntityTreeNode

use of com.qcadoo.model.api.EntityTreeNode in project qcadoo by qcadoo.

the class EntityTreeImplTest method shouldDelegateMethods.

@Test
public void shouldDelegateMethods() throws Exception {
    // given
    Entity entity = mock(Entity.class);
    given(entity.getStringField("entityType")).willReturn("entityType1");
    EntityTreeNode child = mock(EntityTreeNode.class);
    EntityTreeNodeImpl node = new EntityTreeNodeImpl(entity);
    node.addChild(child);
    // then
    assertEquals(1, node.getChildren().size());
    assertEquals(child, node.getChildren().get(0));
    assertEquals("entityType1", node.getEntityNoteType());
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityTreeNode(com.qcadoo.model.api.EntityTreeNode) Test(org.junit.Test)

Example 2 with EntityTreeNode

use of com.qcadoo.model.api.EntityTreeNode in project qcadoo by qcadoo.

the class TreeNumberingServiceTest method getTreeNodeMock.

private EntityTreeNode getTreeNodeMock(final Integer priority) {
    EntityTreeNode node = mock(EntityTreeNode.class);
    when(node.getField(PRIORITY)).thenReturn(priority);
    return node;
}
Also used : EntityTreeNode(com.qcadoo.model.api.EntityTreeNode)

Example 3 with EntityTreeNode

use of com.qcadoo.model.api.EntityTreeNode in project qcadoo by qcadoo.

the class TreeNumberingServiceTest method shouldGenerateNumberForEntityTreeNode.

@Test
public void shouldGenerateNumberForEntityTreeNode() throws Exception {
    // given
    EntityTreeNode node1 = getTreeNodeMock();
    when(rootNode.getChildren()).thenReturn(Lists.newArrayList(node1));
    ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
    // when
    treeNumberingService.generateTreeNumbers(rootNode);
    // then
    Mockito.verify(rootNode).setField(Mockito.eq(NODE_NUMBER_FIELD), argument.capture());
    assertEquals("1.", argument.getValue());
    Mockito.verify(node1).setField(Mockito.eq(NODE_NUMBER_FIELD), argument.capture());
    assertEquals("2.", argument.getValue());
}
Also used : EntityTreeNode(com.qcadoo.model.api.EntityTreeNode) Test(org.junit.Test)

Example 4 with EntityTreeNode

use of com.qcadoo.model.api.EntityTreeNode in project qcadoo by qcadoo.

the class TreeNumberingServiceTest method shouldNumberSequentialTree.

@Test
public void shouldNumberSequentialTree() throws Exception {
    // given
    EntityTreeNode node1 = getTreeNodeMock();
    EntityTreeNode node2 = getTreeNodeMock();
    EntityTreeNode node3 = getTreeNodeMock();
    when(rootNode.getChildren()).thenReturn(Lists.newArrayList(node1));
    when(node1.getChildren()).thenReturn(Lists.newArrayList(node2));
    when(node2.getChildren()).thenReturn(Lists.newArrayList(node3));
    ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
    // when
    treeNumberingService.generateTreeNumbers(tree);
    // then
    Mockito.verify(rootNode).setField(Mockito.eq(NODE_NUMBER_FIELD), argument.capture());
    assertEquals("1.", argument.getValue());
    Mockito.verify(node1).setField(Mockito.eq(NODE_NUMBER_FIELD), argument.capture());
    assertEquals("2.", argument.getValue());
    Mockito.verify(node2).setField(Mockito.eq(NODE_NUMBER_FIELD), argument.capture());
    assertEquals("3.", argument.getValue());
    Mockito.verify(node3).setField(Mockito.eq(NODE_NUMBER_FIELD), argument.capture());
    assertEquals("4.", argument.getValue());
}
Also used : EntityTreeNode(com.qcadoo.model.api.EntityTreeNode) Test(org.junit.Test)

Example 5 with EntityTreeNode

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

the class TechnologyTreeValidationServiceImplTest method shouldReturnEmptyMapIfParentOpNotConsumeManyOutputsFromOneSubOp.

@Test
public final void shouldReturnEmptyMapIfParentOpNotConsumeManyOutputsFromOneSubOp() {
    // given
    Entity product1 = mockProductComponent(1L);
    Entity product2 = mockProductComponent(2L);
    Entity product3 = mockProductComponent(3L);
    Entity product4 = mockProductComponent(4L);
    Entity product5 = mockProductComponent(5L);
    Entity product6 = mockProductComponent(6L);
    EntityTreeNode node2B = mockOperationComponent("2.B.", newArrayList(product6), newArrayList(product4));
    EntityTreeNode node2A = mockOperationComponent("2.A.", newArrayList(product5), newArrayList(product3));
    EntityTreeNode node2 = mockOperationComponent("2.", newArrayList(product3, product4), newArrayList(product2), newArrayList(node2A, node2B));
    EntityTreeNode node1 = mockOperationComponent("1.", newArrayList(product2), newArrayList(product1), newArrayList(node2));
    given(tree.getRoot()).willReturn(node1);
    // when
    resultMap = technologyTreeValidationService.checkConsumingManyProductsFromOneSubOp(tree);
    // then
    assertNotNull(resultMap);
    assertTrue(resultMap.isEmpty());
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityTreeNode(com.qcadoo.model.api.EntityTreeNode) Test(org.junit.Test)

Aggregations

EntityTreeNode (com.qcadoo.model.api.EntityTreeNode)24 Entity (com.qcadoo.model.api.Entity)11 Test (org.junit.Test)10 Set (java.util.Set)4 EntityTree (com.qcadoo.model.api.EntityTree)3 EntityList (com.qcadoo.model.api.EntityList)2 OperationTimes (com.qcadoo.mes.operationTimeCalculations.dto.OperationTimes)1 BigDecimal (java.math.BigDecimal)1 MathContext (java.math.MathContext)1 ArrayList (java.util.ArrayList)1