target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void shouldAddMachineTimeBalanceAndLaborTimeBalanceIfTypeIsHourlyAndForEach() throws Exception { String typeOfProductionRecording = TypeOfProductionRecording.FOR_EACH.getStringValue(); String calculateOperationCostMode = CalculateOperationCostMode.HOURLY.getStringValue(); given(order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)).willReturn(typeOfProductionRecording); given(productionBalance.getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE)).willReturn( calculateOperationCostMode); given(productionCountingService.isTypeOfProductionRecordingForEach(typeOfProductionRecording)).willReturn(true); given(productionCountingService.isCalculateOperationCostModeHourly(calculateOperationCostMode)).willReturn(true); productionBalanceWithCostsPdfService.buildPdfContent(document, productionBalance, locale); verify(productionBalancePdfService).addMachineTimeBalance(document, productionBalance, locale); verify(productionBalancePdfService).addLaborTimeBalance(document, productionBalance, locale); } | @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } PdfPTable createParametersForCostsPanel(final Entity productionBalance, final Locale locale); @Override String getReportTitle(final Locale locale); } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } PdfPTable createParametersForCostsPanel(final Entity productionBalance, final Locale locale); @Override String getReportTitle(final Locale locale); } |
@Test public void shouldCallProductAndOperationNormsPrintingMethodNoMatterWhatIncludingrHourlyAndForEachType() throws Exception { String typeOfProductionRecording = TypeOfProductionRecording.FOR_EACH.getStringValue(); String calculateOperationCostMode = CalculateOperationCostMode.HOURLY.getStringValue(); given(order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)).willReturn(typeOfProductionRecording); given(productionBalance.getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE)).willReturn( calculateOperationCostMode); given(productionCountingService.isTypeOfProductionRecordingForEach(typeOfProductionRecording)).willReturn(true); given(productionCountingService.isCalculateOperationCostModeHourly(calculateOperationCostMode)).willReturn(true); productionBalanceWithCostsPdfService.buildPdfContent(document, productionBalance, locale); verify(costCalculationPdfService).printMaterialAndOperationNorms(document, productionBalance, locale); } | @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } PdfPTable createParametersForCostsPanel(final Entity productionBalance, final Locale locale); @Override String getReportTitle(final Locale locale); } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } PdfPTable createParametersForCostsPanel(final Entity productionBalance, final Locale locale); @Override String getReportTitle(final Locale locale); } |
@Test public void shouldCallProductAndOperationNormsPrintingMethodNoMatterWhatIncludingPieceworkAndCumulatedType() throws Exception { given(productionBalance.getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE)).willReturn( CalculateOperationCostMode.PIECEWORK.getStringValue()); given(order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)).willReturn( TypeOfProductionRecording.CUMULATED.getStringValue()); productionBalanceWithCostsPdfService.buildPdfContent(document, productionBalance, locale); verify(costCalculationPdfService).printMaterialAndOperationNorms(document, productionBalance, locale); } | @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } PdfPTable createParametersForCostsPanel(final Entity productionBalance, final Locale locale); @Override String getReportTitle(final Locale locale); } | ProductionBalanceWithCostsPdfService extends PdfDocumentService { @Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale); String documentAuthor = translationService.translate("smartReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable topTable = pdfHelper.createPanelTable(2); topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale)); topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale)); topTable.setSpacingBefore(20); document.add(topTable); PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale); parametersForCostsPanel.setSpacingBefore(20); document.add(parametersForCostsPanel); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); final boolean isTypeOfProductionRecordingCumulated = productionCountingService .isTypeOfProductionRecordingCumulated(typeOfProductionRecording); final boolean isTypeOfProductionRecordingForEach = productionCountingService .isTypeOfProductionRecordingForEach(typeOfProductionRecording); final boolean isCalculateOperationCostModeHourly = productionCountingService .isCalculateOperationCostModeHourly(calculateOperationCostMode); final boolean isCalculateOperationCostModePiecework = productionCountingService .isCalculateOperationCostModePiecework(calculateOperationCostMode); if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) { PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(productionBalance, locale); assumptionForCumulatedRecordsPanel.setSpacingBefore(20); document.add(assumptionForCumulatedRecordsPanel); } PdfPTable bottomTable = pdfHelper.createPanelTable(2); bottomTable.addCell(createCostsPanel(productionBalance, locale)); bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale)); bottomTable.setSpacingBefore(20); bottomTable.setSpacingAfter(20); document.add(bottomTable); productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale); addMaterialCost(document, productionBalance, locale); productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale); if (isCalculateOperationCostModeHourly) { if (isTypeOfProductionRecordingCumulated) { productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale); addProductionCosts(document, productionBalance, locale); } else if (isTypeOfProductionRecordingForEach) { productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale); addCostsBalance("machine", document, productionBalance, locale); productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale); addCostsBalance("labor", document, productionBalance, locale); } } else if (isCalculateOperationCostModePiecework) { productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale); addCostsBalance("cycles", document, productionBalance, locale); } costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale); } PdfPTable createParametersForCostsPanel(final Entity productionBalance, final Locale locale); @Override String getReportTitle(final Locale locale); } |
@Test public void shouldntAddTechnologyGroupIfProductIsntSaved() { given(product.getId()).willReturn(null); String url = "../page/technologies/technologyGroupDetails.html"; productDetailsListenersT.addTechnologyGroup(view, null, null); verify(view, never()).redirectTo(url, false, true, parameters); } | public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } | ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } | ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } |
@Test public void shouldReturnWhenOperationIsNull() throws Exception { costNormsForOperationService.copyCostValuesFromOperation(view, state, null); } | public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } | CostNormsForOperationService { public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } } | CostNormsForOperationService { public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } } | CostNormsForOperationService { public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState,
final String[] args); void inheritOperationNormValues(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); void fillCurrencyFields(final ViewDefinitionState view); void copyCostNormsToTechnologyOperationComponent(final DataDefinition dd, final Entity technologyOperationComponent); } | CostNormsForOperationService { public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState,
final String[] args); void inheritOperationNormValues(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); void fillCurrencyFields(final ViewDefinitionState view); void copyCostNormsToTechnologyOperationComponent(final DataDefinition dd, final Entity technologyOperationComponent); } |
@Test public void shouldAddTechnologyGroupIfProductIsSaved() { given(product.getId()).willReturn(L_ID); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; productDetailsListenersT.addTechnologyGroup(view, null, null); verify(view).redirectTo(url, false, true, parameters); } | public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } | ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } | ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologyGroups"); String url = "../page/technologies/technologyGroupDetails.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } |
@Test public void shouldntShowTechnologiesWithTechnologyGroupIfProductIsntSaved() { given(product.getId()).willReturn(null); String url = "../page/technologies/technologiesList.html"; productDetailsListenersT.showTechnologiesWithTechnologyGroup(view, null, null); verify(view, never()).redirectTo(url, false, true, parameters); } | public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } |
@Test public void shouldntShowTechnologiesWithTechnologyGroupIfProductIsSavedAndTechnologyGroupIsNull() { given(product.getId()).willReturn(L_ID); given(product.getBelongsToField("technologyGroup")).willReturn(null); String url = "../page/technologies/technologiesList.html"; productDetailsListenersT.showTechnologiesWithTechnologyGroup(view, null, null); verify(view, never()).redirectTo(url, false, true, parameters); } | public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } |
@Test public void shouldShowTechnologiesWithTechnologyGroupIfProductIsSavedAndTechnologyGroupIsntNull() { given(product.getId()).willReturn(L_ID); given(product.getBelongsToField("technologyGroup")).willReturn(technologyGroup); given(technologyGroup.getStringField(NUMBER)).willReturn(L_TECHNOLOGY_GROUP_NUMBER); filters.put("technologyGroupNumber", L_TECHNOLOGY_GROUP_NUMBER); gridOptions.put(L_FILTERS, filters); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; productDetailsListenersT.showTechnologiesWithTechnologyGroup(view, null, null); verify(view).redirectTo(url, false, true, parameters); } | public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } | ProductDetailsListenersT { public final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { return; } String technologyGroupNumber = technologyGroup.getStringField(NUMBER); Map<String, String> filters = Maps.newHashMap(); filters.put("technologyGroupNumber", technologyGroupNumber); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } |
@Test public void shouldntShowTechnologiesWithProductIfProductIsntSaved() { given(product.getId()).willReturn(null); String url = "../page/technologies/technologiesList.html"; productDetailsListenersT.showTechnologiesWithProduct(view, null, null); verify(view, never()).redirectTo(url, false, true, parameters); } | public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } |
@Test public void shouldntShowTechnologiesWithProductIfProductIsntSavedAndProductNameIsNull() { given(product.getId()).willReturn(1L); given(product.getStringField(NAME)).willReturn(null); String url = "../page/technologies/technologiesList.html"; productDetailsListenersT.showTechnologiesWithProduct(view, null, null); verify(view, never()).redirectTo(url, false, true, parameters); } | public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } |
@Test public void shouldShowTechnologiesWithProductIfProductIsSavedAndProductNameIsntNull() { given(product.getId()).willReturn(L_ID); given(product.getStringField(NUMBER)).willReturn(L_PRODUCT_NUMBER); filters.put("productNumber", "["+ L_PRODUCT_NUMBER + "]"); gridOptions.put(L_FILTERS, filters); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; productDetailsListenersT.showTechnologiesWithProduct(view, null, null); verify(view).redirectTo(url, false, true, parameters); } | public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } | ProductDetailsListenersT { public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } String productNumber = product.getStringField(NUMBER); if (productNumber == null) { return; } Map<String, String> filters = Maps.newHashMap(); filters.put("productNumber", applyInOperator(productNumber)); Map<String, Object> gridOptions = Maps.newHashMap(); gridOptions.put(L_FILTERS, filters); Map<String, Object> parameters = Maps.newHashMap(); parameters.put(L_GRID_OPTIONS, gridOptions); parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies"); String url = "../page/technologies/technologiesList.html"; view.redirectTo(url, false, true, parameters); } final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args); final void showTechnologiesWithTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); final void showTechnologiesWithUsingProduct(final ViewDefinitionState view, final ComponentState state,
final String[] args); } |
@Test @Ignore public void shouldntUpdateRibbonStateIfProductIsntSaved() { given(product.getId()).willReturn(null); given(view.getComponentByReference("window")).willReturn((ComponentState) window); given(window.getRibbon()).willReturn(ribbon); given(ribbon.getGroupByName("technologies")).willReturn(technologies); given(technologies.getItemByName("showTechnologiesWithTechnologyGroup")).willReturn(showTechnologiesWithTechnologyGroup); given(technologies.getItemByName("showTechnologiesWithProduct")).willReturn(showTechnologiesWithProduct); productDetailsViewHooksT.updateRibbonState(view); verify(showTechnologiesWithTechnologyGroup).setEnabled(false); verify(showTechnologiesWithProduct).setEnabled(false); } | public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } void updateRibbonState(final ViewDefinitionState view); } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } void updateRibbonState(final ViewDefinitionState view); } |
@Test @Ignore public void shouldUpdateRibbonStateIfProductIsSavedAndTechnologyGroupIsNull() { given(product.getId()).willReturn(L_ID); given(product.getBelongsToField("technologyGroup")).willReturn(null); given(view.getComponentByReference("window")).willReturn((ComponentState) window); given(window.getRibbon()).willReturn(ribbon); given(ribbon.getGroupByName("technologies")).willReturn(technologies); given(technologies.getItemByName("showTechnologiesWithTechnologyGroup")).willReturn(showTechnologiesWithTechnologyGroup); given(technologies.getItemByName("showTechnologiesWithProduct")).willReturn(showTechnologiesWithProduct); productDetailsViewHooksT.updateRibbonState(view); verify(showTechnologiesWithTechnologyGroup).setEnabled(false); verify(showTechnologiesWithProduct).setEnabled(true); } | public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } void updateRibbonState(final ViewDefinitionState view); } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } void updateRibbonState(final ViewDefinitionState view); } |
@Ignore @Test public void shouldUpdateRibbonStateIfProductIsSavedAndTechnologyGroupIsntNull() { given(product.getId()).willReturn(L_ID); given(product.getBelongsToField("technologyGroup")).willReturn(technologyGroup); given(view.getComponentByReference("window")).willReturn((ComponentState) window); given(window.getRibbon()).willReturn(ribbon); given(ribbon.getGroupByName("technologies")).willReturn(technologies); given(technologies.getItemByName("showTechnologiesWithTechnologyGroup")).willReturn(showTechnologiesWithTechnologyGroup); given(technologies.getItemByName("showTechnologiesWithProduct")).willReturn(showTechnologiesWithProduct); productDetailsViewHooksT.updateRibbonState(view); verify(showTechnologiesWithTechnologyGroup).setEnabled(true); verify(showTechnologiesWithProduct).setEnabled(true); } | public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } void updateRibbonState(final ViewDefinitionState view); } | ProductDetailsViewHooksT { public void updateRibbonState(final ViewDefinitionState view) { Entity loggedUser = dataDefinitionService .get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER) .get(securityService.getCurrentUserId()); if (!securityService.hasRole(loggedUser, "ROLE_TECHNOLOGIES")) { view.getComponentByReference("technologyTab").setVisible(false); } FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup technologies = (RibbonGroup) window.getRibbon().getGroupByName("technologies"); RibbonActionItem showTechnologiesWithTechnologyGroup = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithTechnologyGroup"); RibbonActionItem showTechnologiesWithProduct = (RibbonActionItem) technologies .getItemByName("showTechnologiesWithProduct"); if (product.getId() != null) { Entity technologyGroup = product.getBelongsToField("technologyGroup"); if (technologyGroup == null) { updateButtonState(showTechnologiesWithTechnologyGroup, false); } else { updateButtonState(showTechnologiesWithTechnologyGroup, true); } updateButtonState(showTechnologiesWithProduct, true); return; } updateButtonState(showTechnologiesWithTechnologyGroup, false); updateButtonState(showTechnologiesWithProduct, false); } void updateRibbonState(final ViewDefinitionState view); } |
@Test public void shouldApplyCostNormsForGivenSource() throws Exception { when(state.getFieldValue()).thenReturn(1L); Long operationId = 1L; when(operationDD.get(operationId)).thenReturn(operationEntity); when(operationEntity.getField("pieceworkCost")).thenReturn(obj1); when(operationEntity.getField("numberOfOperations")).thenReturn(obj2); when(operationEntity.getField("laborHourlyCost")).thenReturn(obj3); when(operationEntity.getField("machineHourlyCost")).thenReturn(obj4); costNormsForOperationService.copyCostValuesFromOperation(view, state, null); Mockito.verify(field1).setFieldValue(obj1); Mockito.verify(field2).setFieldValue(obj2); Mockito.verify(field3).setFieldValue(obj3); Mockito.verify(field4).setFieldValue(obj4); } | public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } | CostNormsForOperationService { public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } } | CostNormsForOperationService { public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } } | CostNormsForOperationService { public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState,
final String[] args); void inheritOperationNormValues(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); void fillCurrencyFields(final ViewDefinitionState view); void copyCostNormsToTechnologyOperationComponent(final DataDefinition dd, final Entity technologyOperationComponent); } | CostNormsForOperationService { public void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState, final String[] args) { ComponentState operationLookup = view.getComponentByReference(OPERATION_FIELD); if (operationLookup.getFieldValue() == null) { if (!OPERATION_FIELD.equals(operationLookupState.getName())) { view.getComponentByReference("form").addMessage("costNormsForOperation.messages.info.missingOperationReference", INFO); } return; } Entity operation = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION).get((Long) operationLookup.getFieldValue()); applyCostNormsFromGivenSource(view, operation); } void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState,
final String[] args); void inheritOperationNormValues(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); void fillCurrencyFields(final ViewDefinitionState view); void copyCostNormsToTechnologyOperationComponent(final DataDefinition dd, final Entity technologyOperationComponent); } |
@Test public void shouldntAddTechnologyGroupToProductIfTechnologyGroupIsntSaved() { given(technologyGroup.getId()).willReturn(null); technologyGroupDetailsViewHooks.addTechnologyGroupToProduct(view, null, null); verify(product, never()).setField("technologyGroup", technologyGroup); verify(productDD, never()).save(product); } | public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); } |
@Test public void shouldntAddTechnologyGroupToProductIfTechnologyGroupIsSavedAndProductIsNull() { given(technologyGroup.getId()).willReturn(L_ID); given(product.getId()).willReturn(null); technologyGroupDetailsViewHooks.addTechnologyGroupToProduct(view, null, null); verify(product, never()).setField("technologyGroup", technologyGroup); verify(productDD, never()).save(product); } | public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); } |
@Test public void shouldAddTechnologyGroupToProductIfTechnologyGroupIsSavedAndProductIsntNull() { given(technologyGroup.getId()).willReturn(L_ID); given(product.getId()).willReturn(L_ID); given(product.getDataDefinition()).willReturn(productDD); given(dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT)).willReturn(productDD); given(productDD.get(L_ID)).willReturn(product); technologyGroupDetailsViewHooks.addTechnologyGroupToProduct(view, null, null); verify(product).setField("technologyGroup", technologyGroup); verify(productDD).save(product); } | public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); } | TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (technologyGroup.getId() == null) { return; } FormComponent productForm = (FormComponent) view.getComponentByReference("product"); Entity product = productForm.getEntity(); if (product.getId() == null) { return; } product = getProductFromDB(product.getId()); product.setField("technologyGroup", technologyGroup); product.getDataDefinition().save(product); } void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); } |
@Test public void shouldAddMessagesCorrectly() { String messageKey = "technologies.technology.validate.global.error.subOperationsProduceTheSameProductThatIsConsumed"; String parentNode = "1."; String productName = "name"; String productNumber = "abc123"; Long techId = 1L; given(technology.getStringField("state")).willReturn("02accepted"); given(technology.getId()).willReturn(techId); given(techDataDefinition.get(techId)).willReturn(technology); given(technology.getTreeField("operationComponents")).willReturn(tree); given(product.getStringField("name")).willReturn(productName); given(product.getStringField("number")).willReturn(productNumber); Map<String, Set<Entity>> nodesMap = Maps.newHashMap(); Set<Entity> productSet = Sets.newHashSet(); productSet.add(product); nodesMap.put("1.", productSet); given(technologyTreeValidationService.checkConsumingTheSameProductFromManySubOperations(tree)).willReturn(nodesMap); technologyTreeValidators.checkConsumingTheSameProductFromManySubOperations(techDataDefinition, technology, true); Mockito.verify(technology).addGlobalError(messageKey, true, parentNode, productName, productNumber); } | public boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology, final boolean autoCloseMessage) { Entity techFromDB = technologyDD.get(technology.getId()); EntityTree tree = techFromDB.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Map<String, Set<Entity>> nodesMap = technologyTreeValidationService .checkConsumingTheSameProductFromManySubOperations(tree); for (Entry<String, Set<Entity>> entry : nodesMap.entrySet()) { String parentNodeNumber = entry.getKey(); for (Entity product : entry.getValue()) { String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); technology.addGlobalError( "technologies.technology.validate.global.error.subOperationsProduceTheSameProductThatIsConsumed", autoCloseMessage, parentNodeNumber, productName, productNumber); } } return nodesMap.isEmpty(); } | TechnologyTreeValidators { public boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology, final boolean autoCloseMessage) { Entity techFromDB = technologyDD.get(technology.getId()); EntityTree tree = techFromDB.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Map<String, Set<Entity>> nodesMap = technologyTreeValidationService .checkConsumingTheSameProductFromManySubOperations(tree); for (Entry<String, Set<Entity>> entry : nodesMap.entrySet()) { String parentNodeNumber = entry.getKey(); for (Entity product : entry.getValue()) { String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); technology.addGlobalError( "technologies.technology.validate.global.error.subOperationsProduceTheSameProductThatIsConsumed", autoCloseMessage, parentNodeNumber, productName, productNumber); } } return nodesMap.isEmpty(); } } | TechnologyTreeValidators { public boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology, final boolean autoCloseMessage) { Entity techFromDB = technologyDD.get(technology.getId()); EntityTree tree = techFromDB.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Map<String, Set<Entity>> nodesMap = technologyTreeValidationService .checkConsumingTheSameProductFromManySubOperations(tree); for (Entry<String, Set<Entity>> entry : nodesMap.entrySet()) { String parentNodeNumber = entry.getKey(); for (Entity product : entry.getValue()) { String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); technology.addGlobalError( "technologies.technology.validate.global.error.subOperationsProduceTheSameProductThatIsConsumed", autoCloseMessage, parentNodeNumber, productName, productNumber); } } return nodesMap.isEmpty(); } } | TechnologyTreeValidators { public boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology, final boolean autoCloseMessage) { Entity techFromDB = technologyDD.get(technology.getId()); EntityTree tree = techFromDB.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Map<String, Set<Entity>> nodesMap = technologyTreeValidationService .checkConsumingTheSameProductFromManySubOperations(tree); for (Entry<String, Set<Entity>> entry : nodesMap.entrySet()) { String parentNodeNumber = entry.getKey(); for (Entity product : entry.getValue()) { String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); technology.addGlobalError( "technologies.technology.validate.global.error.subOperationsProduceTheSameProductThatIsConsumed", autoCloseMessage, parentNodeNumber, productName, productNumber); } } return nodesMap.isEmpty(); } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology, final boolean autoCloseMessage) { Entity techFromDB = technologyDD.get(technology.getId()); EntityTree tree = techFromDB.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Map<String, Set<Entity>> nodesMap = technologyTreeValidationService .checkConsumingTheSameProductFromManySubOperations(tree); for (Entry<String, Set<Entity>> entry : nodesMap.entrySet()) { String parentNodeNumber = entry.getKey(); for (Entity product : entry.getValue()) { String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); technology.addGlobalError( "technologies.technology.validate.global.error.subOperationsProduceTheSameProductThatIsConsumed", autoCloseMessage, parentNodeNumber, productName, productNumber); } } return nodesMap.isEmpty(); } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldInvalidateAlreadyAcceptedTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertFalse(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldInvalidateAlreadyAcceptedInactiveTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(technology.isActive()).willReturn(false); given(existingTechnology.isActive()).willReturn(false); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertFalse(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldInvalidateAlreadyAcceptedActiveTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(technology.isActive()).willReturn(true); given(existingTechnology.isActive()).willReturn(true); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertFalse(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateAcceptedTechnologyDuringEntityActivation() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(technology.isActive()).willReturn(true); given(existingTechnology.isActive()).willReturn(false); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateAcceptedTechnologyDuringEntityDeactivation() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(technology.isActive()).willReturn(false); given(existingTechnology.isActive()).willReturn(true); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateJustCreatedTechnology() { given(technology.getId()).willReturn(null); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public void shouldFillCurrencyFields() throws Exception { String currency = "PLN"; when(currencyService.getCurrencyAlphabeticCode()).thenReturn(currency); when(view.getComponentByReference("pieceworkCostCURRENCY")).thenReturn(field1); when(view.getComponentByReference("laborHourlyCostCURRENCY")).thenReturn(field2); when(view.getComponentByReference("machineHourlyCostCURRENCY")).thenReturn(field3); costNormsForOperationService.fillCurrencyFields(view); Mockito.verify(field1).setFieldValue(currency); Mockito.verify(field2).setFieldValue(currency); Mockito.verify(field3).setFieldValue(currency); } | public void fillCurrencyFields(final ViewDefinitionState view) { String currencyStringCode = currencyService.getCurrencyAlphabeticCode(); FieldComponent component = null; for (String componentReference : Sets.newHashSet("pieceworkCostCURRENCY", "laborHourlyCostCURRENCY", "machineHourlyCostCURRENCY")) { component = (FieldComponent) view.getComponentByReference(componentReference); if (component == null) { continue; } component.setFieldValue(currencyStringCode); component.requestComponentUpdateState(); } } | CostNormsForOperationService { public void fillCurrencyFields(final ViewDefinitionState view) { String currencyStringCode = currencyService.getCurrencyAlphabeticCode(); FieldComponent component = null; for (String componentReference : Sets.newHashSet("pieceworkCostCURRENCY", "laborHourlyCostCURRENCY", "machineHourlyCostCURRENCY")) { component = (FieldComponent) view.getComponentByReference(componentReference); if (component == null) { continue; } component.setFieldValue(currencyStringCode); component.requestComponentUpdateState(); } } } | CostNormsForOperationService { public void fillCurrencyFields(final ViewDefinitionState view) { String currencyStringCode = currencyService.getCurrencyAlphabeticCode(); FieldComponent component = null; for (String componentReference : Sets.newHashSet("pieceworkCostCURRENCY", "laborHourlyCostCURRENCY", "machineHourlyCostCURRENCY")) { component = (FieldComponent) view.getComponentByReference(componentReference); if (component == null) { continue; } component.setFieldValue(currencyStringCode); component.requestComponentUpdateState(); } } } | CostNormsForOperationService { public void fillCurrencyFields(final ViewDefinitionState view) { String currencyStringCode = currencyService.getCurrencyAlphabeticCode(); FieldComponent component = null; for (String componentReference : Sets.newHashSet("pieceworkCostCURRENCY", "laborHourlyCostCURRENCY", "machineHourlyCostCURRENCY")) { component = (FieldComponent) view.getComponentByReference(componentReference); if (component == null) { continue; } component.setFieldValue(currencyStringCode); component.requestComponentUpdateState(); } } void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState,
final String[] args); void inheritOperationNormValues(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); void fillCurrencyFields(final ViewDefinitionState view); void copyCostNormsToTechnologyOperationComponent(final DataDefinition dd, final Entity technologyOperationComponent); } | CostNormsForOperationService { public void fillCurrencyFields(final ViewDefinitionState view) { String currencyStringCode = currencyService.getCurrencyAlphabeticCode(); FieldComponent component = null; for (String componentReference : Sets.newHashSet("pieceworkCostCURRENCY", "laborHourlyCostCURRENCY", "machineHourlyCostCURRENCY")) { component = (FieldComponent) view.getComponentByReference(componentReference); if (component == null) { continue; } component.setFieldValue(currencyStringCode); component.requestComponentUpdateState(); } } void copyCostValuesFromOperation(final ViewDefinitionState view, final ComponentState operationLookupState,
final String[] args); void inheritOperationNormValues(final ViewDefinitionState view, final ComponentState componentState,
final String[] args); void fillCurrencyFields(final ViewDefinitionState view); void copyCostNormsToTechnologyOperationComponent(final DataDefinition dd, final Entity technologyOperationComponent); } |
@Test public final void shouldValidateTechnologyDuringAccepting() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateTechnologyDuringWithdrawing() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.OUTDATED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateTechnologyDraft() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateTechnologyIfNotChanged() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(technology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(techDataDefinition, technology); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateTocBelongingToDraftTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(tocDataDefinition, toc); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateUnchangedTocBelongingToAlreadyAcceptedTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(toc.getId()).willReturn(202L); given(tocDataDefinition.get(202L)).willReturn(toc); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(tocDataDefinition, toc); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldInvalidateChangedTocBelongingToAlreadyAcceptedTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(toc.getId()).willReturn(202L); final Entity existingToc = mock(Entity.class); given(tocDataDefinition.get(202L)).willReturn(existingToc); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(tocDataDefinition, toc); assertFalse(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateOpicBelongingToDraftTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(opicDataDefinition, opic); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateOpocBelongingToDraftTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.DRAFT.getStringValue()); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(opocDataDefinition, opoc); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldValidateUnchangedOpicBelongingToAlreadyAcceptedTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(opic.getId()).willReturn(303L); given(opicDataDefinition.get(303L)).willReturn(opic); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(opicDataDefinition, opic); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public void shouldReturnFalseAndAddErrorWhenValidateStockCorrectionIfLocationIsntNullAndLocationTypeIsntControlPoint() { given(stockCorrection.getBelongsToField(LOCATION)).willReturn(location); given(location.getStringField(TYPE)).willReturn("otherLocation"); boolean result = stockCorrectionModelValidators.validateStockCorrection(stockCorrectionDD, stockCorrection); assertFalse(result); verify(stockCorrection).addError(Mockito.any(FieldDefinition.class), Mockito.anyString()); } | public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection); boolean checkIfLocationHasExternalNumber(final DataDefinition stockCorrectionDD, final Entity stockCorrection); } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection); boolean checkIfLocationHasExternalNumber(final DataDefinition stockCorrectionDD, final Entity stockCorrection); } |
@Test public final void shouldValidateUnchangedOpocBelongingToAlreadyAcceptedTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(opoc.getId()).willReturn(404L); given(opocDataDefinition.get(404L)).willReturn(opoc); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(opocDataDefinition, opoc); assertTrue(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldInvalidateChangedOpicBelongingToAlreadyAcceptedTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(opic.getId()).willReturn(505L); final Entity existingOpic = mock(Entity.class); given(opicDataDefinition.get(505L)).willReturn(existingOpic); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(opicDataDefinition, opic); assertFalse(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test public final void shouldInvalidateChangedOpocBelongingToAlreadyAcceptedTechnology() { given(technology.getId()).willReturn(101L); given(techDataDefinition.get(101L)).willReturn(existingTechnology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(existingTechnology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyState.ACCEPTED.getStringValue()); given(opoc.getId()).willReturn(606L); final Entity existingOpoc = mock(Entity.class); given(opocDataDefinition.get(606L)).willReturn(existingOpoc); final boolean isValid = technologyTreeValidators.invalidateIfBelongsToAcceptedTechnology(opocDataDefinition, opoc); assertFalse(isValid); } | public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } | TechnologyTreeValidators { public boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity) { Entity technology = null; String errorMessageKey = "technologies.technology.state.error.modifyBelongsToAcceptedTechnology"; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(dataDefinition.getName())) { technology = entity; errorMessageKey = "technologies.technology.state.error.modifyAcceptedTechnology"; } else if (TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(dataDefinition.getName())) { technology = entity.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(dataDefinition.getName()) || TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(dataDefinition.getName())) { final Entity operationComponent = entity.getBelongsToField(L_OPERATION_COMPONENT); if (operationComponent == null) { return true; } technology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); } if (technologyIsAcceptedAndNotDeactivated(dataDefinition, entity, technology)) { entity.addGlobalError(errorMessageKey, technology.getStringField(TechnologyFields.NAME)); return false; } return true; } boolean invalidateIfWrongFormula(final DataDefinition dataDefinition, final Entity entity); boolean checkConsumingTheSameProductFromManySubOperations(final DataDefinition technologyDD, final Entity technology,
final boolean autoCloseMessage); boolean invalidateIfBelongsToAcceptedTechnology(final DataDefinition dataDefinition, final Entity entity); } |
@Test(expected = IllegalStateException.class) public void shouldReturnIllegalStateExceptionIfTheresNoTechnology() { when(order.getBelongsToField("technology")).thenReturn(null); productQuantitiesService.getProductComponentQuantities(order); } | @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldReturnCorrectQuantities() { OperationProductComponentWithQuantityContainer productQuantities = productQuantitiesService .getProductComponentQuantities(order); assertEquals(new BigDecimal(50), productQuantities.get(productInComponent1)); assertEquals(new BigDecimal(10), productQuantities.get(productInComponent2)); assertEquals(new BigDecimal(5), productQuantities.get(productInComponent3)); assertEquals(new BigDecimal(10), productQuantities.get(productOutComponent2)); assertEquals(new BigDecimal(5), productQuantities.get(productOutComponent4)); } | @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test @Ignore public void shouldReturnCorrectQuantitiesOfInputProductsForTechnology() { Map<Long, BigDecimal> productQuantities = productQuantitiesService.getNeededProductQuantities(technology, plannedQty, MrpAlgorithm.ALL_PRODUCTS_IN); assertEquals(3, productQuantities.size()); assertEquals(new BigDecimal(50), productQuantities.get(product1.getId())); assertEquals(new BigDecimal(10), productQuantities.get(product2.getId())); assertEquals(new BigDecimal(5), productQuantities.get(product3.getId())); } | @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldReturnQuantitiesOfInputProductsForOrdersAndIfToldCountOnlyComponents() { Map<Long, BigDecimal> productQuantities = productQuantitiesService.getNeededProductQuantities(order, MrpAlgorithm.ONLY_COMPONENTS); assertEquals(2, productQuantities.size()); assertEquals(new BigDecimal(50), productQuantities.get(product1.getId())); assertEquals(new BigDecimal(5), productQuantities.get(product3.getId())); } | @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldReturnQuantitiesAlsoForListOfComponents() { Entity component = mock(Entity.class); when(component.getBelongsToField("order")).thenReturn(order); Map<Long, BigDecimal> productQuantities = productQuantitiesService.getNeededProductQuantitiesForComponents( Arrays.asList(component), MrpAlgorithm.ALL_PRODUCTS_IN); assertEquals(3, productQuantities.size()); assertEquals(new BigDecimal(50), productQuantities.get(product1.getId())); assertEquals(new BigDecimal(10), productQuantities.get(product2.getId())); assertEquals(new BigDecimal(5), productQuantities.get(product3.getId())); } | @Override public Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components, final MrpAlgorithm mrpAlgorithm) { return getNeededProductQuantitiesForComponents(components, mrpAlgorithm, false); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components, final MrpAlgorithm mrpAlgorithm) { return getNeededProductQuantitiesForComponents(components, mrpAlgorithm, false); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components, final MrpAlgorithm mrpAlgorithm) { return getNeededProductQuantitiesForComponents(components, mrpAlgorithm, false); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components, final MrpAlgorithm mrpAlgorithm) { return getNeededProductQuantitiesForComponents(components, mrpAlgorithm, false); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components, final MrpAlgorithm mrpAlgorithm) { return getNeededProductQuantitiesForComponents(components, mrpAlgorithm, false); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldReturnOperationRuns() { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); productQuantitiesService.getNeededProductQuantities(orders, MrpAlgorithm.ALL_PRODUCTS_IN, operationRuns); assertEquals(2, operationRuns.size()); assertEquals(new BigDecimal(5), operationRuns.get(operationComponent2.getId())); assertEquals(new BigDecimal(10), operationRuns.get(operationComponent1.getId())); } | @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldReturnOperationRunsAlsoForComponents() { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); productQuantitiesService.getProductComponentQuantities(order, operationRuns); assertEquals(2, operationRuns.size()); assertEquals(new BigDecimal(5), operationRuns.get(operationComponent2.getId())); assertEquals(new BigDecimal(10), operationRuns.get(operationComponent1.getId())); } | @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldReturnTrueWhenValidateStockCorrectionIfLocationIsntNullAndLocationTypeIsControlPoint() { given(stockCorrection.getBelongsToField(LOCATION)).willReturn(location); given(location.getStringField(TYPE)).willReturn(CONTROL_POINT.getStringValue()); boolean result = stockCorrectionModelValidators.validateStockCorrection(stockCorrectionDD, stockCorrection); assertTrue(result); verify(stockCorrection, never()).addError(Mockito.any(FieldDefinition.class), Mockito.anyString()); } | public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection); boolean checkIfLocationHasExternalNumber(final DataDefinition stockCorrectionDD, final Entity stockCorrection); } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection); boolean checkIfLocationHasExternalNumber(final DataDefinition stockCorrectionDD, final Entity stockCorrection); } |
@Test public void shouldReturnOperationRunsAlsoForPlainTechnology() { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); productQuantitiesService.getProductComponentQuantities(technology, plannedQty, operationRuns); assertEquals(2, operationRuns.size()); assertEquals(new BigDecimal(5), operationRuns.get(operationComponent2.getId())); assertEquals(new BigDecimal(10), operationRuns.get(operationComponent1.getId())); } | @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldTraverseAlsoThroughReferencedTechnologies() { Entity refTech = mock(Entity.class); Entity someOpComp = mock(Entity.class); EntityList child = mockEntityListIterator(asList(someOpComp)); when(operationComponent2.getHasManyField("children")).thenReturn(child); when(someOpComp.getStringField("entityType")).thenReturn("referenceTechnology"); when(someOpComp.getBelongsToField("referenceTechnology")).thenReturn(refTech); EntityTree refTree = mockEntityTreeIterator(asList((Entity) operationComponent1)); when(refTree.getRoot()).thenReturn(operationComponent1); when(refTech.getTreeField("operationComponents")).thenReturn(refTree); OperationProductComponentWithQuantityContainer productQuantities = productQuantitiesService .getProductComponentQuantities(order); assertEquals(new BigDecimal(50), productQuantities.get(productInComponent1)); assertEquals(new BigDecimal(10), productQuantities.get(productInComponent2)); assertEquals(new BigDecimal(5), productQuantities.get(productInComponent3)); assertEquals(new BigDecimal(10), productQuantities.get(productOutComponent2)); assertEquals(new BigDecimal(5), productQuantities.get(productOutComponent4)); } | @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldNotRoundOperationRunsIfTjIsDivisable() { when(operationComponent1.getBooleanField("areProductQuantitiesDivisible")).thenReturn(true); when(operationComponent2.getBooleanField("areProductQuantitiesDivisible")).thenReturn(true); when(operationComponent1.getBooleanField("isTjDivisible")).thenReturn(true); when(operationComponent2.getBooleanField("isTjDivisible")).thenReturn(true); Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); productQuantitiesService.getNeededProductQuantities(orders, MrpAlgorithm.ALL_PRODUCTS_IN, operationRuns); assertEquals(2, operationRuns.size()); assertEquals(0, new BigDecimal(4.5).compareTo(operationRuns.get(operationComponent2))); assertEquals(0, new BigDecimal(9.0).compareTo(operationRuns.get(operationComponent1))); } | @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet(); OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology( technology, givenQuantity, operationRuns, nonComponents); return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldNotRoundToTheIntegerOperationRunsIfOperationComponentHasDivisableProductQuantities() { when(operationComponent1.getBooleanField("areProductQuantitiesDivisible")).thenReturn(true); when(operationComponent2.getBooleanField("areProductQuantitiesDivisible")).thenReturn(true); OperationProductComponentWithQuantityContainer productQuantities = productQuantitiesService .getProductComponentQuantities(order); assertEquals(0, new BigDecimal(45).compareTo(productQuantities.get(productInComponent1))); assertEquals(0, new BigDecimal(9).compareTo(productQuantities.get(productInComponent2))); assertEquals(0, new BigDecimal(4.5).compareTo(productQuantities.get(productInComponent3))); assertEquals(0, new BigDecimal(9).compareTo(productQuantities.get(productOutComponent2))); assertEquals(0, new BigDecimal(4.5).compareTo(productQuantities.get(productOutComponent4))); } | @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } | ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); } @Override ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantities(final Entity order,
final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders); @Override OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(
final List<Entity> orders, final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity,
final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final Entity order, final MrpAlgorithm mrpAlgorithm); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final boolean onTheFly); @Override Map<Long, BigDecimal> getNeededProductQuantities(final List<Entity> orders, final MrpAlgorithm mrpAlgorithm,
final Map<Long, BigDecimal> operationRuns); @Override Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components,
final MrpAlgorithm mrpAlgorithm); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology,
final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns,
final Set<OperationProductComponentHolder> nonComponents); @Override OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(
final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders); @Override void preloadProductQuantitiesAndOperationRuns(final EntityTree operationComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Map<Long, BigDecimal> operationRuns); @Override void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity,
final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override void traverseProductQuantitiesAndOperationRuns(final Entity technology, Map<Long, Entity> entitiesById,
final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent,
final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer,
final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns); @Override OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final List<Entity> orders,
final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents); @Override Map<Long, BigDecimal> getProductWithQuantities(
final OperationProductComponentWithQuantityContainer productComponentWithQuantities,
final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm,
final String operationProductComponentModelName); @Override void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity,
final Map<Long, BigDecimal> productWithQuantities); @Override Entity getOutputProductsFromOperationComponent(final Entity operationComponent); @Override Entity getTechnologyOperationComponent(final Long technologyOperationComponentId); @Override Entity getProduct(final Long productId); @Override Map<Entity, BigDecimal> convertOperationsRunsFromProductQuantities(
final Map<Long, BigDecimal> operationRunsFromProductionQuantities); } |
@Test public void shouldReturnCorrectWorkstationCount() { given(operation.getBelongsToField("workstationType")).willReturn(work2); Integer workstationCount = productionLinesServiceImpl.getWorkstationTypesCount(opComp1, productionLine); assertEquals(Integer.valueOf(234), workstationCount); } | @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } | ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } } | ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } } | ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } @Override Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine); @Override Integer getWorkstationTypesCount(final Long productionLineId, final String workstationTypeNumber); } | ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } @Override Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine); @Override Integer getWorkstationTypesCount(final Long productionLineId, final String workstationTypeNumber); } |
@Test public void shouldReturnSpecifiedQuantityIfNoWorkstationIsFound() { given(productionLine.getIntegerField("quantityForOtherWorkstationTypes")).willReturn(456); given(operation.getBelongsToField("workstationType")).willReturn(work3); Integer workstationCount = productionLinesServiceImpl.getWorkstationTypesCount(opComp1, productionLine); assertEquals(Integer.valueOf(456), workstationCount); } | @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } | ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } } | ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } } | ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } @Override Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine); @Override Integer getWorkstationTypesCount(final Long productionLineId, final String workstationTypeNumber); } | ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkstation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation != null) { for (Entity workstationTypeComponent : workstationTypeComponents) { Entity workstation = workstationTypeComponent.getBelongsToField(OperationFields.WORKSTATION_TYPE); if (desiredWorkstation.getId().equals(workstation.getId())) { return (Integer) workstationTypeComponent.getField(WorkstationTypeComponentFields.QUANTITY); } } } return productionLine.getIntegerField(ProductionLineFields.QUANTITY_FOR_OTHER_WORKSTATION_TYPES); } @Override Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine); @Override Integer getWorkstationTypesCount(final Long productionLineId, final String workstationTypeNumber); } |
@Test public final void shouldReturnTechnology() { Entity technologyFromDb = mockEntity(); stubDataDefGetResult(technologyFromDb); Optional<Entity> res = technologyDataProvider.tryFind(1L); Assert.assertEquals(Optional.of(technologyFromDb), res); } | public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } Optional<Entity> tryFind(final Long id); } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } Optional<Entity> tryFind(final Long id); } |
@Test public final void shouldReturnEmptyIfIdIsMissing() { Optional<Entity> res = technologyDataProvider.tryFind(null); Assert.assertEquals(Optional.<Entity> empty(), res); } | public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } Optional<Entity> tryFind(final Long id); } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } Optional<Entity> tryFind(final Long id); } |
@Test public final void shouldReturnEmptyIfEntityCannotBeFound() { stubDataDefGetResult(null); Optional<Entity> res = technologyDataProvider.tryFind(1L); Assert.assertEquals(Optional.<Entity> empty(), res); } | public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } Optional<Entity> tryFind(final Long id); } | TechnologyDataProviderImpl implements TechnologyDataProvider { public Optional<Entity> tryFind(final Long id) { return Optional.ofNullable(id).map(i -> getDataDefinition().get(i)); } Optional<Entity> tryFind(final Long id); } |
@Test public final void shouldGenerateNumber() { Entity product = mockEntity(); stubStringField(product, ProductFields.NUMBER, "SomeProductNumber"); technologyNameAndNumberGenerator.generateNumber(product); verify(numberGeneratorService).generateNumberWithPrefix(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY, 3, "SomeProductNumber-"); } | public String generateNumber(final Entity product) { String numberPrefix = product.getField(ProductFields.NUMBER) + "-"; return numberGeneratorService.generateNumberWithPrefix(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY, 3, numberPrefix); } | TechnologyNameAndNumberGenerator { public String generateNumber(final Entity product) { String numberPrefix = product.getField(ProductFields.NUMBER) + "-"; return numberGeneratorService.generateNumberWithPrefix(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY, 3, numberPrefix); } } | TechnologyNameAndNumberGenerator { public String generateNumber(final Entity product) { String numberPrefix = product.getField(ProductFields.NUMBER) + "-"; return numberGeneratorService.generateNumberWithPrefix(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY, 3, numberPrefix); } } | TechnologyNameAndNumberGenerator { public String generateNumber(final Entity product) { String numberPrefix = product.getField(ProductFields.NUMBER) + "-"; return numberGeneratorService.generateNumberWithPrefix(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY, 3, numberPrefix); } String generateNumber(final Entity product); String generateName(final Entity product); } | TechnologyNameAndNumberGenerator { public String generateNumber(final Entity product) { String numberPrefix = product.getField(ProductFields.NUMBER) + "-"; return numberGeneratorService.generateNumberWithPrefix(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY, 3, numberPrefix); } String generateNumber(final Entity product); String generateName(final Entity product); } |
@Test public void shouldReturnTrueWhenValidateStockCorrectionIfLocationIsNull() { given(stockCorrection.getBelongsToField(LOCATION)).willReturn(null); boolean result = stockCorrectionModelValidators.validateStockCorrection(stockCorrectionDD, stockCorrection); assertTrue(result); verify(stockCorrection, never()).addError(Mockito.any(FieldDefinition.class), Mockito.anyString()); } | public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection); boolean checkIfLocationHasExternalNumber(final DataDefinition stockCorrectionDD, final Entity stockCorrection); } | StockCorrectionModelValidators { public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; } boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection); boolean checkIfLocationHasExternalNumber(final DataDefinition stockCorrectionDD, final Entity stockCorrection); } |
@Test public final void shouldGenerateName() { String productNumber = "SomeProductNumber"; String productName = "Some product name"; Entity product = mockEntity(); stubStringField(product, ProductFields.NUMBER, productNumber); stubStringField(product, ProductFields.NAME, productName); technologyNameAndNumberGenerator.generateName(product); LocalDate date = LocalDate.now(); String expectedThirdArgument = String.format("%s.%s", date.getYear(), date.getMonthValue()); verify(translationService).translate("technologies.operation.name.default", LocaleContextHolder.getLocale(), productName, productNumber, expectedThirdArgument); } | public String generateName(final Entity product) { LocalDate date = LocalDate.now(); String currentDateString = String.format("%s.%s", date.getYear(), date.getMonthValue()); String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); return translationService.translate("technologies.operation.name.default", LocaleContextHolder.getLocale(), productName, productNumber, currentDateString); } | TechnologyNameAndNumberGenerator { public String generateName(final Entity product) { LocalDate date = LocalDate.now(); String currentDateString = String.format("%s.%s", date.getYear(), date.getMonthValue()); String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); return translationService.translate("technologies.operation.name.default", LocaleContextHolder.getLocale(), productName, productNumber, currentDateString); } } | TechnologyNameAndNumberGenerator { public String generateName(final Entity product) { LocalDate date = LocalDate.now(); String currentDateString = String.format("%s.%s", date.getYear(), date.getMonthValue()); String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); return translationService.translate("technologies.operation.name.default", LocaleContextHolder.getLocale(), productName, productNumber, currentDateString); } } | TechnologyNameAndNumberGenerator { public String generateName(final Entity product) { LocalDate date = LocalDate.now(); String currentDateString = String.format("%s.%s", date.getYear(), date.getMonthValue()); String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); return translationService.translate("technologies.operation.name.default", LocaleContextHolder.getLocale(), productName, productNumber, currentDateString); } String generateNumber(final Entity product); String generateName(final Entity product); } | TechnologyNameAndNumberGenerator { public String generateName(final Entity product) { LocalDate date = LocalDate.now(); String currentDateString = String.format("%s.%s", date.getYear(), date.getMonthValue()); String productName = product.getStringField(ProductFields.NAME); String productNumber = product.getStringField(ProductFields.NUMBER); return translationService.translate("technologies.operation.name.default", LocaleContextHolder.getLocale(), productName, productNumber, currentDateString); } String generateNumber(final Entity product); String generateName(final Entity product); } |
@Test public final void shouldThrowExceptionWhenTryToAddProductWithIncorrectTypeToOutputProductComponent() { performWrongTypeProductTest(buildOpoc()); verify(wrappedEntity, Mockito.never()).setField(OperationProductInComponentFields.PRODUCT, product); } | @Override public void setField(final String name, final Object value) { entity.setField(name, value); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); @Override void setField(final String name, final Object value); @Override Entity getWrappedEntity(); @Override void setProduct(final Entity product); @Override void setQuantity(final BigDecimal quantity); @Override void setPriority(final int priority); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); @Override void setField(final String name, final Object value); @Override Entity getWrappedEntity(); @Override void setProduct(final Entity product); @Override void setQuantity(final BigDecimal quantity); @Override void setPriority(final int priority); } |
@Test public final void shouldThrowExceptionWhenTryToAddProductWithIncorrectTypeToInputProductComponent() { performWrongTypeProductTest(buildOpic()); verify(wrappedEntity, Mockito.never()).setField(OperationProductOutComponentFields.PRODUCT, product); } | @Override public void setField(final String name, final Object value) { entity.setField(name, value); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); @Override void setField(final String name, final Object value); @Override Entity getWrappedEntity(); @Override void setProduct(final Entity product); @Override void setQuantity(final BigDecimal quantity); @Override void setPriority(final int priority); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); @Override void setField(final String name, final Object value); @Override Entity getWrappedEntity(); @Override void setProduct(final Entity product); @Override void setQuantity(final BigDecimal quantity); @Override void setPriority(final int priority); } |
@Test public final void shouldNotThrowExceptionWhenAddingProductWithCorrectTypeToOutputProductComponent() { performCorrectTypeProductTest(buildOpoc()); verify(wrappedEntity).setField(OperationProductOutComponentFields.PRODUCT, product); } | @Override public void setField(final String name, final Object value) { entity.setField(name, value); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); @Override void setField(final String name, final Object value); @Override Entity getWrappedEntity(); @Override void setProduct(final Entity product); @Override void setQuantity(final BigDecimal quantity); @Override void setPriority(final int priority); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); @Override void setField(final String name, final Object value); @Override Entity getWrappedEntity(); @Override void setProduct(final Entity product); @Override void setQuantity(final BigDecimal quantity); @Override void setPriority(final int priority); } |
@Test public final void shouldNotThrowExceptionWhenAddingProductWithCorrectTypeToInputProductComponent() { performCorrectTypeProductTest(buildOpic()); verify(wrappedEntity).setField(OperationProductInComponentFields.PRODUCT, product); } | @Override public void setField(final String name, final Object value) { entity.setField(name, value); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); @Override void setField(final String name, final Object value); @Override Entity getWrappedEntity(); @Override void setProduct(final Entity product); @Override void setQuantity(final BigDecimal quantity); @Override void setPriority(final int priority); } | OperationProductComponentImpl implements InternalOperationProductComponent { @Override public void setField(final String name, final Object value) { entity.setField(name, value); } OperationProductComponentImpl(final OperationCompType operationType, final DataDefinition opcDataDef); @Override void setField(final String name, final Object value); @Override Entity getWrappedEntity(); @Override void setProduct(final Entity product); @Override void setQuantity(final BigDecimal quantity); @Override void setPriority(final int priority); } |
@Test public final void shouldBuildTree() { TocHolder customTreeRoot = mockCustomTreeRepresentation(); EntityTree tree = treeBuildService.build(customTreeRoot, new TestTreeAdapter()); EntityTreeNode root = tree.getRoot(); assertNotNull(root); Entity toc1 = extractEntity(root); verify(toc1).setField(TechnologyOperationComponentFields.ENTITY_TYPE, TechnologyOperationComponentType.OPERATION.getStringValue()); verify(toc1).setField(TechnologyOperationComponentFields.OPERATION, toc1op); verify(toc1).setField(Mockito.eq(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS), toc1opicCaptor.capture()); Collection<Entity> toc1opics = toc1opicCaptor.getValue(); assertEquals(1, toc1opics.size()); Entity toc1opic = toc1opics.iterator().next(); verify(toc1opic).setField(OperationProductInComponentFields.QUANTITY, BigDecimal.ONE); verify(toc1opic).setField(OperationProductInComponentFields.PRODUCT, toc1opic1prod); verify(toc1).setField(Mockito.eq(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS), toc1opocCaptor.capture()); Collection<Entity> toc1opocs = toc1opocCaptor.getValue(); assertEquals(1, toc1opocs.size()); Entity toc1opoc = toc1opocs.iterator().next(); verify(toc1opoc).setField(OperationProductInComponentFields.QUANTITY, BigDecimal.ONE); verify(toc1opoc).setField(OperationProductInComponentFields.PRODUCT, toc1opoc1prod); verify(toc1).setField(Mockito.eq(TechnologyOperationComponentFields.CHILDREN), toc1childrenCaptor.capture()); Collection<Entity> toc1children = toc1childrenCaptor.getValue(); assertEquals(1, toc1children.size()); Entity toc2 = toc1children.iterator().next(); verify(toc2).setField(TechnologyOperationComponentFields.ENTITY_TYPE, TechnologyOperationComponentType.OPERATION.getStringValue()); verify(toc2).setField(TechnologyOperationComponentFields.OPERATION, toc2op); verify(toc2).setField(Mockito.eq(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS), toc2opicCaptor.capture()); Collection<Entity> toc2opics = toc2opicCaptor.getValue(); assertEquals(1, toc2opics.size()); Entity toc2opic = toc2opics.iterator().next(); verify(toc2opic).setField(OperationProductInComponentFields.QUANTITY, BigDecimal.ONE); verify(toc2opic).setField(OperationProductInComponentFields.PRODUCT, toc2opic1prod); verify(toc2).setField(Mockito.eq(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS), toc2opocCaptor.capture()); Collection<Entity> toc2opocs = toc2opocCaptor.getValue(); assertEquals(1, toc2opocs.size()); Entity toc2opoc = toc2opocs.iterator().next(); verify(toc2opoc).setField(OperationProductInComponentFields.QUANTITY, BigDecimal.ONE); verify(toc2opoc).setField(OperationProductInComponentFields.PRODUCT, toc2opoc1prod); verify(toc2).setField(Mockito.eq(TechnologyOperationComponentFields.CHILDREN), toc2childrenCaptor.capture()); Collection<Entity> toc2children = toc2childrenCaptor.getValue(); assertTrue(toc2children.isEmpty()); } | @Override public <T, P> EntityTree build(final T from, final TechnologyTreeAdapter<T, P> transformer) { TechnologyTreeBuilder<T, P> builder = new TechnologyTreeBuilder<T, P>(componentsFactory, transformer); Entity root = builder.build(from, numberService); return EntityTreeUtilsService.getDetachedEntityTree(Lists.newArrayList(root)); } | TechnologyTreeBuildServiceImpl implements TechnologyTreeBuildService { @Override public <T, P> EntityTree build(final T from, final TechnologyTreeAdapter<T, P> transformer) { TechnologyTreeBuilder<T, P> builder = new TechnologyTreeBuilder<T, P>(componentsFactory, transformer); Entity root = builder.build(from, numberService); return EntityTreeUtilsService.getDetachedEntityTree(Lists.newArrayList(root)); } } | TechnologyTreeBuildServiceImpl implements TechnologyTreeBuildService { @Override public <T, P> EntityTree build(final T from, final TechnologyTreeAdapter<T, P> transformer) { TechnologyTreeBuilder<T, P> builder = new TechnologyTreeBuilder<T, P>(componentsFactory, transformer); Entity root = builder.build(from, numberService); return EntityTreeUtilsService.getDetachedEntityTree(Lists.newArrayList(root)); } } | TechnologyTreeBuildServiceImpl implements TechnologyTreeBuildService { @Override public <T, P> EntityTree build(final T from, final TechnologyTreeAdapter<T, P> transformer) { TechnologyTreeBuilder<T, P> builder = new TechnologyTreeBuilder<T, P>(componentsFactory, transformer); Entity root = builder.build(from, numberService); return EntityTreeUtilsService.getDetachedEntityTree(Lists.newArrayList(root)); } @Override EntityTree build(final T from, final TechnologyTreeAdapter<T, P> transformer); } | TechnologyTreeBuildServiceImpl implements TechnologyTreeBuildService { @Override public <T, P> EntityTree build(final T from, final TechnologyTreeAdapter<T, P> transformer) { TechnologyTreeBuilder<T, P> builder = new TechnologyTreeBuilder<T, P>(componentsFactory, transformer); Entity root = builder.build(from, numberService); return EntityTreeUtilsService.getDetachedEntityTree(Lists.newArrayList(root)); } @Override EntityTree build(final T from, final TechnologyTreeAdapter<T, P> transformer); } |
@Test public final void shouldReturnEmptyMapForNullTree() { resultMap = technologyTreeValidationService.checkConsumingManyProductsFromOneSubOp(null); assertNotNull(resultMap); assertTrue(resultMap.isEmpty()); } | @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } |
@Test public final void shouldReturnEmptyMapForEmptyTree() { given(tree.isEmpty()).willReturn(true); resultMap = technologyTreeValidationService.checkConsumingManyProductsFromOneSubOp(tree); assertNotNull(resultMap); assertTrue(resultMap.isEmpty()); } | @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } |
@Test public final void shouldReturnNotEmptyMapIfParentOpConsumeManyOutputsFromOneSubOp() { 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 node3 = mockOperationComponent("3.", newArrayList(product6), newArrayList(product3, product4, product5)); EntityTreeNode node2 = mockOperationComponent("2.", newArrayList(product3, product4), newArrayList(product2), newArrayList(node3)); EntityTreeNode node1 = mockOperationComponent("1.", newArrayList(product2), newArrayList(product1), newArrayList(node2)); given(tree.getRoot()).willReturn(node1); resultMap = technologyTreeValidationService.checkConsumingManyProductsFromOneSubOp(tree); assertNotNull(resultMap); assertFalse(resultMap.isEmpty()); assertEquals(1, resultMap.size()); hasNodeNumbersFor(node2, node3); } | @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } |
@Test public final void shouldReturnNotEmptyMapIfSubOpsProduceTheSameOutputsWhichAreConsumed() { 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 node3 = mockOperationComponent(3L, "3.", newArrayList(product5), newArrayList(product2, product3)); EntityTreeNode node2 = mockOperationComponent(2L, "2.", newArrayList(product6), newArrayList(product2, product4)); EntityTreeNode node1 = mockOperationComponent(1L, "1.", newArrayList(product2), newArrayList(product1), newArrayList(node2, node3)); given(tree.getRoot()).willReturn(node1); Map<String, Set<Entity>> returnedMap = technologyTreeValidationService .checkConsumingTheSameProductFromManySubOperations(tree); assertNotNull(returnedMap); assertFalse(returnedMap.isEmpty()); assertEquals(1, returnedMap.size()); assertTrue(returnedMap.containsKey("1.")); assertTrue(returnedMap.get("1.").contains(product2)); } | @Override public Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree) { Map<String, Set<Entity>> parentToProductsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingTheSameParentInputs(parentToProductsMap, rootNode); } return parentToProductsMap; } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree) { Map<String, Set<Entity>> parentToProductsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingTheSameParentInputs(parentToProductsMap, rootNode); } return parentToProductsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree) { Map<String, Set<Entity>> parentToProductsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingTheSameParentInputs(parentToProductsMap, rootNode); } return parentToProductsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree) { Map<String, Set<Entity>> parentToProductsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingTheSameParentInputs(parentToProductsMap, rootNode); } return parentToProductsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree) { Map<String, Set<Entity>> parentToProductsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingTheSameParentInputs(parentToProductsMap, rootNode); } return parentToProductsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } |
@Test public void shouldReturnFalseWhenCheckIfTransfersAreValidAndTransfersArentNull() { Entity transferConsumption = mockTransfer(null, null, null); Entity transferProduction = mockTransfer(null, null, null); stubHasManyField(transformations, TRANSFERS_CONSUMPTION, Lists.newArrayList(transferConsumption)); stubHasManyField(transformations, TRANSFERS_PRODUCTION, Lists.newArrayList(transferProduction)); boolean result = transformationsModelValidators.checkIfTransfersAreValid(transformationsDD, transformations); assertFalse(result); } | public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations); boolean checkIfLocationFromOrLocationToHasExternalNumber(final DataDefinition transformationDD,
final Entity transformation); } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations); boolean checkIfLocationFromOrLocationToHasExternalNumber(final DataDefinition transformationDD,
final Entity transformation); } |
@Test public final void shouldReturnNotEmptyMapIfManyParentOpConsumesManyOutputsFromOneSubOp() { Entity product1 = mockProductComponent(1L); Entity product2 = mockProductComponent(2L); Entity product3 = mockProductComponent(3L); Entity product4 = mockProductComponent(4L); Entity product5 = mockProductComponent(5L); Entity product6 = mockProductComponent(6L); Entity product7 = mockProductComponent(7L); Entity product8 = mockProductComponent(8L); Entity product9 = mockProductComponent(9L); Entity product10 = mockProductComponent(10L); Entity product11 = mockProductComponent(11L); Entity product12 = mockProductComponent(12L); EntityTreeNode node1A3 = mockOperationComponent("1.A.3.", newArrayList(product11, product12), newArrayList(product10)); EntityTreeNode node1A2 = mockOperationComponent("1.A.2.", newArrayList(product10), newArrayList(product7, product8, product9), newArrayList(node1A3)); EntityTreeNode node1A1 = mockOperationComponent("1.A.1.", newArrayList(product7, product8, product9), newArrayList(product2, product3), newArrayList(node1A2)); EntityTreeNode node1B1 = mockOperationComponent("1.B.1.", newArrayList(product6), newArrayList(product4, product5)); EntityTreeNode node1 = mockOperationComponent("1.", newArrayList(product2, product3, product4, product5), newArrayList(product1), newArrayList(node1A1, node1B1)); given(tree.getRoot()).willReturn(node1); resultMap = technologyTreeValidationService.checkConsumingManyProductsFromOneSubOp(tree); assertNotNull(resultMap); assertFalse(resultMap.isEmpty()); assertEquals(2, resultMap.size()); assertEquals(2, resultMap.get(node1.getStringField(NODE_NUMBER)).size()); hasNodeNumbersFor(node1, node1A1); hasNodeNumbersFor(node1, node1B1); hasNodeNumbersFor(node1A1, node1A2); } | @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } |
@Test public final void shouldReturnEmptyMapIfParentOpNotConsumeManyOutputsFromOneSubOp() { 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); resultMap = technologyTreeValidationService.checkConsumingManyProductsFromOneSubOp(tree); assertNotNull(resultMap); assertTrue(resultMap.isEmpty()); } | @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } | TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree) { final Map<String, Set<String>> parentToChildsMap = Maps.newHashMap(); if (technologyTree != null && !technologyTree.isEmpty()) { final EntityTreeNode rootNode = technologyTree.getRoot(); collectChildrenProducingManyParentInputs(parentToChildsMap, rootNode); } return parentToChildsMap; } @Override final Map<String, Set<String>> checkConsumingManyProductsFromOneSubOp(final EntityTree technologyTree); @Override Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree); } |
@Test public void shouldReturnOutputProductCountForOperationComponent() { BigDecimal count = technologyService.getProductCountForOperationComponent(opComp2); assertEquals(new BigDecimal(10), count); } | public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); static final String L_01_COMPONENT; static final String L_02_INTERMEDIATE; static final String L_03_FINAL_PRODUCT; static final String L_04_WASTE; static final String L_00_UNRELATED; } |
@Test public void shouldThrowAnExceptionIfThereAreNoProductsOrIntermediates() { EntityList opComp2prodOuts = mockEntityIterator(asList(prodOutComp2)); when(opComp2.getHasManyField("operationProductOutComponents")).thenReturn(opComp2prodOuts); try { technologyService.getProductCountForOperationComponent(opComp2); fail(); } catch (IllegalStateException e) { } } | public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); static final String L_01_COMPONENT; static final String L_02_INTERMEDIATE; static final String L_03_FINAL_PRODUCT; static final String L_04_WASTE; static final String L_00_UNRELATED; } |
@Test public void shouldReturnOutputProductCountForOperationComponentAlsoForTechnologyInstanceOperationComponent() { when(dataDefinition.getName()).thenReturn("technologyInstanceOperationComponent"); when(opComp2.getBelongsToField("technologyOperationComponent")).thenReturn(opComp2); when(opComp1.getBelongsToField("technologyOperationComponent")).thenReturn(opComp1); BigDecimal count = technologyService.getProductCountForOperationComponent(opComp2); assertEquals(new BigDecimal(10), count); } | public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); static final String L_01_COMPONENT; static final String L_02_INTERMEDIATE; static final String L_03_FINAL_PRODUCT; static final String L_04_WASTE; static final String L_00_UNRELATED; } |
@Test public void shouldReturnOutputProductCountForOperationComponentAlsoForReferenceTechnology() { when(opComp2.getStringField("entityType")).thenReturn("referenceTechnology"); Entity refTech = mock(Entity.class); when(opComp2.getBelongsToField("referenceTechnology")).thenReturn(refTech); EntityTree tree = mock(EntityTree.class); when(refTech.getTreeField("operationComponents")).thenReturn(tree); when(tree.getRoot()).thenReturn(opComp2); BigDecimal count = technologyService.getProductCountForOperationComponent(opComp2); assertEquals(new BigDecimal(10), count); } | public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); static final String L_01_COMPONENT; static final String L_02_INTERMEDIATE; static final String L_03_FINAL_PRODUCT; static final String L_04_WASTE; static final String L_00_UNRELATED; } |
@Test public void shouldReturnOutputProductCountForOperationComponentAlsoIfParentOperationIsNull() { when(opComp2.getBelongsToField("parent")).thenReturn(null); when(prodOutComp2.getBelongsToField("product")).thenReturn(product2); when(prodOutComp1.getBelongsToField("product")).thenReturn(product1); when(technology.getBelongsToField("product")).thenReturn(product2); BigDecimal count = technologyService.getProductCountForOperationComponent(opComp2); assertEquals(new BigDecimal(10), count); } | public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); } | TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); boolean checkIfTechnologyStateIsOtherThanCheckedAndAccepted(final Entity technology); boolean isTechnologyUsedInActiveOrder(final Entity technology); void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args); void generateTechnologyGroupNumber(final ViewDefinitionState viewDefinitionState); void generateTechnologyNumber(final ViewDefinitionState view, final ComponentState state, final String[] args); void generateTechnologyName(final ViewDefinitionState view, final ComponentState state, final String[] args); void setLookupDisableInTechnologyOperationComponent(final ViewDefinitionState viewDefinitionState); void toggleDetailsViewEnabled(final ViewDefinitionState view); String getProductType(final Entity product, final Entity technology); void addOperationsFromSubtechnologiesToList(final EntityTree entityTree,
final List<Entity> technologyOperationComponents); boolean invalidateIfAllreadyInTheSameOperation(final DataDefinition operationProductComponentDD,
final Entity operationProductComponent); Optional<Entity> tryGetMainOutputProductComponent(Entity technologyOperationComponent); Entity getMainOutputProductComponent(Entity technologyOperationComponent); BigDecimal getProductCountForOperationComponent(final Entity operationComponent); boolean isExternalSynchronized(final Long technologyId); boolean isIntermediateProduct(final Entity opic); boolean isFinalProduct(final Entity opoc); static final String L_01_COMPONENT; static final String L_02_INTERMEDIATE; static final String L_03_FINAL_PRODUCT; static final String L_04_WASTE; static final String L_00_UNRELATED; } |
@Test public void shouldRedirectToProductionPerShiftView() { Long givenOrderId = 1L; Long expectedPpsId = 50L; given(state.getFieldValue()).willReturn(givenOrderId); given(ppsHelper.getPpsIdForOrder(givenOrderId)).willReturn(expectedPpsId); orderDetailsListenersPPS.redirectToProductionPerShift(view, state, new String[] {}); verifyRedirectToPpsDetails(expectedPpsId); } | public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args); } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args); } |
@Test public void shouldRedirectToJustCreatedProductionPerShiftView() { Long givenOrderId = 1L; Long expectedPpsId = 50L; given(state.getFieldValue()).willReturn(givenOrderId); given(ppsHelper.getPpsIdForOrder(givenOrderId)).willReturn(null); given(ppsHelper.createPpsForOrderAndReturnId(givenOrderId)).willReturn(expectedPpsId); orderDetailsListenersPPS.redirectToProductionPerShift(view, state, new String[] {}); verifyRedirectToPpsDetails(expectedPpsId); } | public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args); } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args); } |
@Test public void shouldThrowExceptionIfProductionPerShiftCanNotBeSaved() { Long givenOrderId = 1L; given(state.getFieldValue()).willReturn(givenOrderId); given(ppsHelper.getPpsIdForOrder(givenOrderId)).willReturn(null); given(ppsHelper.createPpsForOrderAndReturnId(givenOrderId)).willReturn(null); try { orderDetailsListenersPPS.redirectToProductionPerShift(view, state, new String[] {}); Assert.fail(); } catch (NullPointerException ex) { } } | public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args); } | OrderDetailsListenersPPS { public void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args) { Long orderId = (Long) state.getFieldValue(); if (orderId == null) { return; } Long ppsId = ppsHelper.getPpsIdForOrder(orderId); if (ppsId == null) { ppsId = ppsHelper.createPpsForOrderAndReturnId(orderId); Preconditions.checkNotNull(ppsId); } redirect(view, ppsId); } void redirectToProductionPerShift(final ViewDefinitionState view, final ComponentState state, final String[] args); } |
@Test public void shouldReturnFalseWhenCheckIfTransfersAreValidAndTransferProductAlreadyAdded() { Entity transferConsumption1 = mockTransfer(L_NUMBER_CONSUMPTION_1, productConsumption, BigDecimal.ONE); Entity transferConsumption2 = mockTransfer(L_NUMBER_CONSUMPTION_2, productProduction, BigDecimal.ONE); stubHasManyField(transformations, TRANSFERS_CONSUMPTION, Lists.newArrayList(transferConsumption1, transferConsumption2)); boolean result = transformationsModelValidators.checkIfTransfersAreValid(transformationsDD, transformations); assertFalse(result); } | public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations); boolean checkIfLocationFromOrLocationToHasExternalNumber(final DataDefinition transformationDD,
final Entity transformation); } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations); boolean checkIfLocationFromOrLocationToHasExternalNumber(final DataDefinition transformationDD,
final Entity transformation); } |
@Test public void shouldAddErrorForEntityWhenNotUnique() { Long id = 1L; String changeoverNumber = "0002"; given(changeoverNorm.getId()).willReturn(id); given(changeoverNorm.getBelongsToField(FROM_TECHNOLOGY)).willReturn(fromTechnology); given(changeoverNorm.getBelongsToField(TO_TECHNOLOGY)).willReturn(toTechnology); given(changeoverNorm.getBelongsToField(FROM_TECHNOLOGY_GROUP)).willReturn(fromTechnologyGroup); given(changeoverNorm.getBelongsToField(TO_TECHNOLOGY_GROUP)).willReturn(toTechnologyGroup); given(changeoverNorm.getBelongsToField(PRODUCTION_LINE)).willReturn(productionLine); given( dataDefinitionService.get(LineChangeoverNormsConstants.PLUGIN_IDENTIFIER, LineChangeoverNormsConstants.MODEL_LINE_CHANGEOVER_NORMS)).willReturn(changeoverNormDD); given(changeoverNormDD.find()).willReturn(searchCriteria); searchMatchingChangeroverNorms(fromTechnology, toTechnology, fromTechnologyGroup, toTechnologyGroup, productionLine); given(searchCriteria.uniqueResult()).willReturn(changeover); given(changeover.getStringField(NUMBER)).willReturn(changeoverNumber); hooks.checkUniqueNorms(changeoverNormDD, changeoverNorm); verify(changeoverNorm).addGlobalError("lineChangeoverNorms.lineChangeoverNorm.notUnique", changeoverNumber); } | public boolean checkUniqueNorms(final DataDefinition changeoverNormDD, final Entity changeoverNorm) { SearchCriteriaBuilder searchCriteriaBuilder = dataDefinitionService .get(LineChangeoverNormsConstants.PLUGIN_IDENTIFIER, LineChangeoverNormsConstants.MODEL_LINE_CHANGEOVER_NORMS) .find() .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY, changeoverNorm.getBelongsToField(TO_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(TO_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(PRODUCTION_LINE, changeoverNorm.getBelongsToField(PRODUCTION_LINE))); if (changeoverNorm.getId() != null) { searchCriteriaBuilder.add(SearchRestrictions.ne("id", changeoverNorm.getId())); } Entity existingChangeoverNorm = searchCriteriaBuilder.uniqueResult(); if (existingChangeoverNorm != null) { changeoverNorm.addGlobalError(L_LINE_CHANGEOVER_NORMS_LINE_CHANGEOVER_NORM_NOT_UNIQUE, existingChangeoverNorm.getStringField(NUMBER)); return false; } return true; } | LineChangeoverNormsHooks { public boolean checkUniqueNorms(final DataDefinition changeoverNormDD, final Entity changeoverNorm) { SearchCriteriaBuilder searchCriteriaBuilder = dataDefinitionService .get(LineChangeoverNormsConstants.PLUGIN_IDENTIFIER, LineChangeoverNormsConstants.MODEL_LINE_CHANGEOVER_NORMS) .find() .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY, changeoverNorm.getBelongsToField(TO_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(TO_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(PRODUCTION_LINE, changeoverNorm.getBelongsToField(PRODUCTION_LINE))); if (changeoverNorm.getId() != null) { searchCriteriaBuilder.add(SearchRestrictions.ne("id", changeoverNorm.getId())); } Entity existingChangeoverNorm = searchCriteriaBuilder.uniqueResult(); if (existingChangeoverNorm != null) { changeoverNorm.addGlobalError(L_LINE_CHANGEOVER_NORMS_LINE_CHANGEOVER_NORM_NOT_UNIQUE, existingChangeoverNorm.getStringField(NUMBER)); return false; } return true; } } | LineChangeoverNormsHooks { public boolean checkUniqueNorms(final DataDefinition changeoverNormDD, final Entity changeoverNorm) { SearchCriteriaBuilder searchCriteriaBuilder = dataDefinitionService .get(LineChangeoverNormsConstants.PLUGIN_IDENTIFIER, LineChangeoverNormsConstants.MODEL_LINE_CHANGEOVER_NORMS) .find() .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY, changeoverNorm.getBelongsToField(TO_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(TO_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(PRODUCTION_LINE, changeoverNorm.getBelongsToField(PRODUCTION_LINE))); if (changeoverNorm.getId() != null) { searchCriteriaBuilder.add(SearchRestrictions.ne("id", changeoverNorm.getId())); } Entity existingChangeoverNorm = searchCriteriaBuilder.uniqueResult(); if (existingChangeoverNorm != null) { changeoverNorm.addGlobalError(L_LINE_CHANGEOVER_NORMS_LINE_CHANGEOVER_NORM_NOT_UNIQUE, existingChangeoverNorm.getStringField(NUMBER)); return false; } return true; } } | LineChangeoverNormsHooks { public boolean checkUniqueNorms(final DataDefinition changeoverNormDD, final Entity changeoverNorm) { SearchCriteriaBuilder searchCriteriaBuilder = dataDefinitionService .get(LineChangeoverNormsConstants.PLUGIN_IDENTIFIER, LineChangeoverNormsConstants.MODEL_LINE_CHANGEOVER_NORMS) .find() .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY, changeoverNorm.getBelongsToField(TO_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(TO_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(PRODUCTION_LINE, changeoverNorm.getBelongsToField(PRODUCTION_LINE))); if (changeoverNorm.getId() != null) { searchCriteriaBuilder.add(SearchRestrictions.ne("id", changeoverNorm.getId())); } Entity existingChangeoverNorm = searchCriteriaBuilder.uniqueResult(); if (existingChangeoverNorm != null) { changeoverNorm.addGlobalError(L_LINE_CHANGEOVER_NORMS_LINE_CHANGEOVER_NORM_NOT_UNIQUE, existingChangeoverNorm.getStringField(NUMBER)); return false; } return true; } boolean checkUniqueNorms(final DataDefinition changeoverNormDD, final Entity changeoverNorm); boolean checkRequiredField(final DataDefinition changeoverNormDD, final Entity changeoverNorm); } | LineChangeoverNormsHooks { public boolean checkUniqueNorms(final DataDefinition changeoverNormDD, final Entity changeoverNorm) { SearchCriteriaBuilder searchCriteriaBuilder = dataDefinitionService .get(LineChangeoverNormsConstants.PLUGIN_IDENTIFIER, LineChangeoverNormsConstants.MODEL_LINE_CHANGEOVER_NORMS) .find() .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY, changeoverNorm.getBelongsToField(TO_TECHNOLOGY))) .add(SearchRestrictions.belongsTo(FROM_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(FROM_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(TO_TECHNOLOGY_GROUP, changeoverNorm.getBelongsToField(TO_TECHNOLOGY_GROUP))) .add(SearchRestrictions.belongsTo(PRODUCTION_LINE, changeoverNorm.getBelongsToField(PRODUCTION_LINE))); if (changeoverNorm.getId() != null) { searchCriteriaBuilder.add(SearchRestrictions.ne("id", changeoverNorm.getId())); } Entity existingChangeoverNorm = searchCriteriaBuilder.uniqueResult(); if (existingChangeoverNorm != null) { changeoverNorm.addGlobalError(L_LINE_CHANGEOVER_NORMS_LINE_CHANGEOVER_NORM_NOT_UNIQUE, existingChangeoverNorm.getStringField(NUMBER)); return false; } return true; } boolean checkUniqueNorms(final DataDefinition changeoverNormDD, final Entity changeoverNorm); boolean checkRequiredField(final DataDefinition changeoverNormDD, final Entity changeoverNorm); } |
@Test public final void shouldFillNewlyAddedRowsAccordingToPlannedDaysAndDates() { stubRealizationDaysStream(PLANNED_ORDER_START, Sets.newHashSet(0, 1, 2, 3, 4, 5, 8, 9, 10), shifts); stubRealizationDaysStream(CORRECTED_ORDER_START, Sets.newHashSet(1, 2, 3, 6, 7, 8, 9, 10), shifts); stubProgressType(ProgressType.PLANNED); FieldComponent day1 = mockFieldComponent("0"); FieldComponent date1 = mockFieldComponent(null); FormComponent row1 = mockFormComponent(day1, date1); AwesomeDynamicListComponent row1DailyProgresses = mockDailyProgressForShiftAdl(row1); FieldComponent day2 = mockFieldComponent("3"); FieldComponent date2 = mockFieldComponent(null); FormComponent row2 = mockFormComponent(day2, date2); AwesomeDynamicListComponent row2DailyProgresses = mockDailyProgressForShiftAdl(row2); FieldComponent day3 = mockFieldComponent(null); FieldComponent date3 = mockFieldComponent(null); FormComponent row3 = mockFormComponent(day3, date3); AwesomeDynamicListComponent row3DailyProgresses = mockDailyProgressForShiftAdl(row3); FieldComponent day4 = mockFieldComponent(null); FieldComponent date4 = mockFieldComponent(null); FormComponent row4 = mockFormComponent(day4, date4); AwesomeDynamicListComponent row4DailyProgresses = mockDailyProgressForShiftAdl(row4); stubProgressForDaysAdlRows(row1, row2, row3, row4); productionPerShiftListeners.updateProgressForDays(view, progressForDaysAdl, new String[] {}); verify(day1, never()).setFieldValue(any()); verify(date1, never()).setFieldValue(any()); verify(row1DailyProgresses, never()).setFieldValue(any()); verify(day2, never()).setFieldValue(any()); verify(date2, never()).setFieldValue(any()); verify(row2DailyProgresses, never()).setFieldValue(any()); verify(day3).setFieldValue(4); verify(date3).setFieldValue(DateUtils.toDateString(PLANNED_ORDER_START.plusDays(3).toLocalDate().toDate())); verify(row3DailyProgresses).setFieldValue(eq(Lists.newArrayList(firstShiftDailyProgress, secondShiftDailyProgress))); verify(day4).setFieldValue(5); verify(date4).setFieldValue(DateUtils.toDateString(PLANNED_ORDER_START.plusDays(4).toLocalDate().toDate())); verify(row4DailyProgresses).setFieldValue(eq(Lists.newArrayList(firstShiftDailyProgress, secondShiftDailyProgress))); } | public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } void generateProgressForDays(final ViewDefinitionState view, final ComponentState componentState, final String[] args); void onTechnologyOperationChange(final ViewDefinitionState view, final ComponentState state, final String[] args); void savePlan(final ViewDefinitionState view, final ComponentState state, final String[] args); void refreshView(final ViewDefinitionState view, final ComponentState state, final String[] args); void changeView(final ViewDefinitionState view, final ComponentState state, final String[] args); void copyFromPlanned(final ViewDefinitionState view, final ComponentState state, final String[] args); void deleteProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } void generateProgressForDays(final ViewDefinitionState view, final ComponentState componentState, final String[] args); void onTechnologyOperationChange(final ViewDefinitionState view, final ComponentState state, final String[] args); void savePlan(final ViewDefinitionState view, final ComponentState state, final String[] args); void refreshView(final ViewDefinitionState view, final ComponentState state, final String[] args); void changeView(final ViewDefinitionState view, final ComponentState state, final String[] args); void copyFromPlanned(final ViewDefinitionState view, final ComponentState state, final String[] args); void deleteProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); static final String L_FORM; } |
@Test public final void shouldFillNewlyAddedRowsAccordingToCorrectedDaysAndDates() { stubRealizationDaysStream(PLANNED_ORDER_START, Sets.newHashSet(1, 2, 3, 4, 5, 8, 9, 10), shifts); stubRealizationDaysStream(CORRECTED_ORDER_START, Sets.newHashSet(1, 2, 3, 6, 7, 8, 9, 10), shifts); stubProgressType(ProgressType.CORRECTED); FieldComponent day1 = mockFieldComponent("1"); FieldComponent date1 = mockFieldComponent(null); FormComponent row1 = mockFormComponent(day1, date1); AwesomeDynamicListComponent row1DailyProgresses = mockDailyProgressForShiftAdl(row1); FieldComponent day2 = mockFieldComponent("3"); FieldComponent date2 = mockFieldComponent(null); FormComponent row2 = mockFormComponent(day2, date2); AwesomeDynamicListComponent row2DailyProgresses = mockDailyProgressForShiftAdl(row2); FieldComponent day3 = mockFieldComponent(null); FieldComponent date3 = mockFieldComponent(null); FormComponent row3 = mockFormComponent(day3, date3); AwesomeDynamicListComponent row3DailyProgresses = mockDailyProgressForShiftAdl(row3); FieldComponent day4 = mockFieldComponent(null); FieldComponent date4 = mockFieldComponent(null); FormComponent row4 = mockFormComponent(day4, date4); AwesomeDynamicListComponent row4DailyProgresses = mockDailyProgressForShiftAdl(row4); stubProgressForDaysAdlRows(row1, row2, row3, row4); productionPerShiftListeners.updateProgressForDays(view, progressForDaysAdl, new String[] {}); verify(day1, never()).setFieldValue(any()); verify(date1, never()).setFieldValue(any()); verify(row1DailyProgresses, never()).setFieldValue(any()); verify(day2, never()).setFieldValue(any()); verify(date2, never()).setFieldValue(any()); verify(row2DailyProgresses, never()).setFieldValue(any()); } | public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } void generateProgressForDays(final ViewDefinitionState view, final ComponentState componentState, final String[] args); void onTechnologyOperationChange(final ViewDefinitionState view, final ComponentState state, final String[] args); void savePlan(final ViewDefinitionState view, final ComponentState state, final String[] args); void refreshView(final ViewDefinitionState view, final ComponentState state, final String[] args); void changeView(final ViewDefinitionState view, final ComponentState state, final String[] args); void copyFromPlanned(final ViewDefinitionState view, final ComponentState state, final String[] args); void deleteProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } void generateProgressForDays(final ViewDefinitionState view, final ComponentState componentState, final String[] args); void onTechnologyOperationChange(final ViewDefinitionState view, final ComponentState state, final String[] args); void savePlan(final ViewDefinitionState view, final ComponentState state, final String[] args); void refreshView(final ViewDefinitionState view, final ComponentState state, final String[] args); void changeView(final ViewDefinitionState view, final ComponentState state, final String[] args); void copyFromPlanned(final ViewDefinitionState view, final ComponentState state, final String[] args); void deleteProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); static final String L_FORM; } |
@Test public final void shouldDoNothingIfPlannedDateIsNotPresent() { stubOrderStartDates(null, null, null); stubProgressType(ProgressType.PLANNED); FieldComponent day1 = mockFieldComponent(null); FieldComponent date1 = mockFieldComponent(null); FormComponent row1 = mockFormComponent(day1, date1); AwesomeDynamicListComponent row1DailyProgresses = mockDailyProgressForShiftAdl(row1); stubProgressForDaysAdlRows(row1); productionPerShiftListeners.updateProgressForDays(view, progressForDaysAdl, new String[] {}); verifyNoMoreInteractions(day1); verifyNoMoreInteractions(date1); verifyNoMoreInteractions(row1DailyProgresses); } | public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } void generateProgressForDays(final ViewDefinitionState view, final ComponentState componentState, final String[] args); void onTechnologyOperationChange(final ViewDefinitionState view, final ComponentState state, final String[] args); void savePlan(final ViewDefinitionState view, final ComponentState state, final String[] args); void refreshView(final ViewDefinitionState view, final ComponentState state, final String[] args); void changeView(final ViewDefinitionState view, final ComponentState state, final String[] args); void copyFromPlanned(final ViewDefinitionState view, final ComponentState state, final String[] args); void deleteProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } void generateProgressForDays(final ViewDefinitionState view, final ComponentState componentState, final String[] args); void onTechnologyOperationChange(final ViewDefinitionState view, final ComponentState state, final String[] args); void savePlan(final ViewDefinitionState view, final ComponentState state, final String[] args); void refreshView(final ViewDefinitionState view, final ComponentState state, final String[] args); void changeView(final ViewDefinitionState view, final ComponentState state, final String[] args); void copyFromPlanned(final ViewDefinitionState view, final ComponentState state, final String[] args); void deleteProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); static final String L_FORM; } |
@Test public final void shouldFillFirstDayForShiftThatStartsWorkDayBefore() { stubRealizationDaysStream(PLANNED_ORDER_START, Sets.newHashSet(0, 1, 2, 3, 4, 5, 8, 9, 10), shifts); stubRealizationDaysStream(CORRECTED_ORDER_START, Sets.newHashSet(1, 2, 3, 6, 7, 8, 9, 10), shifts); stubProgressType(ProgressType.PLANNED); FieldComponent day1 = mockFieldComponent(null); FieldComponent date1 = mockFieldComponent(null); FormComponent row1 = mockFormComponent(day1, date1); AwesomeDynamicListComponent row1DailyProgresses = mockDailyProgressForShiftAdl(row1); stubProgressForDaysAdlRows(row1); stubOrderDate(OrderFields.DATE_TO, null); productionPerShiftListeners.updateProgressForDays(view, progressForDaysAdl, new String[] {}); verify(day1).setFieldValue(0); verify(date1).setFieldValue(DateUtils.toDateString(PLANNED_ORDER_START.minusDays(1).toDate())); verify(row1DailyProgresses).setFieldValue(Lists.newArrayList(firstShiftDailyProgress)); } | public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } void generateProgressForDays(final ViewDefinitionState view, final ComponentState componentState, final String[] args); void onTechnologyOperationChange(final ViewDefinitionState view, final ComponentState state, final String[] args); void savePlan(final ViewDefinitionState view, final ComponentState state, final String[] args); void refreshView(final ViewDefinitionState view, final ComponentState state, final String[] args); void changeView(final ViewDefinitionState view, final ComponentState state, final String[] args); void copyFromPlanned(final ViewDefinitionState view, final ComponentState state, final String[] args); void deleteProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); } | ProductionPerShiftListeners { public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) { ProgressType progressType = detailsHooks.resolveProgressType(view); Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get(); Optional<OrderDates> maybeOrderDates = resolveOrderDates(order); if (!maybeOrderDates.isPresent()) { return; } int lastDay = -1; List<Shift> shifts = shiftsDataProvider.findAll(); LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom( progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts); AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view .getComponentByReference(PROGRESS_ADL_REF); for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) { FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue()); if (dayNum == null) { final int maxDayNum = lastDay; if (realizationDaysStream != null) { realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() { @Override public boolean apply(final OrderRealizationDay input) { return input.getRealizationDayNumber() > maxDayNum; } }); OrderRealizationDay realizationDay = realizationDaysStream.head(); setUpProgressForDayRow(progressForDayForm, realizationDay); lastDay = realizationDay.getRealizationDayNumber(); } } else { lastDay = dayNum; } } } void generateProgressForDays(final ViewDefinitionState view, final ComponentState componentState, final String[] args); void onTechnologyOperationChange(final ViewDefinitionState view, final ComponentState state, final String[] args); void savePlan(final ViewDefinitionState view, final ComponentState state, final String[] args); void refreshView(final ViewDefinitionState view, final ComponentState state, final String[] args); void changeView(final ViewDefinitionState view, final ComponentState state, final String[] args); void copyFromPlanned(final ViewDefinitionState view, final ComponentState state, final String[] args); void deleteProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args); static final String L_FORM; } |
@Test public final void shouldFailDueToMissingPpsId() { Either<String, Entity> res = ppsCorrectionReasonAppender.append(null, CORRECTION_REASON); Assert.assertTrue(res.isLeft()); Assert.assertEquals("Missing pps id!", res.getLeft()); verify(correctionReasonDataDef, never()).save(newlyCreatedReasonEntity); } | public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } |
@Test public final void shouldFailDueToMissingReason() { Either<String, Entity> res = ppsCorrectionReasonAppender.append(PPS_ID, null); Assert.assertTrue(res.isLeft()); Assert.assertEquals("Missing or blank reason type value!", res.getLeft()); verify(correctionReasonDataDef, never()).save(newlyCreatedReasonEntity); } | public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } |
@Test public final void shouldFailDueToMissingReasonValue() { Either<String, Entity> res = ppsCorrectionReasonAppender.append(PPS_ID, new PpsCorrectionReason(null)); Assert.assertTrue(res.isLeft()); Assert.assertEquals("Missing or blank reason type value!", res.getLeft()); verify(correctionReasonDataDef, never()).save(newlyCreatedReasonEntity); } | public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } |
@Test public final void shouldFailDueToEmptyReasonValue() { Either<String, Entity> res = ppsCorrectionReasonAppender.append(PPS_ID, new PpsCorrectionReason("")); Assert.assertTrue(res.isLeft()); Assert.assertEquals("Missing or blank reason type value!", res.getLeft()); verify(correctionReasonDataDef, never()).save(newlyCreatedReasonEntity); } | public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } |
@Test public final void shouldFailDueToBlankReasonValue() { Either<String, Entity> res = ppsCorrectionReasonAppender.append(PPS_ID, new PpsCorrectionReason(" ")); Assert.assertTrue(res.isLeft()); Assert.assertEquals("Missing or blank reason type value!", res.getLeft()); verify(correctionReasonDataDef, never()).save(newlyCreatedReasonEntity); } | public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } |
@Test public final void shouldFailDueToValidationErrors() { Entity invalidEntity = mockEntity(null, correctionReasonDataDef); given(invalidEntity.isValid()).willReturn(false); given(correctionReasonDataDef.save(anyEntity())).willReturn(invalidEntity); Either<String, Entity> res = ppsCorrectionReasonAppender.append(PPS_ID, CORRECTION_REASON); Assert.assertTrue(res.isLeft()); String expectedMsg = String.format("Cannot save %s.%s because of validation errors", ProductionPerShiftConstants.PLUGIN_IDENTIFIER, ProductionPerShiftConstants.MODEL_REASON_TYPE_OF_CORRECTION_PLAN); Assert.assertEquals(expectedMsg, res.getLeft()); verify(correctionReasonDataDef, times(1)).save(newlyCreatedReasonEntity); } | public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } |
@Test public void shouldReturnFalseWhenCheckIfTransfersAreValidAndTransfersNumersArentDistinct() { Entity transferConsumption1 = mockTransfer(L_NUMBER_CONSUMPTION_1, productConsumption, BigDecimal.ONE); Entity transferConsumption2 = mockTransfer(L_NUMBER_CONSUMPTION_1, productProduction, BigDecimal.ONE); stubHasManyField(transformations, TRANSFERS_CONSUMPTION, Lists.newArrayList(transferConsumption1, transferConsumption2)); boolean result = transformationsModelValidators.checkIfTransfersAreValid(transformationsDD, transformations); assertFalse(result); } | public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations); boolean checkIfLocationFromOrLocationToHasExternalNumber(final DataDefinition transformationDD,
final Entity transformation); } | TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUCTION); Iterable<Boolean> validationResults = Lists.newArrayList(areTransfersValid(transfersConsumption), areTransfersValid(transfersProduction), checkIfTransfersNumbersAreDistinct(transfersConsumption, transfersProduction), checkIfTransfersNumbersAreDistinct(transfersProduction, transfersConsumption)); return Iterables.all(validationResults, Predicates.equalTo(true)); } boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations); boolean checkIfLocationFromOrLocationToHasExternalNumber(final DataDefinition transformationDD,
final Entity transformation); } |
@Test public final void shouldAppendReason() { Entity validSavedEntity = mockEntity(null, correctionReasonDataDef); given(validSavedEntity.isValid()).willReturn(true); given(correctionReasonDataDef.save(anyEntity())).willReturn(validSavedEntity); Either<String, Entity> res = ppsCorrectionReasonAppender.append(PPS_ID, CORRECTION_REASON); Assert.assertTrue(res.isRight()); Assert.assertEquals(validSavedEntity, res.getRight()); verify(correctionReasonDataDef, times(1)).save(newlyCreatedReasonEntity); verify(newlyCreatedReasonEntity).setField(ReasonTypeOfCorrectionPlanFields.PRODUCTION_PER_SHIFT, PPS_ID.get()); verify(newlyCreatedReasonEntity).setField(ReasonTypeOfCorrectionPlanFields.REASON_TYPE_OF_CORRECTION_PLAN, CORRECTION_REASON.get()); } | public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } | PpsCorrectionReasonAppender { public Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason) { if (ppsId == null) { return Either.left("Missing pps id!"); } if (reason == null || StringUtils.isBlank(reason.get())) { return Either.left("Missing or blank reason type value!"); } return trySave(createCorrectionReason(ppsId, reason)); } @Autowired PpsCorrectionReasonAppender(final DataDefinitionService dataDefinitionService); Either<String, Entity> append(final ProductionPerShiftId ppsId, final PpsCorrectionReason reason); } |
@Test public final void shouldNotify() { LocalDate mondayDate = new LocalDate(2014, 9, 1); LocalDate tuesdayDate = new LocalDate(2014, 9, 2); DateTime orderStartDateTime = mondayDate.toDateTime(new LocalTime(23, 0, 0)); Entity shift1 = mockShiftEntity("firstShift", ImmutableSet.of(DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY)); Entity shift2 = mockShiftEntity("secondShift", ImmutableSet.of(DateTimeConstants.TUESDAY, DateTimeConstants.WEDNESDAY)); stubStringField(shift1, ShiftFields.MONDAY_HOURS, "22:00-10:00"); stubStringField(shift1, ShiftFields.TUESDAY_HOURS, "22:00-10:00"); stubStringField(shift2, ShiftFields.TUESDAY_HOURS, "10:00-20:00"); Entity pfd1 = mockProgressForDay(mondayDate, 1, ImmutableList.of(shift1, shift2)); Entity pfd2 = mockProgressForDay(tuesdayDate, 2, ImmutableList.of(shift1, shift2)); stubProgressForDayFindResults(ImmutableList.of(pfd1, pfd2)); nonWorkingShiftsNotifier.checkAndNotify(view, orderStartDateTime, mockEntity(), ProgressType.CORRECTED); verify(form).addMessage("productionPerShift.progressForDay.shiftDoesNotWork", ComponentState.MessageType.INFO, "secondShift", DateUtils.toDateString(mondayDate.toDate())); verifyNoMoreInteractions(form); } | public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime,
final Entity technologyOperation, final ProgressType progressType); } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime,
final Entity technologyOperation, final ProgressType progressType); } |
@Test public final void shouldNotifyAboutZeroDay() { LocalDate mondayDate = new LocalDate(2014, 9, 1); LocalDate tuesdayDate = new LocalDate(2014, 9, 2); DateTime orderStartDateTime = tuesdayDate.toDateTime(new LocalTime(2, 0, 0)); Entity shift1 = mockShiftEntity("firstShift", ImmutableSet.of(DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY)); Entity shift2 = mockShiftEntity("secondShift", ImmutableSet.of(DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY, DateTimeConstants.WEDNESDAY)); stubStringField(shift1, ShiftFields.MONDAY_HOURS, "22:00-10:00"); stubStringField(shift1, ShiftFields.TUESDAY_HOURS, "22:00-10:00"); stubStringField(shift2, ShiftFields.TUESDAY_HOURS, "10:00-20:00"); Entity pfd1 = mockProgressForDay(mondayDate, 0, ImmutableList.of(shift1, shift2)); Entity pfd2 = mockProgressForDay(tuesdayDate, 1, ImmutableList.of(shift1, shift2)); stubProgressForDayFindResults(ImmutableList.of(pfd1, pfd2)); nonWorkingShiftsNotifier.checkAndNotify(view, orderStartDateTime, mockEntity(), ProgressType.CORRECTED); verify(form).addMessage("productionPerShift.progressForDay.shiftDoesNotStartOrderAtZeroDay", ComponentState.MessageType.INFO, "secondShift", DateUtils.toDateString(mondayDate.toDate())); verifyNoMoreInteractions(form); } | public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime,
final Entity technologyOperation, final ProgressType progressType); } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime,
final Entity technologyOperation, final ProgressType progressType); } |
@Test public final void shouldNotNotify() { LocalDate mondayDate = new LocalDate(2014, 9, 1); LocalDate tuesdayDate = new LocalDate(2014, 9, 2); DateTime orderStartDateTime = mondayDate.toDateTime(new LocalTime(9, 0, 0)); Entity shift1 = mockShiftEntity("firstShift", ImmutableSet.of(DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY)); Entity shift2 = mockShiftEntity("secondShift", ImmutableSet.of(DateTimeConstants.TUESDAY, DateTimeConstants.WEDNESDAY)); stubStringField(shift1, ShiftFields.MONDAY_HOURS, "22:00-10:00"); stubStringField(shift1, ShiftFields.TUESDAY_HOURS, "22:00-10:00"); stubStringField(shift2, ShiftFields.TUESDAY_HOURS, "10:00-20:00"); Entity pfd1 = mockProgressForDay(mondayDate, 1, ImmutableList.of(shift1)); Entity pfd2 = mockProgressForDay(tuesdayDate, 2, ImmutableList.of(shift1, shift2)); stubProgressForDayFindResults(ImmutableList.of(pfd1, pfd2)); nonWorkingShiftsNotifier.checkAndNotify(view, orderStartDateTime, mockEntity(), ProgressType.CORRECTED); verify(form, never()).addMessage(eq("productionPerShift.progressForDay.shiftDoesNotWork"), any(ComponentState.MessageType.class), Matchers.<String> anyVararg()); verifyNoMoreInteractions(form); } | public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime,
final Entity technologyOperation, final ProgressType progressType); } | NonWorkingShiftsNotifier { public void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime, final Entity technologyOperation, final ProgressType progressType) { for (FormComponent form : view.<FormComponent> tryFindComponentByReference("form").asSet()) { List<ShiftAndDate> shiftsAndDates = getShiftAndDates(technologyOperation, progressType); for (ShiftAndDate shiftAndDate : filterShiftsNotStartingOrderAtZeroDay(orderStartDateTime, shiftsAndDates)) { notifyAboutShiftNotStartingOrderAtZeroDay(form, shiftAndDate, orderStartDateTime); } for (ShiftAndDate shiftAndDate : filterShiftsNotWorkingAtWeekday(shiftsAndDates)) { notifyAboutShiftNotWorkingAtWeekday(form, shiftAndDate); } } } void checkAndNotify(final ViewDefinitionState view, final DateTime orderStartDateTime,
final Entity technologyOperation, final ProgressType progressType); } |
@Test public void shouldReturnFalseWhenCheckIfIsMoreThatFiveDays() { given(ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report)).willReturn(10); boolean result = hooks.checkIfIsMoreThatFiveDays(reportDD, report); Assert.assertFalse(result); verify(report, times(2)).addError(Mockito.any(FieldDefinition.class), Mockito.anyString()); } | public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } | PPSReportHooks { public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } } | PPSReportHooks { public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } } | PPSReportHooks { public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report); final boolean validateDates(final DataDefinition reportDD, final Entity report); void clearGenerated(final DataDefinition reportDD, final Entity report); } | PPSReportHooks { public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report); final boolean validateDates(final DataDefinition reportDD, final Entity report); void clearGenerated(final DataDefinition reportDD, final Entity report); } |
@Test public void shouldReturnTrueWhenCheckIfIsMoreThatFiveDays() { given(ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report)).willReturn(3); boolean result = hooks.checkIfIsMoreThatFiveDays(reportDD, report); Assert.assertTrue(result); verify(report, never()).addError(Mockito.any(FieldDefinition.class), Mockito.anyString()); } | public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } | PPSReportHooks { public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } } | PPSReportHooks { public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } } | PPSReportHooks { public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report); final boolean validateDates(final DataDefinition reportDD, final Entity report); void clearGenerated(final DataDefinition reportDD, final Entity report); } | PPSReportHooks { public boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report) { int days = ppsReportXlsHelper.getNumberOfDaysBetweenGivenDates(report); if (days > 7) { report.addError(reportDD.getField(PPSReportFields.DATE_FROM), "productionPerShift.report.onlyFiveDays"); report.addError(reportDD.getField(PPSReportFields.DATE_TO), "productionPerShift.report.onlyFiveDays"); return false; } return true; } boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report); final boolean validateDates(final DataDefinition reportDD, final Entity report); void clearGenerated(final DataDefinition reportDD, final Entity report); } |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.