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