src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
PropertyUtils { public static void setProperty(Object bean, String name, Object value) { requireNonNull(bean, "bean cannot be null"); requireNonNull(name, "name cannot be null"); Class<?> beanClass = bean.getClass(); try { PropertyDescriptor descriptor = findPropertyDescriptor(beanClass, name); Method writeMethod = des...
@Test public void shouldSetProperties() { Bean bean = new Bean(); setProperty(bean, "intValue", 1); assertThat(bean.getIntValue()).isEqualTo(1); setProperty(bean, "stringValue", "string"); assertThat(bean.getStringValue()).isEqualTo("string"); Bean beanValue = new Bean(); setProperty(bean, "beanValue", beanValue); asse...
JaxbConverter implements TypeConverter<T> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class && ((AnnotatedElement) type).getAnnotation(XmlRootElement.class) != null; } @Override boolean isApplicable(Type type, ...
@Test public void shouldBeApplicableForMultipleXmlTypes() { assertThat(jaxbTypeConverter.isApplicable(XmlRootConfiguration01.class, null)).isTrue(); assertThat(jaxbTypeConverter.isApplicable(XmlRootConfiguration02.class, null)).isTrue(); } @Test public void shouldNotBeApplicableForNonXmlTypes() { assertThat(jaxbTypeCon...
PropertyUtils { public static String getPropertyName(Method method) { requireNonNull(method, "method cannot be null"); String name = method.getName(); if (name.startsWith("set")) { if (method.getParameterCount() != 1) { throw new IllegalArgumentException("Method " + method + " is not a valid setter."); } name = name.su...
@Test public void getPropertyNameShouldProvidePropertyNameFromValidAccessor() { assertThat(getPropertyName(getMethod(Bean.class, "getIntValue"))).isEqualTo("intValue"); assertThat(getPropertyName(getMethod(Bean.class, "setIntValue"))).isEqualTo("intValue"); assertThat(getPropertyName(getMethod(Bean.class, "getStringVal...
MultiConfigurationSource implements ConfigurationSource { @Override public OptionalValue<String> getValue(String key, Map<String, String> attributes) { requireNonNull(key, "key cannot be null"); for (ConfigurationSource source : sources) { OptionalValue<String> value = source.getValue(key, attributes); if (value.isPres...
@Test public void shouldReturnValuesFromProperSource() { assertThat(source.getValue(A_KEY, null).get()).isEqualTo(A_KEY); assertThat(source.getValue(B_KEY, null).get()).isEqualTo(B_KEY); }
MultiConfigurationSource implements ConfigurationSource { @Override public ConfigurationEntry findEntry(Collection<String> keys, Map<String, String> attributes) { requireNonNull(keys, "keys cannot be null"); for (ConfigurationSource source : sources) { ConfigurationEntry entry = source.findEntry(keys, attributes); if (...
@Test public void shouldFindValuesInProperSource() { assertThat(source.findEntry(asList("NotExistingKey", B_KEY), null)).isEqualTo(new ConfigurationEntry(B_KEY, B_KEY)); }
MapConfigurationSource implements IterableConfigurationSource { @Override public OptionalValue<String> getValue(String key, Map<String, String> attributes) { requireNonNull(key, "key cannot be null"); String value = source.get(key); return value != null || source.containsKey(key) ? present(value) : absent(); } MapConfi...
@Test public void shouldGetSingleValueFromUnderlyingMap() { ConfigurationSource source = new MapConfigurationSource(of("key1", "value1", "key2", "value2")); String value = source.getValue("key2", null).get(); assertThat(value).isEqualTo("value2"); }
MapConfigurationSource implements IterableConfigurationSource { @Override public Iterable<ConfigurationEntry> getAllConfigurationEntries() { return new MapConfigurationEntryIterable(source); } MapConfigurationSource(Map<String, String> source); @Override OptionalValue<String> getValue(String key, Map<String, String> at...
@Test public void shouldIterateOver() { MapConfigurationSource source = new MapConfigurationSource(of("key1", "value1", "key2", "value2")); Iterable<ConfigurationEntry> iterable = source.getAllConfigurationEntries(); assertThat(iterable).containsExactly(new ConfigurationEntry("key1", "value1"), new ConfigurationEntry("...
WritableMapConfigurationSource extends MapConfigurationSource implements WritableConfigurationSource { @Override public void setValue(String key, String value, Map<String, String> attributes) { requireNonNull(key, "key cannot be null"); source.put(key, value); } WritableMapConfigurationSource(Map<String, String> source...
@Test public void shouldSetAndGetValue() { WritableConfigurationSource mapConfigurationSource = new WritableMapConfigurationSource(new HashMap<>()); mapConfigurationSource.setValue("key", "value", null); OptionalValue<String> value = mapConfigurationSource.getValue("key", null); assertThat(value.isPresent()).isTrue(); ...
MatchingChangeoverNormsDetailsListeners { public void matchingChangeoverNorm(final ViewDefinitionState viewDefinitionState, final ComponentState state, final String[] args) { Entity fromTechnology = ((LookupComponent) viewDefinitionState.getComponentByReference(MATCHING_FROM_TECHNOLOGY)) .getEntity(); Entity toTechnolo...
@Test public void shouldClearFieldAndDisabledButtonWhenMatchingChangeoverNormWasnotFound() throws Exception { when(changeoverNormsService.getMatchingChangeoverNorms(fromTechnology, toTechnology, productionLine)).thenReturn(null); when(view.getComponentByReference(NUMBER)).thenReturn(number); when(view.getComponentByRef...
AbstractStateChangeAspect implements StateChangeService { @Override public void changeState(final StateChangeContext stateChangeContext) { try { performStateChange(stateChangeContext); } catch (Exception exception) { LOGGER.warn("Can't perform state change", exception); stateChangeContext.setStatus(StateChangeStatus.FA...
@Test public final void shouldNotPerformEntityStateChangeIfOwnerHasValidationErrors() { AlmostRealStateChangeService stateChangeService = new AlmostRealStateChangeService(); given(stateChangeContext.isOwnerValid()).willReturn(true, false); stateChangeService.changeState(stateChangeContext); verify(stateChangeContext).s...
ProductionTrackingDetailsHooks { public void initializeProductionTrackingDetailsView(final ViewDefinitionState view) { FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(L_FORM); FieldComponent stateField = (FieldComponent) view.getComponentByReference(ProductionTrackingFields.STATE); L...
@Test public void shouldSetStateToDraftWhenInitializeTrackingDetailsViewIfProductionTrackingIsntSaved() { given(productionTrackingForm.getEntityId()).willReturn(null); given(productionTrackingForm.getEntity()).willReturn(productionTracking); given(productionTracking.getField(ProductionTrackingFields.STATE)).willReturn(...
ProductionTrackingServiceImpl implements ProductionTrackingService { @Override public void setTimeAndPieceworkComponentsVisible(final ViewDefinitionState view, final Entity order) { String recordingType = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); boolean recordingTypeEqualsForEach = TypeOfProduc...
@Test public void shouldNotSetTimeAndPieceworkTabVisibleIfTypeIsBasic() { String typeOfProductionRecording = TypeOfProductionRecording.BASIC.getStringValue(); given(order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)).willReturn(typeOfProductionRecording); given(order.getBooleanField(OrderFieldsPC.REGISTER...
OrderClosingHelper { public boolean orderShouldBeClosed(final Entity productionTracking) { Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER); if (order == null) { return false; } Boolean autoCloseOrder = order.getBooleanField(OrderFieldsPC.AUTO_CLOSE_ORDER); Boolean isLastRecord = prod...
@Test public final void shouldOrderCanBeClosedWhenTypeIsCummulativeAndAcceptingLastRecord() { orderHasEnabledAutoClose(); stubTypeOfProductionRecording(TypeOfProductionRecording.CUMULATED); productionTrackingIsLast(); boolean shouldClose = orderClosingHelper.orderShouldBeClosed(productionTracking); assertTrue(shouldClo...
AvgLaborCostCalcForOrderDetailsHooks { public void enabledButtonForCopyNorms(final ViewDefinitionState view) { WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonActionItem copyToOperationsNorms = window.getRibbon().getGroupByName("hourlyCostNorms") .getItemByName("copyToOperations...
@Test public void shouldEnabledButtonForCopyNorms() throws Exception { String averageLaborHourlyCostValue = "50"; when(averageLaborHourlyCost.getFieldValue()).thenReturn(averageLaborHourlyCostValue); orderDetailsHooks.enabledButtonForCopyNorms(view); Mockito.verify(copyToOperationsNorms).setEnabled(true); } @Test publi...
GenerateProductionBalanceWithCosts implements Observer { public void doTheCostsPart(final Entity productionBalance) { Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY); Entity productionLine = order.getBelongsToField(Or...
@Test public void shouldSetQuantityTechnologyProductionLineAndTechnicalProductionCostPerUnitFieldsAndSaveEntity() { BigDecimal quantity = BigDecimal.TEN; BigDecimal doneQuantity = BigDecimal.TEN; given(productionBalance.getDecimalField(ProductionBalanceFieldsPCWC.TOTAL_TECHNICAL_PRODUCTION_COSTS)).willReturn( BigDecima...
GenerateProductionBalanceWithCosts implements Observer { void generateBalanceWithCostsReport(final Entity productionBalance) { Locale locale = LocaleContextHolder.getLocale(); String localePrefix = "productionCounting.productionBalanceWithCosts.report.fileName"; Entity productionBalanceWithFileName = fileService.update...
@Test public void shouldGenerateReportCorrectly() throws Exception { Locale locale = Locale.getDefault(); String localePrefix = "productionCounting.productionBalanceWithCosts.report.fileName"; Entity productionBalanceWithFileName = mock(Entity.class); given(productionBalanceWithFileName.getDataDefinition()).willReturn(...
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", loc...
@Test public void shouldAddTimeBalanceAndProductionCostsIfTypeCumulatedAndHourly() throws Exception { String typeOfProductionRecording = TypeOfProductionRecording.CUMULATED.getStringValue(); String calculateOperationCostMode = CalculateOperationCostMode.HOURLY.getStringValue(); given(order.getStringField(OrderFieldsPC....
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; }...
@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); } @Test public void ...
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.equ...
@Test public void shouldReturnWhenOperationIsNull() throws Exception { costNormsForOperationService.copyCostValuesFromOperation(view, state, null); } @Test public void shouldApplyCostNormsForGivenSource() throws Exception { when(state.getFieldValue()).thenReturn(1L); Long operationId = 1L; when(operationDD.get(operatio...
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() == ...
@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, param...
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) { ...
@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); } @Test ...
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")...
@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...
TechnologyGroupDetailsViewHooks { public void addTechnologyGroupToProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent technologyGroupForm = (FormComponent) view.getComponentByReference("form"); Entity technologyGroup = technologyGroupForm.getEntity(); if (te...
@Test public void shouldntAddTechnologyGroupToProductIfTechnologyGroupIsntSaved() { given(technologyGroup.getId()).willReturn(null); technologyGroupDetailsViewHooks.addTechnologyGroupToProduct(view, null, null); verify(product, never()).setField("technologyGroup", technologyGroup); verify(productDD, never()).save(produ...
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_COMPONE...
@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")).willR...
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(data...
@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.g...
CostNormsForOperationService { public void fillCurrencyFields(final ViewDefinitionState view) { String currencyStringCode = currencyService.getCurrencyAlphabeticCode(); FieldComponent component = null; for (String componentReference : Sets.newHashSet("pieceworkCostCURRENCY", "laborHourlyCostCURRENCY", "machineHourlyCos...
@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...
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()....
@Test public void shouldReturnFalseAndAddErrorWhenValidateStockCorrectionIfLocationIsntNullAndLocationTypeIsntControlPoint() { given(stockCorrection.getBelongsToField(LOCATION)).willReturn(location); given(location.getStringField(TYPE)).willReturn("otherLocation"); boolean result = stockCorrectionModelValidators.valida...
ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities =...
@Test(expected = IllegalStateException.class) public void shouldReturnIllegalStateExceptionIfTheresNoTechnology() { when(order.getBelongsToField("technology")).thenReturn(null); productQuantitiesService.getProductComponentQuantities(order); } @Test public void shouldReturnCorrectQuantities() { OperationProductComponent...
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> n...
@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), product...
ProductQuantitiesServiceImpl implements ProductQuantitiesService { @Override public Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components, final MrpAlgorithm mrpAlgorithm) { return getNeededProductQuantitiesForComponents(components, mrpAlgorithm, false); } @Override ProductQuantit...
@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_...
ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity desiredWorkst...
@Test public void shouldReturnCorrectWorkstationCount() { given(operation.getBelongsToField("workstationType")).willReturn(work2); Integer workstationCount = productionLinesServiceImpl.getWorkstationTypesCount(opComp1, productionLine); assertEquals(Integer.valueOf(234), workstationCount); } @Test public void shouldRetu...
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 shouldReturnTechnology() { Entity technologyFromDb = mockEntity(); stubDataDefGetResult(technologyFromDb); Optional<Entity> res = technologyDataProvider.tryFind(1L); Assert.assertEquals(Optional.of(technologyFromDb), res); } @Test public final void shouldReturnEmptyIfIdIsMissing() { Optional<Ent...
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 ...
@Test public final void shouldGenerateNumber() { Entity product = mockEntity(); stubStringField(product, ProductFields.NUMBER, "SomeProductNumber"); technologyNameAndNumberGenerator.generateNumber(product); verify(numberGeneratorService).generateNumberWithPrefix(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesCons...
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(...
@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.g...
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...
@Test public final void shouldThrowExceptionWhenTryToAddProductWithIncorrectTypeToOutputProductComponent() { performWrongTypeProductTest(buildOpoc()); verify(wrappedEntity, Mockito.never()).setField(OperationProductInComponentFields.PRODUCT, product); } @Test public final void shouldThrowExceptionWhenTryToAddProductWit...
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, numberSe...
@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(TechnologyOperationC...
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.i...
@Test public final void shouldReturnEmptyMapForNullTree() { resultMap = technologyTreeValidationService.checkConsumingManyProductsFromOneSubOp(null); assertNotNull(resultMap); assertTrue(resultMap.isEmpty()); } @Test public final void shouldReturnEmptyMapForEmptyTree() { given(tree.isEmpty()).willReturn(true); resultMa...
TechnologyTreeValidationServiceImpl implements TechnologyTreeValidationService { @Override public Map<String, Set<Entity>> checkConsumingTheSameProductFromManySubOperations(final EntityTree technologyTree) { Map<String, Set<Entity>> parentToProductsMap = Maps.newHashMap(); if (technologyTree != null && !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); Ent...
TransformationsModelValidators { public boolean checkIfTransfersAreValid(final DataDefinition transformationsDD, final Entity transformations) { List<Entity> transfersConsumption = transformations.getHasManyField(TRANSFERS_CONSUMPTION); List<Entity> transfersProduction = transformations.getHasManyField(TRANSFERS_PRODUC...
@Test public void shouldReturnFalseWhenCheckIfTransfersAreValidAndTransfersArentNull() { Entity transferConsumption = mockTransfer(null, null, null); Entity transferProduction = mockTransfer(null, null, null); stubHasManyField(transformations, TRANSFERS_CONSUMPTION, Lists.newArrayList(transferConsumption)); stubHasMany...
TechnologyService { public BigDecimal getProductCountForOperationComponent(final Entity operationComponent) { return getMainOutputProductComponent(operationComponent).getDecimalField(L_QUANTITY); } void copyCommentAndAttachmentFromLowerInstance(final Entity technologyOperationComponent, final String belongsToName); bo...
@Test public void shouldReturnOutputProductCountForOperationComponent() { BigDecimal count = technologyService.getProductCountForOperationComponent(opComp2); assertEquals(new BigDecimal(10), count); } @Test public void shouldThrowAnExceptionIfThereAreNoProductsOrIntermediates() { EntityList opComp2prodOuts = mockEntity...
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.cr...
@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[]...
LineChangeoverNormsHooks { public boolean checkUniqueNorms(final DataDefinition changeoverNormDD, final Entity changeoverNorm) { SearchCriteriaBuilder searchCriteriaBuilder = dataDefinitionService .get(LineChangeoverNormsConstants.PLUGIN_IDENTIFIER, LineChangeoverNormsConstants.MODEL_LINE_CHANGEOVER_NORMS) .find() .add...
@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); g...
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 = ...
@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.PLANNE...
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!"); } r...
@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); } @Test publi...
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 = ...
@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, DateTimeCons...
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...
@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), Mo...
PPSReportHooks { public void clearGenerated(final DataDefinition reportDD, final Entity report) { report.setField(PPSReportFields.GENERATED, false); report.setField(PPSReportFields.FILE_NAME, null); } boolean checkIfIsMoreThatFiveDays(final DataDefinition reportDD, final Entity report); final boolean validateDates(fin...
@Test public void shouldClearGenerated() { hooks.clearGenerated(reportDD, report); verify(report, times(2)).setField(Mockito.anyString(), Mockito.any()); }
PPSReportDetailsHooks { public void disableFields(final ViewDefinitionState view) { FormComponent form = (FormComponent) view.getComponentByReference(L_FORM); Long reportId = form.getEntityId(); if (reportId == null) { setFieldsState(view, REPORT_FIELDS, true); } else { Entity report = getReportFromDb(reportId); if (re...
@Test public void shouldntDisableFieldsWhenEntityIsntSaved() { given(view.getComponentByReference(L_FORM)).willReturn(reportForm); given(view.getComponentByReference(PPSReportFields.NUMBER)).willReturn(fieldComponent); given(view.getComponentByReference(PPSReportFields.NAME)).willReturn(fieldComponent); given(view.getC...
ProductionPerShiftDetailsHooks { void fillTechnologyOperationLookup(final ViewDefinitionState view, final Entity technology) { LookupComponent technologyOperationLookup = (LookupComponent) view.getComponentByReference(OPERATION_LOOKUP_REF); for (Entity rootOperation : technologyOperationDataProvider.findRoot(technology...
@Test public void shouldAddRootForOperation() throws Exception { final Long rootOperationId = 2L; LookupComponent technologyOperationLookup = mockLookup(mockEntity()); stubViewComponent(OPERATION_LOOKUP_REF, technologyOperationLookup); Entity rootOperation = mockEntity(rootOperationId); given(technologyOperationDataPro...
ProductionPerShiftDetailsHooks { void setupProgressTypeComboBox(final ViewDefinitionState view, final OrderState orderState, final ProgressType progressType) { FieldComponent plannedProgressType = (FieldComponent) view.getComponentByReference(PROGRESS_TYPE_COMBO_REF); plannedProgressType.setFieldValue(progressType.getS...
@Test public void shouldEnabledPlannedProgressTypeForInProgressOrder() throws Exception { ProgressType progressType = ProgressType.PLANNED; productionPerShiftDetailsHooks.setupProgressTypeComboBox(view, OrderState.IN_PROGRESS, progressType); verify(progressTypeComboBox).setFieldValue(progressType.getStringValue()); ver...
ProductionPerShiftDetailsHooks { void fillOrderDateComponents(final ViewDefinitionState view, final Entity order) { for (ImmutableMap.Entry<String, String> modelFieldToViewReference : ORDER_DATE_FIELDS_TO_VIEW_COMPONENTS.entrySet()) { FieldComponent dateComponent = (FieldComponent) view.getComponentByReference(modelFie...
@Test public void shouldSetOrderStartDatesWhenPlannedDateExists() throws Exception { ComponentState plannedDateField = mockFieldComponent(null); ComponentState correctedDateField = mockFieldComponent(null); ComponentState effectiveDateField = mockFieldComponent(null); stubViewComponent(PLANNED_START_DATE_TIME_REF, plan...
ProductionPerShiftDetailsHooks { public void setProductAndFillProgressForDays(final ViewDefinitionState view) { Entity order = getEntityFromLookup(view, "order").get(); OrderState orderState = OrderState.of(order); ProgressType progressType = resolveProgressType(view); AwesomeDynamicListComponent progressForDaysADL = (...
@Test public void shouldFillProgressesADL() throws Exception { Entity technologyOperation = mockEntity(3L); stubViewComponent(OPERATION_LOOKUP_REF, mockLookup(technologyOperation)); LookupComponent producedProductLookup = mockLookup(null); stubViewComponent(PRODUCED_PRODUCT_LOOKUP_REF, producedProductLookup); long prod...
ProductionPerShiftDetailsHooks { void disableComponents(final AwesomeDynamicListComponent progressForDaysADL, final ProgressType progressType, final OrderState orderState) { boolean isEnabled = (progressType == ProgressType.CORRECTED || orderState == OrderState.PENDING) && !UNSUPPORTED_ORDER_STATES.contains(orderState)...
@Test public void shouldDisableDailyProgressRowsForLockedEntities() { FormComponent firstPfdFirstDailyForm = mockForm(mockEntity()); FormComponent firstPfdSecondDailyForm = mockForm(mockLockedEntity()); AwesomeDynamicListComponent firstPfdDailyAdl = mock(AwesomeDynamicListComponent.class); given(firstPfdDailyAdl.getFor...
TechnologyOperationComponentValidatorsPPS { public boolean checkGrowingNumberOfDays(final DataDefinition technologyOperationComponentDD, final Entity technologyOperationComponent) { List<Entity> progressForDays = technologyOperationComponent .getHasManyField(TechnologyOperationComponentFieldsPPS.PROGRESS_FOR_DAYS); if ...
@Test public void shouldReturnTrueWhenProgressForDayHMIsEmpty() { given(technologyOperationComponent.getHasManyField(TechnologyOperationComponentFieldsPPS.PROGRESS_FOR_DAYS)).willReturn( progressForDays); given(progressForDays.isEmpty()).willReturn(true); boolean result = technologyOperationComponentValidatorsPPS.check...
PPSHelper { public Long getPpsIdForOrder(final Long orderId) { DataDefinition ppsDateDef = getProductionPerShiftDD(); String query = "select id as ppsId from #productionPerShift_productionPerShift where order.id = :orderId"; Entity projectionResults = ppsDateDef.find(query).setLong("orderId", orderId).setMaxResults(1)....
@Test public final void shouldGetPpsForOrderReturnExistingPpsId() { Long givenOrderId = 1L; Long expectedPpsId = 50L; given( dataDefinitionService.get(ProductionPerShiftConstants.PLUGIN_IDENTIFIER, ProductionPerShiftConstants.MODEL_PRODUCTION_PER_SHIFT)).willReturn(dataDefinition); SearchQueryBuilder searchCriteriaBuil...
OrderRealizationDaysResolver { public OrderRealizationDay find(final DateTime orderStartDateTime, final int startingFrom, final boolean isFirstDay, final List<Shift> shifts) { OrderRealizationDay firstWorkingDay = findFirstWorkingDayFrom(orderStartDateTime.toLocalDate(), startingFrom, shifts); if (isFirstDay) { return ...
@Test public final void shouldResolveRealizationDay1() { DateTime startDate = new DateTime(2014, 8, 14, 10, 0, 0); List<Shift> shifts = ImmutableList.of(shift1, shift2, shift3); OrderRealizationDay realizationDay = orderRealizationDaysResolver.find(startDate, 1, true, shifts); assertRealizationDayState(realizationDay, ...
OrderRealizationDaysResolver { public LazyStream<OrderRealizationDay> asStreamFrom(final DateTime orderStartDateTime, final List<Shift> shifts) { OrderRealizationDay firstDay = find(orderStartDateTime, 1, true, shifts); return LazyStream.create(firstDay, prevElement -> find(orderStartDateTime, prevElement.getRealizatio...
@Test public final void shouldProduceStreamWithCorrectFirstDayDate() { DateTime startDate = new DateTime(2014, 12, 4, 23, 0, 0); List<Shift> shifts = ImmutableList.of(shift1, shift2, shift3); LazyStream<OrderRealizationDay> stream = orderRealizationDaysResolver.asStreamFrom(startDate, shifts); Optional<OrderRealization...
TransferDetailsViewHooks { public void checkIfTransferHasTransformations(final ViewDefinitionState view) { FormComponent transferForm = (FormComponent) view.getComponentByReference(L_FORM); Long transferId = transferForm.getEntityId(); if (transferId == null) { return; } Entity transfer = dataDefinitionService .get(Mat...
@Test public void shouldReturnWhenCheckIfTransferHasTransformationsAndNumberIsNull() { given(view.getComponentByReference(L_FORM)).willReturn(transferForm); given(view.getComponentByReference(TYPE)).willReturn(typeField); given(view.getComponentByReference(TIME)).willReturn(typeField); given(view.getComponentByReferenc...
DeliveriesColumnLoaderTSFD { public void addColumnsForDeliveriesTSFD() { if (LOG.isDebugEnabled()) { LOG.debug("Columns for deliveries table will be populated ..."); } deliveriesColumnLoaderService.fillColumnsForDeliveries(TechSubcontrForDeliveriesConstants.PLUGIN_IDENTIFIER); } void addColumnsForDeliveriesTSFD(); voi...
@Test public void shouldAddColumnsForDeliveriesTSFD() { deliveriesColumnLoaderTSFD.addColumnsForDeliveriesTSFD(); verify(deliveriesColumnLoaderService).fillColumnsForDeliveries(Mockito.anyString()); }
DeliveriesColumnLoaderTSFD { public void deleteColumnsForDeliveriesTSFD() { if (LOG.isDebugEnabled()) { LOG.debug("Columns for deliveries table will be unpopulated ..."); } deliveriesColumnLoaderService.clearColumnsForDeliveries(TechSubcontrForDeliveriesConstants.PLUGIN_IDENTIFIER); } void addColumnsForDeliveriesTSFD(...
@Test public void shouldDeleteTSFDcolumnsForDeliveries() { deliveriesColumnLoaderTSFD.deleteColumnsForDeliveriesTSFD(); verify(deliveriesColumnLoaderService).clearColumnsForDeliveries(Mockito.anyString()); }
DeliveriesColumnLoaderTSFD { public void addColumnsForOrdersTSFD() { if (LOG.isDebugEnabled()) { LOG.debug("Columns for orders table will be populated ..."); } deliveriesColumnLoaderService.fillColumnsForOrders(TechSubcontrForDeliveriesConstants.PLUGIN_IDENTIFIER); } void addColumnsForDeliveriesTSFD(); void deleteColu...
@Test public void shouldAddColumnsForOrdersTSFD() { deliveriesColumnLoaderTSFD.addColumnsForOrdersTSFD(); verify(deliveriesColumnLoaderService).fillColumnsForOrders(Mockito.anyString()); }
DeliveriesColumnLoaderTSFD { public void deleteColumnsForOrdersTSFD() { if (LOG.isDebugEnabled()) { LOG.debug("Columns for orders table will be unpopulated ..."); } deliveriesColumnLoaderService.clearColumnsForOrders(TechSubcontrForDeliveriesConstants.PLUGIN_IDENTIFIER); } void addColumnsForDeliveriesTSFD(); void dele...
@Test public void shouldDeleteColumnsForOrdersTSFD() { deliveriesColumnLoaderTSFD.deleteColumnsForOrdersTSFD(); verify(deliveriesColumnLoaderService).clearColumnsForOrders(Mockito.anyString()); }
TechSubcontrForDeliveriesOnStartupService extends Module { @Transactional @Override public void multiTenantEnable() { deliveriesColumnLoaderTSFD.addColumnsForDeliveriesTSFD(); deliveriesColumnLoaderTSFD.addColumnsForOrdersTSFD(); } @Transactional @Override void multiTenantEnable(); @Transactional @Override void multiT...
@Test public void shouldMultiTenantEnable() { techSubcontrForDeliveriesOnStartupService.multiTenantEnable(); verify(deliveriesColumnLoaderTSFD).addColumnsForDeliveriesTSFD(); verify(deliveriesColumnLoaderTSFD).addColumnsForOrdersTSFD(); }
TechSubcontrForDeliveriesOnStartupService extends Module { @Transactional @Override public void multiTenantDisable() { deliveriesColumnLoaderTSFD.deleteColumnsForDeliveriesTSFD(); deliveriesColumnLoaderTSFD.deleteColumnsForOrdersTSFD(); } @Transactional @Override void multiTenantEnable(); @Transactional @Override void...
@Test public void shouldMultiTenantDisable() { techSubcontrForDeliveriesOnStartupService.multiTenantDisable(); verify(deliveriesColumnLoaderTSFD).deleteColumnsForDeliveriesTSFD(); verify(deliveriesColumnLoaderTSFD).deleteColumnsForOrdersTSFD(); }
CostCalculationValidators { public boolean checkIfTheTechnologyHasCorrectState(final DataDefinition costCalculationDD, final Entity costCalculation) { Entity technology = costCalculation.getBelongsToField(CostCalculationFields.TECHNOLOGY); String state = technology.getStringField(TechnologyFields.STATE); if (Technology...
@Test public void shouldTechnologyHasIncorrectState() { given(costCalculation.getBelongsToField(CostCalculationFields.TECHNOLOGY)).willReturn(technology); given(technology.getStringField(TechnologyFields.STATE)).willReturn(TechnologyStateStringValues.DRAFT); boolean result = costCalculationValidators.checkIfTheTechnolo...
CostCalculationValidators { public boolean checkIfCurrentGlobalIsSelected(final DataDefinition costCalculationDD, final Entity costCalculation) { String sourceOfMaterialCosts = costCalculation.getStringField(CostCalculationFields.SOURCE_OF_MATERIAL_COSTS); String calculateMaterialCostsMode = costCalculation.getStringFi...
@Test public void shouldReturnFalseWhenCurrencyGlobalIsSelected() throws Exception { given(costCalculation.getStringField(CostCalculationFields.SOURCE_OF_MATERIAL_COSTS)).willReturn( SourceOfMaterialCosts.CURRENT_GLOBAL_DEFINITIONS_IN_PRODUCT.getStringValue()); given(costCalculation.getStringField(CostCalculationFields...
StaffDetailsHooks { public void enabledIndividualCost(final ViewDefinitionState view) { FieldComponent individual = (FieldComponent) view.getComponentByReference("determinedIndividual"); FieldComponent individualLaborCost = (FieldComponent) view.getComponentByReference("individualLaborCost"); if (individual.getFieldVal...
@Test public void shouldEnabledFieldWhenCheckBoxIsSelected() throws Exception { String result = "1"; when(view.getComponentByReference("determinedIndividual")).thenReturn(field1); when(view.getComponentByReference("individualLaborCost")).thenReturn(field2); when(field1.getFieldValue()).thenReturn(result); detailsHooks....
StaffDetailsHooks { public void setCurrency(final ViewDefinitionState view) { FieldComponent laborHourlyCostUNIT = (FieldComponent) view.getComponentByReference("individualLaborCostCURRENCY"); FieldComponent laborCostFromWageGroupsUNIT = (FieldComponent) view .getComponentByReference("laborCostFromWageGroupsCURRENCY");...
@Test public void shouldFillFieldCurrency() throws Exception { String currency = "PLN"; when(view.getComponentByReference("individualLaborCostCURRENCY")).thenReturn(field1); when(view.getComponentByReference("laborCostFromWageGroupsCURRENCY")).thenReturn(field2); when(currencyService.getCurrencyAlphabeticCode()).thenRe...
StaffDetailsHooks { public void fillFieldAboutWageGroup(final ViewDefinitionState view) { LookupComponent lookup = (LookupComponent) view.getComponentByReference("wageGroup"); Entity wageGroup = lookup.getEntity(); FieldComponent laborCostFromWageGroups = (FieldComponent) view.getComponentByReference("laborCostFromWage...
@Test public void shouldFillFieldValuesOfSelectedWageGroup() throws Exception { String superiorWageGroup = "1234"; when(view.getComponentByReference("wageGroup")).thenReturn(lookup); when(lookup.getEntity()).thenReturn(wageGroup); when(view.getComponentByReference("laborCostFromWageGroups")).thenReturn(field1); when(vi...
WageGroupsDetailsHooks { public void setCurrency(final ViewDefinitionState view) { FieldComponent individualLaborCostUNIT = (FieldComponent) view .getComponentByReference(WageGroupFields.LABOR_HOURLY_COST_CURRENCY); individualLaborCostUNIT.setFieldValue(currencyService.getCurrencyAlphabeticCode()); individualLaborCostU...
@Test public void shouldFillFieldWithCurrency() throws Exception { String currency = "pln"; when(view.getComponentByReference("laborHourlyCostCURRENCY")).thenReturn(field); when(currencyService.getCurrencyAlphabeticCode()).thenReturn(currency); hooks.setCurrency(view); Mockito.verify(field).setFieldValue(currency); }
StaffHooks { public void saveLaborHourlyCost(final DataDefinition dataDefinition, final Entity entity) { boolean individual = entity.getBooleanField(DETERMINED_INDIVIDUAL); if (individual) { entity.setField("laborHourlyCost", entity.getField(INDIVIDUAL_LABOR_COST)); } else { Entity wageGroup = entity.getBelongsToField(...
@Test public void shouldSaveIndividualCost() throws Exception { when(entity.getBooleanField(DETERMINED_INDIVIDUAL)).thenReturn(true); when(entity.getField(INDIVIDUAL_LABOR_COST)).thenReturn(BigDecimal.ONE); hooks.saveLaborHourlyCost(dataDefinition, entity); Mockito.verify(entity).setField("laborHourlyCost", BigDecimal....
DeliveriesColumnLoaderCNID { public void addColumnsForDeliveriesCNID() { if (LOG.isDebugEnabled()) { LOG.debug("Columns for deliveries table will be populated ..."); } deliveriesColumnLoaderService.fillColumnsForDeliveries(CatNumbersInDeliveriesConstants.PLUGIN_IDENTIFIER); } void addColumnsForDeliveriesCNID(); void d...
@Test public void shouldAddColumnsForDeliveriesCNID() { deliveriesColumnLoaderCNID.addColumnsForDeliveriesCNID(); verify(deliveriesColumnLoaderService).fillColumnsForDeliveries(Mockito.anyString()); }
DeliveriesColumnLoaderCNID { public void deleteColumnsForDeliveriesCNID() { if (LOG.isDebugEnabled()) { LOG.debug("Columns for deliveries table will be unpopulated ..."); } deliveriesColumnLoaderService.clearColumnsForDeliveries(CatNumbersInDeliveriesConstants.PLUGIN_IDENTIFIER); } void addColumnsForDeliveriesCNID(); ...
@Test public void shouldDeleteColumnsForDeliveriesCNID() { deliveriesColumnLoaderCNID.deleteColumnsForDeliveriesCNID(); verify(deliveriesColumnLoaderService).clearColumnsForDeliveries(Mockito.anyString()); }
DeliveriesColumnLoaderCNID { public void addColumnsForOrdersCNID() { if (LOG.isDebugEnabled()) { LOG.debug("Columns for orders table will be populated ..."); } deliveriesColumnLoaderService.fillColumnsForOrders(CatNumbersInDeliveriesConstants.PLUGIN_IDENTIFIER); } void addColumnsForDeliveriesCNID(); void deleteColumns...
@Test public void shouldAddColumnsForOrdersCNID() { deliveriesColumnLoaderCNID.addColumnsForOrdersCNID(); verify(deliveriesColumnLoaderService).fillColumnsForOrders(Mockito.anyString()); }
DeliveriesColumnLoaderCNID { public void deleteColumnsForOrdersCNID() { if (LOG.isDebugEnabled()) { LOG.debug("Columns for deliveries table will be unpopulated ..."); } deliveriesColumnLoaderService.clearColumnsForOrders(CatNumbersInDeliveriesConstants.PLUGIN_IDENTIFIER); } void addColumnsForDeliveriesCNID(); void del...
@Test public void shouldDeleteColumnsForOrdersCNID() { deliveriesColumnLoaderCNID.deleteColumnsForOrdersCNID(); verify(deliveriesColumnLoaderService).clearColumnsForOrders(Mockito.anyString()); }
OrderedProductHooksCNID { public void updateOrderedProductCatalogNumber(final DataDefinition orderedProductDD, final Entity orderedProduct) { catNumbersInDeliveriesService.updateProductCatalogNumber(orderedProduct); } void updateOrderedProductCatalogNumber(final DataDefinition orderedProductDD, final Entity orderedPro...
@Test public void shouldUpdateOrderedProductCatalogNumber() { orderedProductHooksCNID.updateOrderedProductCatalogNumber(orderedProductDD, orderedProduct); verify(catNumbersInDeliveriesService).updateProductCatalogNumber(orderedProduct); }
DeliveredProductHooksCNID { public void updateDeliveredProductCatalogNumber(final DataDefinition deliveredProductDD, final Entity deliveredProduct) { catNumbersInDeliveriesService.updateProductCatalogNumber(deliveredProduct); } void updateDeliveredProductCatalogNumber(final DataDefinition deliveredProductDD, final Ent...
@Test public void shouldUpdateDeliveredProductCatalogNumber() { deliveredProductHooksCNID.updateDeliveredProductCatalogNumber(deliveredProductDD, deliveredProduct); verify(catNumbersInDeliveriesService).updateProductCatalogNumber(deliveredProduct); }
DeliveryHooksCNID { public void updateOrderedProductsCatalogNumbers(final DataDefinition deliveryDD, final Entity delivery) { catNumbersInDeliveriesService.updateProductsCatalogNumbers(delivery, ORDERED_PRODUCTS); } void updateOrderedProductsCatalogNumbers(final DataDefinition deliveryDD, final Entity delivery); void ...
@Test public void shouldUpdateOrderedProductsCatalogNumbers() { deliveryHooksCNID.updateOrderedProductsCatalogNumbers(deliveryDD, delivery); verify(catNumbersInDeliveriesService).updateProductsCatalogNumbers(delivery, ORDERED_PRODUCTS); }
DeliveryHooksCNID { public void updateDeliveredProductsCatalogNumbers(final DataDefinition deliveryDD, final Entity delivery) { catNumbersInDeliveriesService.updateProductsCatalogNumbers(delivery, DELIVERED_PRODUCTS); } void updateOrderedProductsCatalogNumbers(final DataDefinition deliveryDD, final Entity delivery); v...
@Test public void shouldUpdateDeliveredProductsCatalogNumbers() { deliveryHooksCNID.updateDeliveredProductsCatalogNumbers(deliveryDD, delivery); verify(catNumbersInDeliveriesService).updateProductsCatalogNumbers(delivery, DELIVERED_PRODUCTS); }
CatNumbersInDeliveriesServiceImpl implements CatNumbersInDeliveriesService { @Override public void updateProductCatalogNumber(final Entity deliveryProduct) { Entity delivery = deliveryProduct.getBelongsToField(DELIVERY); Entity supplier = delivery.getBelongsToField(SUPPLIER); Entity product = deliveryProduct.getBelongs...
@Test public void shouldntUpdateProductCatalogNumberIfEntityIsntSaved() { given(deliveryProduct.getBelongsToField(DELIVERY)).willReturn(delivery); given(delivery.getBelongsToField(SUPPLIER)).willReturn(supplier); given(deliveryProduct.getBelongsToField(PRODUCT)).willReturn(product); given(productCatalogNumbersService.g...
CatNumbersInDeliveriesServiceImpl implements CatNumbersInDeliveriesService { @Override public void updateProductsCatalogNumbers(final Entity delivery, final String productsName) { Entity supplier = delivery.getBelongsToField(SUPPLIER); if ((delivery.getId() != null) && hasSupplierChanged(delivery.getId(), supplier)) { ...
@Test public void shouldntUpdateProductsCatalogNumbersIfEntityIsntSaved() { Long deliveryId = null; given(delivery.getId()).willReturn(deliveryId); given(delivery.getBelongsToField(SUPPLIER)).willReturn(supplier); catNumbersInDeliveriesService.updateProductsCatalogNumbers(delivery, ORDERED_PRODUCTS); verify(deliveryPro...
CatNumbersInDeliveriesOnStartupService extends Module { @Transactional @Override public void multiTenantEnable() { deliveriesColumnLoaderCNID.addColumnsForDeliveriesCNID(); deliveriesColumnLoaderCNID.addColumnsForOrdersCNID(); } @Transactional @Override void multiTenantEnable(); @Transactional @Override void multiTena...
@Test public void shouldMultiTenantEnable() { catNumbersInDeliveriesOnStartupService.multiTenantEnable(); verify(deliveriesColumnLoaderCNID).addColumnsForDeliveriesCNID(); verify(deliveriesColumnLoaderCNID).addColumnsForOrdersCNID(); }
CatNumbersInDeliveriesOnStartupService extends Module { @Transactional @Override public void multiTenantDisable() { deliveriesColumnLoaderCNID.deleteColumnsForDeliveriesCNID(); deliveriesColumnLoaderCNID.deleteColumnsForOrdersCNID(); } @Transactional @Override void multiTenantEnable(); @Transactional @Override void mu...
@Test public void shouldMultiTenantDisable() { catNumbersInDeliveriesOnStartupService.multiTenantDisable(); verify(deliveriesColumnLoaderCNID).deleteColumnsForDeliveriesCNID(); verify(deliveriesColumnLoaderCNID).deleteColumnsForOrdersCNID(); }
ProductDetailsListenersO { public final void showOrdersWithProductMain(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) { re...
@Test public void shouldntShowOrdersWithProductMainIfProductIsntSaved() { given(product.getId()).willReturn(null); String url = "../page/orders/ordersList.html"; productDetailsListenersO.showOrdersWithProductMain(view, null, null); verify(view, never()).redirectTo(url, false, true, parameters); } @Test public void shou...
TransferModelHooks { public void copyProductionOrConsumptionDataFromBelongingTransformation(final DataDefinition dd, final Entity transfer) { Entity transformations = transfer.getBelongsToField(TRANSFORMATIONS_PRODUCTION); if (transformations == null) { transformations = transfer.getBelongsToField(TRANSFORMATIONS_CONSU...
@Test public void shouldCopyProductionDataFromBelongingTransformation() { given(transfer.getBelongsToField(TRANSFORMATIONS_PRODUCTION)).willReturn(transformation); given(transformation.getField(TIME)).willReturn("1234"); given(transformation.getBelongsToField(LOCATION_FROM)).willReturn(locationFrom); given(transformati...
ProductDetailsListenersO { public final void showOrdersWithProductPlanned(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == null) {...
@Test public void shouldntShowOrdersWithProductPlannedIfProductIsntSaved() { given(product.getId()).willReturn(null); String url = "../page/orders/ordersPlanningList.html"; productDetailsListenersO.showOrdersWithProductPlanned(view, null, null); verify(view, never()).redirectTo(url, false, true, parameters); } @Test pu...
ParametersListenersO { public void redirectToOrdersParameters(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { Long parameterId = (Long) componentState.getFieldValue(); if (parameterId != null) { String url = "../page/orders/ordersParameters.html?context={\"form.id\":\"" + par...
@Test public void shouldRedirectToOrdersParametersIfParameterIdIsntNull() { Long parameterId = 1L; given(componentState.getFieldValue()).willReturn(parameterId); String url = "../page/orders/ordersParameters.html?context={\"form.id\":\"" + parameterId + "\"}"; parametersListenersO.redirectToOrdersParameters(view, compo...
ParametersListenersO { public void redirectToDeviationsDictionary(final ViewDefinitionState viewDefinitionState, final ComponentState componentState, final String[] args) { Long dictionaryId = getDictionaryId("reasonTypeOfChangingOrderState"); if (dictionaryId != null) { String url = "../page/smartDictionaries/dictiona...
@Test public void shouldRedirectToDeviationsDictionaryIfDictionaryIdIsntNull() { Long dictionaryId = 1L; given(dataDefinitionService.get("smartModel", "dictionary")).willReturn(dictionaryDD); given(dictionaryDD.find()).willReturn(searchCriteriaBuilder); given(searchCriteriaBuilder.add(SearchRestrictions.eq("name", "rea...
ParametersListenersO { public void showTimeField(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { String componentStateName = componentState.getName(); if (REASON_NEEDED_WHEN_DELAYED_EFFECTIVE_DATE_FROM.equals(componentStateName)) { orderService.changeFieldState(view, REASON_N...
@Test public void shouldShowTimeFieldForDelayedEffectiveDateFrom() { given(componentState.getName()).willReturn(REASON_NEEDED_WHEN_DELAYED_EFFECTIVE_DATE_FROM); parametersListenersO.showTimeField(view, componentState, null); verify(orderService).changeFieldState(view, REASON_NEEDED_WHEN_DELAYED_EFFECTIVE_DATE_FROM, DEL...
ParametersHooksO { public void showTimeFields(final ViewDefinitionState view) { orderService.changeFieldState(view, REASON_NEEDED_WHEN_DELAYED_EFFECTIVE_DATE_FROM, DELAYED_EFFECTIVE_DATE_FROM_TIME); orderService.changeFieldState(view, REASON_NEEDED_WHEN_EARLIER_EFFECTIVE_DATE_FROM, EARLIER_EFFECTIVE_DATE_FROM_TIME); or...
@Test public void shouldShowTimeFields() { parametersHooksO.showTimeFields(view); verify(orderService).changeFieldState(view, REASON_NEEDED_WHEN_DELAYED_EFFECTIVE_DATE_FROM, DELAYED_EFFECTIVE_DATE_FROM_TIME); verify(orderService).changeFieldState(view, REASON_NEEDED_WHEN_EARLIER_EFFECTIVE_DATE_FROM, EARLIER_EFFECTIVE_D...
ProductDetailsViewHooksO { public void updateRibbonState(final ViewDefinitionState view) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonGroup orders = (...
@Test public void shouldntUpdateRibbonStateIfProductIsntSaved() { given(product.getId()).willReturn(null); given(view.getComponentByReference("window")).willReturn((ComponentState) window); given(window.getRibbon()).willReturn(ribbon); given(ribbon.getGroupByName("orders")).willReturn(orders); given(orders.getItemByNam...
CommonReasonTypeModelHooks { public void updateDate(final Entity reasonTypeEntity, final DeviationModelDescriber deviationModelDescriber) { if (reasonHasNotBeenSavedYet(reasonTypeEntity) || reasonHasChanged(reasonTypeEntity, deviationModelDescriber)) { reasonTypeEntity.setField(CommonReasonTypeFields.DATE, new Date());...
@Test public final void shouldSetCurrentDateOnUpdate() { Date dateBefore = new Date(); stubReasonEntityId(1L); stubFindResults(false); commonReasonTypeModelHooks.updateDate(reasonTypeEntity, deviationModelDescriber); verify(reasonTypeEntity).setField(eq(CommonReasonTypeFields.DATE), dateCaptor.capture()); Date captured...
OrderHooks { public boolean checkOrderDates(final DataDefinition orderDD, final Entity order) { DateRange orderDateRange = orderDatesService.getCalculatedDates(order); Date dateFrom = orderDateRange.getFrom(); Date dateTo = orderDateRange.getTo(); if (dateFrom == null || dateTo == null || dateTo.after(dateFrom)) { retu...
@Test public void shouldReturnTrueForValidOrderDates() throws Exception { DateRange dateRange = new DateRange(new Date(System.currentTimeMillis() - 10000), new Date()); given(orderDatesService.getCalculatedDates(order)).willReturn(dateRange); boolean result = orderHooks.checkOrderDates(orderDD, order); assertTrue(resul...
LineChangeoverNormsHooks { public boolean checkRequiredField(final DataDefinition changeoverNormDD, final Entity changeoverNorm) { String changeoverType = changeoverNorm.getStringField(LineChangeoverNormsFields.CHANGEOVER_TYPE); if (changeoverType.equals(ChangeoverType.FOR_TECHNOLOGY.getStringValue())) { for (String re...
@Test public void shouldReturnErrorWhenRequiredFieldForTechnologyIsNotFill() { given(changeoverNorm.getStringField(LineChangeoverNormsFields.CHANGEOVER_TYPE)).willReturn("01forTechnology"); given(changeoverNorm.getBelongsToField(FROM_TECHNOLOGY)).willReturn(null); given(changeoverNorm.getDataDefinition()).willReturn(ch...
OrderHooks { public boolean checkOrderPlannedQuantity(final DataDefinition orderDD, final Entity order) { Entity product = order.getBelongsToField(OrderFields.PRODUCT); if (product == null) { return true; } BigDecimal plannedQuantity = order.getDecimalField(OrderFields.PLANNED_QUANTITY); if (plannedQuantity == null) { ...
@Test public void shouldReturnTrueForPlannedQuantityValidationIfThereIsNoProduct() throws Exception { stubBelongsToField(order, OrderFields.PRODUCT, null); boolean result = orderHooks.checkOrderPlannedQuantity(orderDD, order); assertTrue(result); } @Test public void shouldReturnTrueForPlannedQuantityValidation() throws...
OrderHooks { public void clearOrSetSpecyfiedValueOrderFieldsOnCopy(final DataDefinition orderDD, final Entity order) { order.setField(OrderFields.STATE, OrderState.PENDING.getStringValue()); order.setField(OrderFields.EFFECTIVE_DATE_TO, null); order.setField(OrderFields.EFFECTIVE_DATE_FROM, null); order.setField(OrderF...
@Test public void shouldClearOrderFieldsOnCopy() throws Exception { Date startDate = new Date(); Date finishDate = new Date(); stubDateField(order, OrderFields.START_DATE, startDate); stubDateField(order, OrderFields.FINISH_DATE, finishDate); orderHooks.clearOrSetSpecyfiedValueOrderFieldsOnCopy(orderDD, order); verify(...
OrderHooks { void setCopyOfTechnology(final Entity order) { if (orderService.isPktEnabled()) { order.setField(OrderFields.TECHNOLOGY, copyTechnology(order).orNull()); } else { Entity prototypeTechnology = order.getBelongsToField(OrderFields.TECHNOLOGY_PROTOTYPE); if (prototypeTechnology != null && TechnologyState.of(pr...
@Test public final void shouldNotSetCopyOfTechnology() { given(orderService.isPktEnabled()).willReturn(true); stubBelongsToField(order, OrderFields.TECHNOLOGY, null); orderHooks.setCopyOfTechnology(order); verify(order, never()).setField(eq(OrderFields.TECHNOLOGY), notNull()); } @Test public final void shouldSetCopyOfT...
OrderDetailsHooks { public void setAndDisableState(final ViewDefinitionState view) { FormComponent orderForm = (FormComponent) view.getComponentByReference(L_FORM); FieldComponent stateField = (FieldComponent) view.getComponentByReference(OrderFields.STATE); stateField.setEnabled(false); if (orderForm.getEntityId() != ...
@Test public void shouldSetAndDisableState() throws Exception { given(view.getComponentByReference(L_FORM)).willReturn(orderForm); given(orderForm.getEntityId()).willReturn(null); orderDetailsHooks.setAndDisableState(view); verify(stateField).setEnabled(false); verify(stateField).setFieldValue(OrderState.PENDING.getStr...
MaterialsInLocationComponentModelValidators { public boolean checkMaterialFlowComponentUniqueness(final DataDefinition materialsInLocationComponentDD, final Entity materialsInLocationComponent) { Entity location = materialsInLocationComponent.getBelongsToField(LOCATION); Entity materialsInLocation = materialsInLocation...
@Test public void shouldReturnFalseWhenCheckMaterialFlowComponentUniquenessAndMaterialsInLocationOrLocationIsNull() { given(materialsInLocationComponent.getBelongsToField(LOCATION)).willReturn(null); given(materialsInLocationComponent.getBelongsToField(MATERIALS_IN_LOCATION)).willReturn(null); boolean result = material...
OrderDetailsHooks { public void generateOrderNumber(final ViewDefinitionState view) { numberGeneratorService.generateAndInsertNumber(view, OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER, L_FORM, OrderFields.NUMBER); } final void onBeforeRender(final ViewDefinitionState view); void fillRecipeFilterValue...
@Test public void shouldGenerateOrderNumber() throws Exception { orderDetailsHooks.generateOrderNumber(view); verify(numberGeneratorService).generateAndInsertNumber(view, OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER, L_FORM, OrderFields.NUMBER); }