@Test @Transactional @Ignore("FIXME pending review after rename to libreplan") public void testRemove() { Order order = createValidOrder(); orderModel.setPlanningState(createPlanningStateFor(order)); orderModel.save(); assertTrue(orderDAO.exists(order.getId())); orderModel.remove(order); assertFalse(orderDAO.exists(order.getId())); }
private Order givenValidOrderWithValidOrderLinesAlreadyStored() { Order order = givenOrder(); jiraOrderElementSynchronizer.syncOrderElementsWithJiraIssues(issues, order); order.dontPoseAsTransientObjectAnymore(); orderDAO.saveWithoutValidating(order); orderDAO.flush(); try { return orderDAO.find(order.getId()); } catch (InstanceNotFoundException e) { return null; } }
@Test @Transactional public void invalidSubcontractedTaskDataWithoutOrderElement() { int previous = orderDAO.getOrders().size(); ExternalCompany externalCompany = getClientExternalCompanySaved("Company", "company-nif"); SubcontractedTaskDataDTO subcontractedTaskDataDTO = new SubcontractedTaskDataDTO(); subcontractedTaskDataDTO.externalCompanyNif = externalCompany.getNif(); List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = subcontractService.subcontract(subcontractedTaskDataDTO).instanceConstraintViolationsList; assertThat(instanceConstraintViolationsList.size(), equalTo(1)); assertThat(orderDAO.getOrders().size(), equalTo(previous)); }
@Test @Transactional @Ignore("FIXME pending review after rename to libreplan") public void testCreationUsingPrepareForCreate() { Order order = givenOrderFromPrepareForCreate(); orderModel.save(); assertTrue(orderDAO.exists(order.getId())); }
private Order givenValidOrderAlreadyStored() { Order order = Order.create(); order.setCode(UUID.randomUUID().toString()); order.setName("Order name " + UUID.randomUUID()); order.setInitDate(new Date()); order.setCalendar(configurationDAO.getConfiguration().getDefaultCalendar()); OrderVersion version = setupVersionUsing(scenarioManager, order); order.useSchedulingDataFor(version); orderDAO.save(order); orderDAO.flush(); try { return orderDAO.find(order.getId()); } catch (InstanceNotFoundException e) { return null; } }
@Test @Transactional @Ignore("FIXME pending review after rename to libreplan") public void testFind() throws InstanceNotFoundException { Order order = createValidOrder(); orderModel.setPlanningState(createPlanningStateFor(order)); orderModel.save(); assertThat(orderDAO.find(order.getId()), notNullValue()); }
@Test @Transactional public void invalidSubcontractedTaskDataWithoutExternalCompanyNif() { int previous = orderDAO.getOrders().size(); String orderLineCode = "order-line-code"; OrderElementDTO orderElementDTO = givenBasicOrderLineDTO(orderLineCode); SubcontractedTaskDataDTO subcontractedTaskDataDTO = new SubcontractedTaskDataDTO(); subcontractedTaskDataDTO.orderElementDTO = orderElementDTO; List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = subcontractService.subcontract(subcontractedTaskDataDTO).instanceConstraintViolationsList; assertThat(instanceConstraintViolationsList.size(), equalTo(1)); assertThat(orderDAO.getOrders().size(), equalTo(previous)); }
@Test @Transactional @Ignore("FIXME pending review after rename to libreplan") public void testCreation() throws ValidationException { Order order = createValidOrder(); order.setCustomer(createValidExternalCompany()); orderModel.setPlanningState(createPlanningStateFor(order)); orderModel.save(); assertTrue(orderDAO.exists(order.getId())); }
@Test @Transactional public void validSubcontractedTaskData() { int previous = orderDAO.getOrders().size(); String orderLineCode = "order-line-code"; OrderElementDTO orderElementDTO = givenBasicOrderLineDTO(orderLineCode); ExternalCompany externalCompany = getClientExternalCompanySaved("Company", "company-nif"); SubcontractedTaskDataDTO subcontractedTaskDataDTO = new SubcontractedTaskDataDTO(); subcontractedTaskDataDTO.orderElementDTO = orderElementDTO; subcontractedTaskDataDTO.externalCompanyNif = externalCompany.getNif(); String orderName = "Work description"; String orderCustomerReference = "client-reference-code"; BigDecimal orderBudget = new BigDecimal(1000).setScale(2); subcontractedTaskDataDTO.workDescription = orderName; subcontractedTaskDataDTO.subcontractedCode = orderCustomerReference; subcontractedTaskDataDTO.subcontractPrice = orderBudget; List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = subcontractService.subcontract(subcontractedTaskDataDTO).instanceConstraintViolationsList; assertThat(instanceConstraintViolationsList.size(), equalTo(0)); assertThat(orderDAO.getOrders().size(), equalTo(previous + 1)); Order order = orderDAO.getOrders().get(previous); assertNotNull(order.getCode()); assertTrue(order.isCodeAutogenerated()); assertNotNull(order.getExternalCode()); assertThat(order.getExternalCode(), equalTo(orderLineCode)); assertThat(order.getState(), equalTo(OrderStatusEnum.OUTSOURCED)); assertThat(order.getWorkHours(), equalTo(0)); assertThat(order.getCustomer().getId(), equalTo(externalCompany.getId())); assertThat(order.getName(), equalTo(orderName)); assertThat(order.getCustomerReference(), equalTo(orderCustomerReference)); assertThat(order.getTotalManualBudget(), equalTo(orderBudget)); List<OrderElement> children = order.getChildren(); assertThat(children.size(), equalTo(1)); assertNull(children.get(0).getExternalCode()); }
@Test @Transactional @Ignore("FIXME pending review after rename to libreplan") public void createOrderWithScheduledOrderLine() { Order order = givenOrderFromPrepareForCreate(); OrderElement line = OrderLine.createOrderLineWithUnfixedPercentage(20); order.add(line); line.setName(UUID.randomUUID().toString()); line.setCode(UUID.randomUUID().toString()); assert line.getSchedulingState().isSomewhatScheduled(); orderModel.save(); assertTrue(orderDAO.exists(order.getId())); TaskSource lineTaskSource = line.getTaskSource(); assertTrue(taskSourceDAO.exists(lineTaskSource.getId())); }
public void reattach() { for (OrderElement each : orderElements) { orderElementDAO.reattach(each); (orderDAO.loadOrderAvoidingProxyFor(each)).getName(); } }
private void initialize(OrderElement orderElement) { orderElement.getName(); (orderDAO.loadOrderAvoidingProxyFor(orderElement)).getName(); }