src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
BasicController { @RequestMapping(value = "parameters", method = RequestMethod.GET) public ModelAndView getParameterPageView(final Locale locale) { JSONObject json = new JSONObject(ImmutableMap.of("form.id", parameterService.getParameterId().toString())); Map<String, String> arguments = ImmutableMap.of("context", json.... | @Test public void shouldPrepareViewForParameters() throws Exception { Map<String, String> arguments = ImmutableMap.of("context", "{\"form.id\":\"13\"}"); ModelAndView expectedMav = mock(ModelAndView.class); CrudService crudController = mock(CrudService.class); given( crudController.prepareView(BasicConstants.PLUGIN_IDE... |
ProductDetailsHooks { public void disableProductFormForExternalItems(final ViewDefinitionState state) { FormComponent productForm = (FormComponent) state.getComponentByReference(L_FORM); FieldComponent entityTypeField = (FieldComponent) state.getComponentByReference(ProductFields.ENTITY_TYPE); FieldComponent parentFiel... | @Test public void shouldDisabledFormWhenExternalNumberIsNotNull() throws Exception { Long productId = 1L; given(view.getComponentByReference(L_FORM)).willReturn(productForm); given(view.getComponentByReference(ProductFields.PARENT)).willReturn(parentField); given(view.getComponentByReference(ProductFields.ENTITY_TYPE))... |
ProductDetailsHooks { public void fillUnit(final ViewDefinitionState view) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); FieldComponent unitField = (FieldComponent) view.getComponentByReference(UNIT); if ((productForm.getEntityId() == null) && (unitField.getFieldValue() == null)) {... | @Test public void shouldntFillUnitIfFormIsSaved() { given(view.getComponentByReference(L_FORM)).willReturn(productForm); given(view.getComponentByReference(UNIT)).willReturn(unitField); given(productForm.getEntityId()).willReturn(L_ID); productDetailsHooks.fillUnit(view); verify(unitField, never()).setFieldValue(Mockit... |
WorkPlansListView { public List<Entity> getSelectedWorkPlans() { return workPlansGrid.getSelectedEntities(); } WorkPlansListView(final WindowComponent window, final RibbonActionItem deleteButton, final GridComponent workPlansGrid); static WorkPlansListView from(final ViewDefinitionState view); void setUpDeleteButton(fi... | @Test public final void shouldGetSelectedEntities() { List<Entity> entities = ImmutableList.of(mockEntity(), mockEntity(), mockEntity(), mockEntity()); given(workPlansGrid.getSelectedEntities()).willReturn(entities); List<Entity> result = workPlansListView.getSelectedWorkPlans(); assertEquals(entities, result); } |
UnitConversionItemValidatorsB { public boolean validateUnitOnConversionWithProduct(final DataDefinition dataDefinition, final Entity unitConversionItem) { final Entity product = unitConversionItem.getBelongsToField(UnitConversionItemFieldsB.PRODUCT); final String unitFrom = unitConversionItem.getStringField(UnitConvers... | @Test public void sholudReturnTrueIfProductIsNull() { given(unitConversionItem.getBelongsToField(UnitConversionItemFieldsB.PRODUCT)).willReturn(null); boolean result = unitConversionItemValidatorsB.validateUnitOnConversionWithProduct(dataDefinition, unitConversionItem); assertTrue(result); }
@Test public void sholudRet... |
ProductHooks { public void clearFamilyFromProductWhenTypeIsChanged(final DataDefinition productDD, final Entity product) { if (product.getId() == null) { return; } String entityType = product.getStringField(ENTITY_TYPE); Entity productFromDB = product.getDataDefinition().get(product.getId()); if (entityType.equals(PART... | @Test public void shouldReturnWhenEntityIdIsNull() throws Exception { when(entity.getId()).thenReturn(null); productHooks.clearFamilyFromProductWhenTypeIsChanged(dataDefinition, entity); }
@Test public void shouldReturnWhenSavingEntityIsFamily() throws Exception { Long entityId = 1L; when(entity.getId()).thenReturn(ent... |
ProductHooks { public void clearExternalIdOnCopy(final DataDefinition dataDefinition, final Entity entity) { if (entity == null) { return; } entity.setField("externalNumber", null); } void generateNodeNumber(final DataDefinition productDD, final Entity product); void updateNodeNumber(final DataDefinition productDD, fi... | @Test public void shouldClearExternalIdOnCopy() throws Exception { productHooks.clearExternalIdOnCopy(dataDefinition, entity); Mockito.verify(entity).setField("externalNumber", null); } |
ExchangeRatesNbpServiceImpl implements ExchangeRatesNbpService { @Override public Map<String, BigDecimal> parse(InputStream inputStream, NbpProperties nbpProperties) { Map<String, BigDecimal> exRates = new HashMap<>(); try { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLStreamReader sr = inputFactory... | @Test public void shouldParseCorrectlyGivenExampleDocument() throws Exception { Map<String, BigDecimal> map = service.parse(inputStream, ExchangeRatesNbpService.NbpProperties.LAST_C); assertTrue(map.containsKey("USD")); assertTrue(map.containsKey("CAD")); assertTrue(map.containsKey("AUD")); assertTrue(map.containsValue... |
ProductValidators { public boolean checkEanUniqueness(final DataDefinition productDD, final FieldDefinition eanFieldDefinition, final Entity product, final Object eanOldValue, final Object eanNewValue) { String ean = (String) eanNewValue; if (StringUtils.isEmpty(ean) || ObjectUtils.equals(eanOldValue, ean)) { return tr... | @Test public final void shouldCheckEanUniquenessJustReturnTrueIfNewEanIsEmpty() { String oldVal = "123456"; String newVal = ""; boolean isValid = productValidators.checkEanUniqueness(dataDefinition, fieldDefinition, entity, oldVal, newVal); assertTrue(isValid); verify(entity, never()).addError(any(FieldDefinition.class... |
WorkPlansListView { public void setUpDeleteButton(final boolean isEnabled, final String message) { deleteButton.setEnabled(isEnabled); deleteButton.setMessage(message); deleteButton.requestUpdate(true); window.requestRibbonRender(); } WorkPlansListView(final WindowComponent window, final RibbonActionItem deleteButton, ... | @Test public final void shouldSetUpDeleteButton() { boolean isEnabled = true; String message = "some arbitrary mesage"; workPlansListView.setUpDeleteButton(isEnabled, message); verify(deleteButton).setEnabled(isEnabled); verify(deleteButton).setMessage(message); verify(deleteButton).requestUpdate(true); verify(windowCo... |
CompanyService { public Long getCompanyId() { if (getCompany() == null) { return null; } else { return getCompany().getId(); } } Long getCompanyId(); @Transactional Entity getCompany(); @Transactional Entity getCompany(final Long companyId); final Boolean isCompanyOwner(final Entity company); void disabledGridWhenComp... | @Test public void shouldReturnExistingCompanyEntityId() throws Exception { Entity company = Mockito.mock(Entity.class); given(company.getId()).willReturn(13L); given(parameterService.getParameter()).willReturn(parameter); given(parameter.getBelongsToField(ParameterFields.COMPANY)).willReturn(company); Long id = company... |
CompanyService { @Transactional public Entity getCompany() { Entity parameter = parameterService.getParameter(); return parameter.getBelongsToField(ParameterFields.COMPANY); } Long getCompanyId(); @Transactional Entity getCompany(); @Transactional Entity getCompany(final Long companyId); final Boolean isCompanyOwner(f... | @Test public void shouldReturnExistingCompanyEntity() throws Exception { given(parameterService.getParameter()).willReturn(parameter); given(parameter.getBelongsToField(ParameterFields.COMPANY)).willReturn(company); given(company.isValid()).willReturn(true); Entity existingcompany = companyService.getCompany(); assertE... |
Shift { public Optional<DateRange> findWorkTimeAt(final Date date) { if (timetableExceptions.hasFreeTimeAt(date)) { return Optional.absent(); } DateTime dateTime = new DateTime(date); Optional<TimeRange> maybeTimeRangeFromPlan = findWorkTimeAt(dateTime.getDayOfWeek(), dateTime.toLocalTime()); for (TimeRange timeRangeFr... | @Test public final void shouldReturnWorkingHoursForDay() { String hours = "6:00-12:00, 21:30-2:30"; given(shiftEntity.getStringField(ShiftFields.MONDAY_HOURS)).willReturn(hours); given(shiftEntity.getBooleanField(ShiftFields.MONDAY_WORKING)).willReturn(true); LocalDate mondayDate = new LocalDate(2013, 9, 2); Shift shif... |
WorkingHours implements Comparable<WorkingHours> { public Set<TimeRange> getTimeRanges() { return Collections.unmodifiableSet(hours); } WorkingHours(final String hourRanges); boolean isEmpty(); boolean contains(final LocalTime time); Optional<TimeRange> findRangeFor(final LocalTime time); Set<TimeRange> getTimeRanges()... | @Test public final void shouldBuildWorkingHoursFromSingleTimeRangeWithTwoDigitsHour() { String timeRangeString = "09:00-17:00"; WorkingHours workingHours = new WorkingHours(timeRangeString); assertEquals(1, workingHours.getTimeRanges().size()); TimeRange timeRange = workingHours.getTimeRanges().iterator().next(); asser... |
ProductsFamiliesTreeService { public List<Entity> getHierarchyProductsTree(final Entity product) { List<Entity> tree = new ArrayList<Entity>(); addProduct(tree, product); generateTree(product, tree); return tree; } List<Entity> getHierarchyProductsTree(final Entity product); } | @Test public void shouldReturnTreeWithoutChildrenWhenDoesnotExists() throws Exception { EntityList emptyList = mockEntityList(new LinkedList<Entity>()); when(productDsk.getHasManyField(PRODUCT_FAMILY_CHILDRENS)).thenReturn(emptyList); List<Entity> tree = productsFamiliesTreeService.getHierarchyProductsTree(productDsk);... |
ProductCatalogNumbersServiceImpl implements ProductCatalogNumbersService { @Override public Entity getProductCatalogNumber(final Entity product, final Entity supplier) { return dataDefinitionService .get(ProductCatalogNumbersConstants.PLUGIN_IDENTIFIER, ProductCatalogNumbersConstants.MODEL_PRODUCT_CATALOG_NUMBERS).find... | @Test public void shouldReturnNullWhenGetProductCatalogNumber() { given(productCatalogNumbersDD.find()).willReturn(searchCriteriaBuilder); given(searchCriteriaBuilder.add(Mockito.any(SearchCriterion.class))).willReturn(searchCriteriaBuilder); given(searchCriteriaBuilder.setMaxResults(1)).willReturn(searchCriteriaBuilde... |
ProductService { public boolean checkIfProductEntityTypeIsCorrect(final Entity product, final ProductFamilyElementType entityType) { return entityType.getStringValue().equals(product.getStringField(ENTITY_TYPE)); } Entity find(final SearchProjection projection, final SearchCriterion criteria, final SearchOrder order);... | @Test public void shouldReturnTrueWhenCheckIfProductEntityTypeIsCorrect() throws Exception { given(product.getStringField(ENTITY_TYPE)).willReturn(PARTICULAR_PRODUCT.getStringValue()); boolean result = productService.checkIfProductEntityTypeIsCorrect(product, PARTICULAR_PRODUCT); assertTrue(result); }
@Test public void... |
ProductService { public boolean checkIfProductIsNotRemoved(final DataDefinition substituteDD, final Entity substitute) { Entity product = substitute.getBelongsToField(SubstituteFields.PRODUCT); if (product == null || product.getId() == null) { return true; } Entity productEntity = dataDefinitionService.get(BasicConstan... | @Test public void shouldReturnTrueWhenProductIsNotRemoved() throws Exception { boolean result = productService.checkIfProductIsNotRemoved(productDD, product); assertTrue(result); }
@Test public void shouldReturnFalseWhenEntityDoesnotExists() throws Exception { DataDefinition productDD = Mockito.mock(DataDefinition.clas... |
ProductService { public boolean checkIfSubstituteIsNotRemoved(final DataDefinition substituteComponentDD, final Entity substituteComponent) { Entity substitute = substituteComponent.getBelongsToField(SubstituteComponentFields.SUBSTITUTE); if (substitute == null || substitute.getId() == null) { return true; } Entity sub... | @Test public void shouldReturnFalseWhenSubstituteDoesnotExists() throws Exception { DataDefinition substituteDD = Mockito.mock(DataDefinition.class); Long substituteId = 1L; given(substituteComponent.getBelongsToField(SubstituteComponentFields.SUBSTITUTE)).willReturn(substitute); given(dataDefinitionService.get(BasicCo... |
ProductService { public void fillUnit(final DataDefinition productDD, final Entity product) { if (product.getField(UNIT) == null) { product.setField(UNIT, unitService.getDefaultUnitFromSystemParameters()); } } Entity find(final SearchProjection projection, final SearchCriterion criteria, final SearchOrder order); List... | @Test public void shouldntFillUnitIfUnitIsntNull() { Entity product = mock(Entity.class); DataDefinition productDD = mock(DataDefinition.class); given(product.getField(UNIT)).willReturn(L_SZT); productService.fillUnit(productDD, product); verify(product, never()).setField(Mockito.anyString(), Mockito.anyString()); }
@T... |
TechnologyOperationComponentHooksOTFO { public void changeDescriptionInOperationalTasksWhenChanged(final DataDefinition technologyOperationComponentDD, final Entity technologyOperationComponent) { Long technologyOperationComponentId = technologyOperationComponent.getId(); if (technologyOperationComponentId == null) { r... | @Test public void shouldReturnWhenEntityIdIsNull() throws Exception { Long technologyOperationComponentId = null; String comment = "comment"; given(technologyOperationComponent.getId()).willReturn(technologyOperationComponentId); technologyOperationComponentHooksOTFO.changeDescriptionInOperationalTasksWhenChanged(techn... |
OperationHooksOTFO { public void changedNameInOperationalTasksWhenChanged(final DataDefinition operationDD, final Entity operation) { Long operationId = operation.getId(); if (operationId == null) { return; } Entity operationFromDB = operationDD.get(operationId); String name = operation.getStringField(OperationFields.N... | @Test public void shouldReturnIfEntityIdIsNull() throws Exception { Long operationId = null; String name = "name"; given(operation.getId()).willReturn(operationId); operationHooksOTFO.changedNameInOperationalTasksWhenChanged(operationDD, operation); Mockito.verify(operationalTask, Mockito.never()).setField(OperationalT... |
OperationalTaskDetailsHooksOTFO { public void disableFieldsWhenOrderTypeIsSelected(final ViewDefinitionState view) { FieldComponent typeTaskField = (FieldComponent) view.getComponentByReference(OperationalTaskFields.TYPE_TASK); String typeTask = (String) typeTaskField.getFieldValue(); List<String> referenceBasicFields ... | @Test public void shouldDisabledFieldWhenTypeForOrderIsSelected() throws Exception { String typeTask = OperationalTaskTypeTaskOTFO.EXECUTION_OPERATION_IN_ORDER.getStringValue(); given(typeTaskField.getFieldValue()).willReturn(typeTask); given(operationalTasksForOrdersService.isOperationalTaskTypeTaskOtherCase(typeTask)... |
OrderHooksOTFO { public void changedProductionLineInOperationalTasksWhenChanged(final DataDefinition orderDD, final Entity order) { Long orderId = order.getId(); if (orderId == null) { return; } Entity orderFromDB = orderDD.get(orderId); Entity productionLine = order.getBelongsToField(OrderFields.PRODUCTION_LINE); Enti... | @Test public void shouldReturnWhenEntityIdIsNull() throws Exception { Long orderId = null; given(order.getId()).willReturn(orderId); orderHooksOTFO.changedProductionLineInOperationalTasksWhenChanged(orderDD, order); }
@Test public void shouldReturnWhenProductionLineIsTheSame() throws Exception { Long orderId = 1L; Long... |
ProductCatalogNumbersHooks { public boolean checkIfExistsCatalogNumberWithNumberAndCompany(final DataDefinition dataDefinition, final Entity entity) { SearchCriteriaBuilder criteria = dataDefinitionService .get(ProductCatalogNumbersConstants.PLUGIN_IDENTIFIER, ProductCatalogNumbersConstants.MODEL_PRODUCT_CATALOG_NUMBER... | @Test public void shouldReturnTrueWhenEntityWithGivenNumberAndCompanyDoesnotExistsInDB() throws Exception { SearchCriterion criterion1 = SearchRestrictions.eq(CATALOG_NUMBER, entity.getStringField(CATALOG_NUMBER)); SearchCriterion criterion2 = SearchRestrictions.belongsTo(ProductCatalogNumberFields.COMPANY, company); g... |
OperationDurationDetailsInOrderDetailsHooksOTFO { public void disableCreateButton(final ViewDefinitionState view) { WindowComponent window = (WindowComponent) view.getComponentByReference(L_WINDOW); RibbonGroup operationalTasks = window.getRibbon().getGroupByName(L_OPERATIONAL_TASKS); RibbonActionItem createOperational... | @Test public void shouldEnableButtonWhenIsGeneratedAndOrderStateIsAccepted() throws Exception { String generatedEndDate = "01-02-2012"; given(generatedEndDateField.getFieldValue()).willReturn(generatedEndDate); given(order.getStringField(OrderFields.STATE)).willReturn(OrderStateStringValues.ACCEPTED); given(order.getBe... |
OperationalTaskValidatorsOTFO { public boolean validatesWith(final DataDefinition operationalTaskDD, final Entity operationalTask) { return checkIfOrderHasTechnology(operationalTaskDD, operationalTask); } boolean validatesWith(final DataDefinition operationalTaskDD, final Entity operationalTask); } | @Test public void shouldReturnTrueWhenOrderIsNotSave() throws Exception { given(operationalTask.getBelongsToField(OperationalTaskFieldsOTFO.ORDER)).willReturn(null); boolean result = operationalTaskValidatorsOTFO.validatesWith(operationalTaskDD, operationalTask); Assert.assertTrue(result); }
@Test public void shouldRet... |
LineChangeoverNormsForOrderDetailsListeners { public final void showPreviousOrder(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER); Long previousOrderId = (Lon... | @Test public void shouldNotRedirectToPreviousOrderIfPreviousOrderIsNull() { stubLookup(previousOrderLookup, null); lineChangeoverNormsForOrderDetailsListeners.showPreviousOrder(view, null, null); verify(view, never()).redirectTo(anyString(), anyBoolean(), anyBoolean(), anyMap()); }
@Test public void shouldRedirectToPre... |
LineChangeoverNormsForOrderDetailsListeners { public final void showBestFittingLineChangeoverNorm(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FieldComponent lineChangeoverNormField = (FieldComponent) view .getComponentByReference(OrderFieldsLCNFO.LINE_CHANGEOVER_NORM); Lo... | @Test public void shouldNotRedirectToBestFittingLineChangeoverNormIfLineChangeoverIsNull() { stubLookup(lineChangeoverNormLookup, null); lineChangeoverNormsForOrderDetailsListeners.showBestFittingLineChangeoverNorm(view, null, null); verify(view, never()).redirectTo(anyString(), anyBoolean(), anyBoolean(), anyMap()); }... |
LineChangeoverNormsForOrderDetailsListeners { public final void showLineChangeoverNormForGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FieldComponent previousOrderTechnologyGroupNumberField = (FieldComponent) view .getComponentByReference("previousOrderTechnologyGroup... | @Test public void shouldNotRedirectToLineChangeoverNormForGroupIfTechnologyGroupNumbersAreEmpty() { given(previousOrderTechnologyGroupNumberField.getFieldValue()).willReturn(null); given(technologyGroupNumberField.getFieldValue()).willReturn(null); lineChangeoverNormsForOrderDetailsListeners.showLineChangeoverNormForGr... |
LineChangeoverNormsForOrderDetailsListeners { public final void showLineChangeoverNormForTechnology(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FieldComponent previousOrderTechnologyNumberField = (FieldComponent) view .getComponentByReference("previousOrderTechnologyNumbe... | @Test public void shouldNotRedirectToLineChangeoverNormsForTechnologyIfTechnologyNumbersAreEmpty() { given(previousOrderTechnologyNumberField.getFieldValue()).willReturn(null); given(technologyNumberField.getFieldValue()).willReturn(null); lineChangeoverNormsForOrderDetailsListeners.showLineChangeoverNormForTechnology(... |
LineChangeoverNormsForOrderDetailsListeners { public final void checkIfOrderHasCorrectStateAndIsPrevious(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER); Look... | @Test public void shouldNotAddMessageWhenOrdersAreNotSpecified() { stubLookup(previousOrderLookup, null); stubLookup(orderLookup, null); given(lineChangeoverNormsForOrdersService.previousOrderEndsBeforeOrIsWithdrawed(null, null)).willReturn(true); lineChangeoverNormsForOrderDetailsListeners.checkIfOrderHasCorrectStateA... |
ProductCatalogNumbersHooks { public boolean checkIfExistsCatalogNumberWithProductAndCompany(final DataDefinition dataDefinition, final Entity entity) { SearchCriteriaBuilder criteria = dataDefinitionService .get(ProductCatalogNumbersConstants.PLUGIN_IDENTIFIER, ProductCatalogNumbersConstants.MODEL_PRODUCT_CATALOG_NUMBE... | @Test public void shouldReturnTrueWhenEntityWithGivenProductAndCompanyDoesnotExistsInDB() throws Exception { SearchCriterion criterion1 = SearchRestrictions.eq(CATALOG_NUMBER, entity.getStringField(CATALOG_NUMBER)); SearchCriterion criterion2 = SearchRestrictions.belongsTo(PRODUCT, entity.getBelongsToField(PRODUCT)); g... |
LineChangeoverNormsForOrderDetailsListeners { public final void fillPreviousOrderForm(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { lineChangeoverNormsForOrdersService.fillOrderForm(view, LineChangeoverNormsForOrdersConstants.PREVIOUS_ORDER_FIELDS); } final void showPrevio... | @Test public final void shouldFillPreviousOrderForm() { lineChangeoverNormsForOrderDetailsListeners.fillPreviousOrderForm(view, null, null); verify(lineChangeoverNormsForOrdersService).fillOrderForm(view, PREVIOUS_ORDER_FIELDS); } |
LineChangeoverNormsForOrderDetailsListeners { public void showOwnLineChangeoverDurationField(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { orderService.changeFieldState(view, OrderFieldsLCNFO.OWN_LINE_CHANGEOVER, OrderFieldsLCNFO.OWN_LINE_CHANGEOVER_DURATION); } final void... | @Test public void shouldShowOwnLineChangeoverDurationField() { lineChangeoverNormsForOrderDetailsListeners.showOwnLineChangeoverDurationField(view, null, null); verify(orderService).changeFieldState(view, OWN_LINE_CHANGEOVER, OWN_LINE_CHANGEOVER_DURATION); } |
OrderDetailsListenersLCNFO { public final void showChangeover(final ViewDefinitionState viewState, final ComponentState componentState, final String[] args) { Long orderId = (Long) componentState.getFieldValue(); if (orderId == null) { return; } Map<String, Object> parameters = Maps.newHashMap(); parameters.put("form.i... | @Test public void shouldntShowChangeoverIfOrderIdIsNull() { given(componentState.getFieldValue()).willReturn(null); String url = "/page/lineChangeoverNormsForOrders/lineChangeoverNormsForOrderDetails.html"; orderDetailsListenersLCNFO.showChangeover(view, componentState, null); verify(view, never()).redirectTo(url, fals... |
OrderModelValidatorsLCNFO { public final boolean checkIfOrderHasCorrectStateAndIsPrevious(final DataDefinition orderDD, final Entity order) { Entity previousOrderDB = order.getBelongsToField(OrderFieldsLCNFO.PREVIOUS_ORDER); Entity orderDB = order.getBelongsToField(OrderFieldsLCNFO.ORDER); if (!lineChangeoverNormsForOr... | @Test public void shouldReturnFalseWhenPreviousOrderIsNotCorrect() { given(lineChangeoverNormsForOrdersService.previousOrderEndsBeforeOrIsWithdrawed(previousOrderDB, orderDB)).willReturn( false); boolean result = orderModelValidatorsLCNFO.checkIfOrderHasCorrectStateAndIsPrevious(orderDD, order); assertFalse(result); ve... |
LineChangeoverNormsForOrderDetailsViewHooks { public final void fillOrderForms(final ViewDefinitionState view) { FormComponent orderForm = (FormComponent) view.getComponentByReference(L_FORM); LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.ORDER); LookupComponent previousO... | @Test public void shouldNotFillOrderFormsIfOrderFormEntityIdIsNull() { given(view.getComponentByReference(L_FORM)).willReturn(orderForm); given(view.getComponentByReference(PREVIOUS_ORDER)).willReturn(previousOrderLookup); given(view.getComponentByReference(ORDER)).willReturn(orderLookup); stubOrderForm(null); lineChan... |
LineChangeoverNormsForOrderDetailsViewHooks { public void fillLineChangeoverNorm(final ViewDefinitionState view) { Entity lineChangeoverNorm = findChangeoverNorm(view); fillChangeoverNormFields(view, lineChangeoverNorm); } final void fillOrderForms(final ViewDefinitionState view); void fillLineChangeoverNorm(final Vie... | @Test public void shouldntFillLineChangeoverNormIfOrderLookupsAreEmpty() { given(view.getComponentByReference(PREVIOUS_ORDER)).willReturn(previousOrderLookup); given(view.getComponentByReference(ORDER)).willReturn(orderLookup); given(view.getComponentByReference("lineChangeoverNorm")).willReturn(lineChangeoverNormLooku... |
LineChangeoverNormsForOrderDetailsViewHooks { public void updateRibbonState(final ViewDefinitionState view) { FieldComponent productionLineField = (FieldComponent) view.getComponentByReference(OrderFields.PRODUCTION_LINE); LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsL... | @Test public void shouldNotUpdateRibbonState() { given(view.getComponentByReference(PRODUCTION_LINE)).willReturn(productionLineField); given(view.getComponentByReference(PREVIOUS_ORDER)).willReturn(previousOrderLookup); given(view.getComponentByReference(LINE_CHANGEOVER_NORM)).willReturn(lineChangeoverNormLookup); give... |
LineChangeoverNormsForOrderDetailsViewHooks { public void showOwnLineChangeoverDurationField(final ViewDefinitionState view) { orderService.changeFieldState(view, OrderFieldsLCNFO.OWN_LINE_CHANGEOVER, OrderFieldsLCNFO.OWN_LINE_CHANGEOVER_DURATION); } final void fillOrderForms(final ViewDefinitionState view); void fill... | @Test public void shouldShowOwnLineChangeoverDurationField() { lineChangeoverNormsForOrderDetailsViewHooks.showOwnLineChangeoverDurationField(view); verify(orderService).changeFieldState(view, OWN_LINE_CHANGEOVER, OWN_LINE_CHANGEOVER_DURATION); } |
TechnologyOperationComponentHooksTS { public void copySubstractingFieldFromLowerInstance(final DataDefinition technologyOperationComponentDD, final Entity technologyOperationComponent) { if (!shouldCopyFromLowerInstance(technologyOperationComponent)) { return; } Entity operation = technologyOperationComponent.getBelong... | @Test public void shouldSetTrueFromLowerInstance() throws Exception { when(technologyOperationComponent.getField(IS_SUBCONTRACTING)).thenReturn(null); when(operation.getBooleanField(IS_SUBCONTRACTING)).thenReturn(true); technologyOperationComponentHooksTS.copySubstractingFieldFromLowerInstance(technologyOperationCompon... |
MasterOrderHooks { protected void setExternalSynchronizedField(final Entity masterOrder) { masterOrder.setField(MasterOrderFields.EXTERNAL_SYNCHRONIZED, true); } void onCreate(final DataDefinition dataDefinition, final Entity masterOrder); void onSave(final DataDefinition dataDefinition, final Entity masterOrder); voi... | @Test public final void shouldSetExternalSynchronized() { masterOrderHooks.setExternalSynchronizedField(masterOrder); verify(masterOrder).setField(MasterOrderFields.EXTERNAL_SYNCHRONIZED, true); } |
MasterOrderHooks { protected void changedDeadlineAndInOrder(final Entity masterOrder) { Preconditions.checkArgument(masterOrder.getId() != null, "Method expects already persisted entity"); Date deadline = masterOrder.getDateField(DEADLINE); Entity customer = masterOrder.getBelongsToField(COMPANY); if (deadline == null ... | @Test public final void shouldThrowExceptionWhenMasterOrderIsNotSave() { stubId(masterOrder, null); try { masterOrderHooks.changedDeadlineAndInOrder(masterOrder); Assert.fail(); } catch (IllegalArgumentException ignored) { verify(masterOrder, never()).setField(MasterOrderFields.ORDERS, Lists.newArrayList()); } }
@Test ... |
MasterOrderProductDetailsHooks { public void fillUnitField(final ViewDefinitionState view) { LookupComponent productField = (LookupComponent) view.getComponentByReference(MasterOrderProductFields.PRODUCT); Entity product = productField.getEntity(); String unit = null; if (product != null) { unit = product.getStringFiel... | @Test public final void shouldSetNullWhenProductDoesnotExists() { given(productField.getEntity()).willReturn(null); masterOrderProductDetailsHooks.fillUnitField(view); verify(cumulatedOrderQuantityUnitField).setFieldValue(null); verify(masterOrderQuantityUnitField).setFieldValue(null); verify(producedOrderQuantityUnitF... |
MasterOrderProductDetailsHooks { public void showErrorWhenCumulatedQuantity(final ViewDefinitionState view) { FormComponent masterOrderProductForm = (FormComponent) view.getComponentByReference(L_FORM); Entity masterOrderProduct = masterOrderProductForm.getPersistedEntityWithIncludedFormValues(); if ((masterOrderProduc... | @Test public final void shouldShowMessageError() { BigDecimal cumulatedOrderQuantity = BigDecimal.ONE; BigDecimal masterOrderQuantity = BigDecimal.TEN; given(masterOrderProduct.isValid()).willReturn(true); given(masterOrderProduct.getDecimalField(MasterOrderProductFields.CUMULATED_ORDER_QUANTITY)).willReturn( cumulated... |
OrderValidatorsMO { public boolean checkProductAndTechnology(final DataDefinition orderDD, final Entity order) { Entity masterOrder = order.getBelongsToField(MASTER_ORDER); if (masterOrder == null || masterOrder.getHasManyField(MasterOrderFields.MASTER_ORDER_PRODUCTS).isEmpty()) { return true; } return checkIfOrderMatc... | @Test public final void shouldReturnFalseIfNoneOfMasterOrderProductMatches() { stubMasterOrderProducts(NOT_EMPTY_ENTITY_LIST); SearchCriteriaBuilder scb = mockCriteriaBuilder(EMPTY_ENTITY_LIST); given(masterDD.find()).willReturn(scb); boolean isValid = orderValidatorsMO.checkProductAndTechnology(orderDD, order); Assert... |
OrderValidatorsMO { public boolean checkCompanyAndDeadline(final DataDefinition orderDD, final Entity order) { boolean isValid = true; Entity masterOrder = order.getBelongsToField(MASTER_ORDER); if (masterOrder == null) { return isValid; } if (!checkIfBelongToFieldIsTheSame(order, masterOrder, COMPANY)) { Entity compan... | @Test public final void shouldCheckCompanyAndDeadlineReturnTrueWhenMasterOrderIsNotSpecified() { given(order.getBelongsToField(OrderFieldsMO.MASTER_ORDER)).willReturn(null); boolean result = orderValidatorsMO.checkCompanyAndDeadline(orderDD, order); Assert.assertTrue(result); } |
OrderValidatorsMO { public boolean checkOrderNumber(final DataDefinition orderDD, final Entity order) { Entity masterOrder = order.getBelongsToField(MASTER_ORDER); if (masterOrder == null) { return true; } if (!masterOrder.getBooleanField(ADD_MASTER_PREFIX_TO_NUMBER)) { return true; } String masterOrderNumber = masterO... | @Test public final void shouldCheckOrderNumberReturnTrueWhenMasterOrderIsNotSpecified() { given(order.getBelongsToField(OrderFieldsMO.MASTER_ORDER)).willReturn(null); boolean result = orderValidatorsMO.checkOrderNumber(orderDD, order); Assert.assertEquals(true, result); }
@Test public final void shouldCheckOrderNumberR... |
OperationalTaskDetailsListenersOTFOOverrideUtil { public void setOperationalTaskNameDescriptionAndProductionLineForSubcontracted(final ViewDefinitionState view) { LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OperationalTaskFieldsOTFO.ORDER); LookupComponent technologyOperationComponentLo... | @Test public void shouldntOperationalTaskNameDescriptionAndProductionLineForSubcontractedWhenIsSubcontracting() throws Exception { given(orderLookup.getEntity()).willReturn(order); given(technologyOperationComponentLookup.getEntity()).willReturn(technologyOperationComponent); given(technologyOperationComponent.getBoole... |
MrpAlgorithmStrategyTS implements MrpAlgorithmStrategy { public Map<Long, BigDecimal> perform(final OperationProductComponentWithQuantityContainer productComponentWithQuantities, final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm, final String operationProductComponentModelName) {... | @Test public void shouldReturnMapWithoutProductFromSubcontractingOperation() throws Exception { Map<Long, BigDecimal> productsMap = algorithmStrategyTS.perform(productComponentQuantities, nonComponents, MrpAlgorithm.COMPONENTS_AND_SUBCONTRACTORS_PRODUCTS, "productInComponent"); assertEquals(2, productsMap.size()); asse... |
OrderRealizationTimeServiceImpl implements OrderRealizationTimeService { @Override @Transactional public int estimateOperationTimeConsumption(final EntityTreeNode operationComponent, final BigDecimal plannedQuantity, final boolean includeTpz, final boolean includeAdditionalTime, final Entity productionLine) { Entity te... | @Test public void shouldReturnCorrectOperationTimeWithShifts() { boolean includeTpz = true; boolean includeAdditionalTime = true; BigDecimal plannedQuantity = new BigDecimal(1); int time = orderRealizationTimeServiceImpl.estimateOperationTimeConsumption(opComp1, plannedQuantity, includeTpz, includeAdditionalTime, produ... |
OrderRealizationTimeServiceImpl implements OrderRealizationTimeService { @Override @Transactional public int estimateMaxOperationTimeConsumptionForWorkstation(final EntityTreeNode operationComponent, final BigDecimal plannedQuantity, final boolean includeTpz, final boolean includeAdditionalTime, final Entity production... | @Test public void shouldCalculateMaxTimeConsumptionPerWorkstationCorrectly() { boolean includeTpz = true; boolean includeAdditionalTime = true; BigDecimal plannedQuantity = new BigDecimal(1); when(productionLinesService.getWorkstationTypesCount(opComp1, productionLine)).thenReturn(2); when(productionLinesService.getWor... |
MultitransferListeners { public void fillUnitsInADL(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { fillUnitsInADL(view, PRODUCTS); } @Transactional void createMultitransfer(final ViewDefinitionState view, final ComponentState state, final String[] args); boolean checkIfTran... | @Test public void shouldFillUnitsInADL() { multitransferListeners.fillUnitsInADL(view, state, null); verify(unit).setFieldValue(L_UNIT); verify(formComponent).setEntity(productQuantity); } |
MultitransferListeners { @Transactional public void createMultitransfer(final ViewDefinitionState view, final ComponentState state, final String[] args) { if (!isMultitransferFormValid(view)) { return; } FormComponent multitransferForm = (FormComponent) view.getComponentByReference(L_FORM); FieldComponent typeField = (... | @Ignore @Test public void shouldCreateMultitransfer() { multitransferListeners.createMultitransfer(view, state, null); verify(form).addMessage("materialFlow.multitransfer.generate.success", MessageType.SUCCESS); } |
MatchingChangeoverNormsDetailsHooks { public void setFieldsVisible(final ViewDefinitionState view) { FormComponent form = (FormComponent) view.getComponentByReference(L_FORM); ComponentState matchingNorm = view.getComponentByReference("matchingNorm"); ComponentState matchingNormNotFound = view.getComponentByReference("... | @Test public void shouldntSetFieldsVisibleWhenNormsNotFound() { given(form.getEntityId()).willReturn(null); hooks.setFieldsVisible(view); verify(matchingNorm).setVisible(false); verify(matchingNormNotFound).setVisible(true); }
@Test public void shouldSetFieldsVisibleWhenNormsFound() { given(form.getEntityId()).willRetu... |
MultitransferListeners { public void getFromTemplates(final ViewDefinitionState view, final ComponentState state, final String[] args) { getFromTemplates(view); } @Transactional void createMultitransfer(final ViewDefinitionState view, final ComponentState state, final String[] args); boolean checkIfTransferIsValid(For... | @Ignore @Test public void shouldDownloadProductsFromTemplates() { given(template.getBelongsToField(PRODUCT)).willReturn(product); given( dataDefinitionService.get(MaterialFlowMultitransfersConstants.PLUGIN_IDENTIFIER, MaterialFlowMultitransfersConstants.MODEL_PRODUCT_QUANTITY)).willReturn(productQuantityDD); given(prod... |
MultitransferViewHooks { public void makeFieldsRequired(final ViewDefinitionState view) { for (String componentRef : COMPONENTS) { FieldComponent component = (FieldComponent) view.getComponentByReference(componentRef); component.setRequired(true); component.requestComponentUpdateState(); } } void makeFieldsRequired(fi... | @Test public void shouldMakeTimeAndTypeFieldsRequired() { given(view.getComponentByReference(TIME)).willReturn(time); given(view.getComponentByReference(TYPE)).willReturn(type); multitransferViewHooks.makeFieldsRequired(view); verify(time).setRequired(true); verify(type).setRequired(true); } |
MessagesUtil { public static String joinArgs(final String[] splittedArgs) { if (ArrayUtils.isEmpty(splittedArgs)) { return null; } return StringUtils.join(splittedArgs, ARGS_SEPARATOR); } private MessagesUtil(); static String joinArgs(final String[] splittedArgs); static String[] splitArgs(final String joinedArgs); st... | @Test public final void shouldReturnJoinedString() { final String[] splittedArgs = new String[] { "mes", "plugins", "states", "test" }; final String joinedString = MessagesUtil.joinArgs(splittedArgs); final String expectedString = splittedArgs[0] + ARGS_SEPARATOR + splittedArgs[1] + ARGS_SEPARATOR + splittedArgs[2] + A... |
MessagesUtil { public static String[] splitArgs(final String joinedArgs) { if (StringUtils.isBlank(joinedArgs)) { return ArrayUtils.EMPTY_STRING_ARRAY; } return joinedArgs.split(ARGS_SEPARATOR); } private MessagesUtil(); static String joinArgs(final String[] splittedArgs); static String[] splitArgs(final String joined... | @Test public final void shouldReturnSplittedString() { final String arg1 = "mes"; final String arg2 = "plugins"; final String arg3 = "states"; final String arg4 = "test"; final String joinedArgs = arg1 + ARGS_SEPARATOR + arg2 + ARGS_SEPARATOR + arg3 + ARGS_SEPARATOR + arg4; final String[] splittedString = MessagesUtil.... |
MessagesUtil { public static boolean hasFailureMessages(final List<Entity> messages) { return hasMessagesOfType(messages, StateMessageType.FAILURE); } private MessagesUtil(); static String joinArgs(final String[] splittedArgs); static String[] splitArgs(final String joinedArgs); static boolean hasFailureMessages(final... | @Test public final void shouldHasFailureMessagesReturnTrue() { List<Entity> messages = Lists.newArrayList(); messages.add(mockMessage(StateMessageType.FAILURE, "test")); EntityList messagesEntityList = mockEntityList(messages); boolean result = MessagesUtil.hasFailureMessages(messagesEntityList); assertTrue(result); }
... |
MessagesUtil { public static boolean isAutoClosed(final Entity message) { return message.getField(AUTO_CLOSE) == null || message.getBooleanField(AUTO_CLOSE); } private MessagesUtil(); static String joinArgs(final String[] splittedArgs); static String[] splitArgs(final String joinedArgs); static boolean hasFailureMessa... | @Test public final void shouldIsAutoClosedReturnFalseIfFieldValueIsFalse() { final Entity message = mock(Entity.class); given(message.getField(MessageFields.AUTO_CLOSE)).willReturn(false); given(message.getBooleanField(MessageFields.AUTO_CLOSE)).willReturn(false); final boolean result = MessagesUtil.isAutoClosed(messag... |
StateChangeViewClientValidationUtil { public void addValidationErrorMessages(final ComponentState component, final StateChangeContext stateChangeContext) { addValidationErrorMessages(component, stateChangeContext.getOwner(), stateChangeContext); } void addValidationErrorMessages(final ComponentState component, final S... | @Test public final void shouldAddValidationErrorToEntityField() { final String existingFieldName = "existingField"; FieldDefinition existingField = mockFieldDefinition(existingFieldName); DataDefinition dataDefinition = mockDataDefinition(Lists.newArrayList(existingField)); given(entity.getDataDefinition()).willReturn(... |
AbstractStateChangeDescriber implements StateChangeEntityDescriber { @Override public void checkFields() { DataDefinition dataDefinition = getDataDefinition(); List<String> fieldNames = Lists.newArrayList(getOwnerFieldName(), getSourceStateFieldName(), getTargetStateFieldName(), getStatusFieldName(), getMessagesFieldNa... | @Test public final void shouldCheckFieldsPass() { try { testStateChangeDescriber.checkFields(); } catch (IllegalStateException e) { fail(); } }
@Test public final void shouldCheckFieldsThrowExceptionIfAtLeastOneFieldIsMissing() { dataDefFieldsSet.remove("sourceState"); try { testStateChangeDescriber.checkFields(); } ca... |
MatchingChangeoverNormsDetailsHooks { public void fillOrCleanFields(final ViewDefinitionState view) { FormComponent form = (FormComponent) view.getComponentByReference(L_FORM); if (form.getEntityId() == null) { listeners.clearField(view); listeners.changeStateEditButton(view, false); } else { Entity changeover = dataDe... | @Test public void shouldFillOrCleanFieldsNormsNotFound() { given(form.getEntityId()).willReturn(null); hooks.fillOrCleanFields(view); verify(listeners).clearField(view); verify(listeners).changeStateEditButton(view, false); }
@Test public void shouldFillOrCleanFieldsWhenNormsFound() { given(form.getEntityId()).willRetu... |
Sha1Digest implements MessageDigest { public String calculate(final InputStream inputStream) throws IOException { logger.trace("Calculating message digest"); return DigestUtils.sha1Hex(inputStream); } String calculate(final InputStream inputStream); String calculate(final File file); String calculate(String path); boo... | @Test public void testCalculateInputStream() throws IOException { try (InputStream inputStream = getClass().getResourceAsStream("message.txt")) { Sha1Digest sha1Digest = new Sha1Digest(); String ret = sha1Digest.calculate(inputStream); assertEquals("The message digest do not match", MESSAGE_DIGEST, ret); } } |
WorkerDataUtils { public static <T extends MaestroWorker> BinaryRateWriter writer(final File reportFolder, final T worker) throws IOException { assert worker != null : "Invalid worker type"; if (worker instanceof MaestroSenderWorker) { return new BinaryRateWriter(new File(reportFolder, "sender.dat"), FileHeader.WRITER_... | @Test public void testCreate() throws IOException { String path = this.getClass().getResource(".").getPath(); File reportDir = new File(path); try (BinaryRateWriter writer = WorkerDataUtils.writer(reportDir, new DummySender())) { assertNotNull("The writer should not be null", writer); assertEquals("The report path does... |
JmsOptions { public JmsOptions(final String url) { try { final URI uri = new URI(url); final URLQuery urlQuery = new URLQuery(uri); protocol = JMSProtocol.valueOf(urlQuery.getString("protocol", JMSProtocol.AMQP.name())); path = uri.getPath(); type = urlQuery.getString("type", "queue"); configuredLimitDestinations = url... | @Test public void testJmsOptions() { final String url = "amqps: JmsOptions jmsOptions = new JmsOptions(url); assertFalse("Expected durable to be false", jmsOptions.isDurable()); assertEquals("The connection URL does not match the expected one", "amqps: jmsOptions.getConnectionUrl()); } |
JMSClient implements Client { public static String setupLimitDestinations(final String destinationName, final int limitDestinations, final int clientNumber) { String ret = destinationName; if (limitDestinations >= 1) { logger.debug("Client requested a client-specific limit to the number of destinations: {}", limitDesti... | @Test public void testLimitDestinations() { final String requestedDestName = "test.unit.queue"; for (int i = 0; i < 5; i++) { String destinationName = JMSClient.setupLimitDestinations("test.unit.queue", 5, i); assertEquals("The destination name does not match the expected one", requestedDestName + "." + i, destinationN... |
StringUtils { public static String capitalize(final String string) { if (string != null && string.length() >= 2) { return string.substring(0, 1).toUpperCase() + string.substring(1); } else { return string; } } private StringUtils(); static String capitalize(final String string); } | @Test public void testCapitalize() { assertEquals("Username", StringUtils.capitalize("username")); assertEquals("u", StringUtils.capitalize("u")); assertEquals("Uu", StringUtils.capitalize("uu")); assertEquals(null, StringUtils.capitalize(null)); assertEquals("", StringUtils.capitalize("")); } |
BinaryRateWriter implements RateWriter { @Override public void close() { try { flush(); fileChannel.close(); } catch (IOException e) { Logger logger = LoggerFactory.getLogger(BinaryRateWriter.class); logger.error(e.getMessage(), e); } } BinaryRateWriter(final File reportFile, final FileHeader fileHeader); @Override Fil... | @Test public void testHeader() throws IOException { String path = this.getClass().getResource(".").getPath(); File reportFile = new File(path, "testHeader.dat"); try { BinaryRateWriter binaryRateWriter = new BinaryRateWriter(reportFile, FileHeader.WRITER_DEFAULT_SENDER); binaryRateWriter.close(); try (BinaryRateReader ... |
BinaryRateWriter implements RateWriter { private void write() throws IOException { byteBuffer.flip(); while (byteBuffer.hasRemaining()) { fileChannel.write(byteBuffer); } byteBuffer.flip(); byteBuffer.clear(); } BinaryRateWriter(final File reportFile, final FileHeader fileHeader); @Override File reportFile(); void writ... | @Test(expected = InvalidRecordException.class) public void testHeaderWriteRecordsNonSequential() throws IOException { String path = this.getClass().getResource(".").getPath(); File reportFile = new File(path, "testHeaderWriteRecordsNonSequential.dat"); try (BinaryRateWriter binaryRateWriter = new BinaryRateWriter(repor... |
BinaryRateUpdater implements AutoCloseable { public static void joinFile(final BinaryRateUpdater binaryRateUpdater, final File reportFile1) throws IOException { try (BinaryRateReader reader = new BinaryRateReader(reportFile1)) { if (!binaryRateUpdater.isOverlay()) { FileHeader header = binaryRateUpdater.getFileHeader()... | @Test public void testJoinFile() throws IOException { String path = this.getClass().getResource(".").getPath(); File reportFile = new File(path, "sender.dat"); File baseFile = new File(path, "sender-0.dat"); FileUtils.copyFile(baseFile, reportFile); try (BinaryRateUpdater binaryRateUpdater = new BinaryRateUpdater(repor... |
PropertyUtils { public static void loadProperties(final File testProperties, Map<String, Object> context) { if (testProperties.exists()) { Properties prop = new Properties(); try (FileInputStream in = new FileInputStream(testProperties)) { prop.load(in); prop.forEach((key, value) -> addToContext(context, key, value)); ... | @Test public void testLoadProperties() { final Map<String, Object> context = new HashMap<>(); final String path = this.getClass().getResource("test-with-query-params.properties").getPath(); final File propertiesFile = new File(path); PropertyUtils.loadProperties(propertiesFile, context); assertEquals("10", context.get(... |
Sha1Digest implements MessageDigest { public boolean verify(String source) throws IOException { try (InputStream stream = new FileInputStream(source + "." + HASH_NAME)) { final String digest = IOUtils.toString(stream, Charset.defaultCharset()).trim(); return verify(source, digest); } } String calculate(final InputStre... | @Test public void testVerify() throws IOException { Sha1Digest sha1Digest = new Sha1Digest(); boolean ret = sha1Digest.verify(MESSAGE_FILE, MESSAGE_DIGEST); assertTrue("The message digest do not match", ret); } |
DurationDrain extends DurationCount { @Override public boolean canContinue(TestProgress progress) { long count = progress.messageCount(); return !staleChecker.isStale(count); } DurationDrain(); @Override boolean canContinue(TestProgress progress); static final String DURATION_DRAIN_FORMAT; } | @Test public void testCanContinue() { DurationDrain durationDrain = new DurationDrain(); assertEquals(-1, durationDrain.getNumericDuration()); DurationCountTest.DurationCountTestProgress progress = new DurationCountTest.DurationCountTestProgress(); for (int i = 0; i < 10; i++) { assertTrue(durationDrain.canContinue(pro... |
DurationTime implements TestDuration { @Override public boolean canContinue(final TestProgress snapshot) { final long currentDuration = snapshot.elapsedTime(outputTimeUnit); return currentDuration < expectedDuration; } DurationTime(final String timeSpec); @Override boolean canContinue(final TestProgress snapshot); @Ove... | @Test(timeout = 15000) public void testCanContinue() throws DurationParseException { DurationTime durationTime = new DurationTime("5s"); DurationTimeProgress progress = new DurationTimeProgress(System.currentTimeMillis()); assertTrue(durationTime.canContinue(progress)); try { Thread.sleep(5000); } catch (InterruptedExc... |
DurationTime implements TestDuration { @Override public long getNumericDuration() { return expectedDuration; } DurationTime(final String timeSpec); @Override boolean canContinue(final TestProgress snapshot); @Override long getNumericDuration(); @Override TestDuration getWarmUpDuration(); @Override TestDuration getCoolD... | @Test public void testExpectedDuration() throws DurationParseException { assertEquals(5, new DurationTime("5s").getNumericDuration()); assertEquals(300, new DurationTime("5m").getNumericDuration()); assertEquals(3900, new DurationTime("1h5m").getNumericDuration()); } |
DurationTime implements TestDuration { public String toString() { return timeSpec; } DurationTime(final String timeSpec); @Override boolean canContinue(final TestProgress snapshot); @Override long getNumericDuration(); @Override TestDuration getWarmUpDuration(); @Override TestDuration getCoolDownDuration(); String toSt... | @Test public void testToStringRetainFormat() throws DurationParseException { assertEquals("5s", new DurationTime("5s").toString()); assertEquals("5m", new DurationTime("5m").toString()); assertEquals("1h5m", new DurationTime("1h5m").toString()); } |
DurationCount implements TestDuration { @Override public boolean canContinue(final TestProgress progress) { return progress.messageCount() < count; } DurationCount(final String durationSpec); DurationCount(long count); @Override boolean canContinue(final TestProgress progress); @Override long getNumericDuration(); @O... | @Test public void testCanContinue() { DurationCount durationCount = new DurationCount("10"); assertEquals(10L, durationCount.getNumericDuration()); DurationCountTestProgress progress = new DurationCountTestProgress(); for (int i = 0; i < durationCount.getNumericDuration(); i++) { assertTrue(durationCount.canContinue(pr... |
WorkerUtils { public static long getExchangeInterval(final long rate) { return rate > 0 ? (1_000_000_000L / rate) : 0; } private WorkerUtils(); static long getExchangeInterval(final long rate); static long waitNanoInterval(final long expectedFireTime, final long intervalInNanos); } | @Test public void testRate() { assertEquals(0, WorkerUtils.getExchangeInterval(0)); assertEquals(20000, WorkerUtils.getExchangeInterval(50000)); } |
XunitWriter { public void saveToXML(final File outputFile, TestSuites testSuites) { Element rootEle = dom.createElement("testsuites"); serializeTestSuites(rootEle, testSuites.getTestSuiteList()); serializeProperties(rootEle, testSuites.getProperties()); dom.appendChild(rootEle); try { Transformer tr = TransformerFactor... | @Test public void testSaveXmlSuccess() { String path = this.getClass().getResource("/").getPath() + "xunit.success.xml"; TestCase warmUpTc = new TestCase(); warmUpTc.setAssertions(1); warmUpTc.setClassName("singlepoint.FixedRate"); warmUpTc.setName("AMQP-s-1024-c-30-ld-10-durable-false"); warmUpTc.setTime(Duration.ofSe... |
Sha1Digest implements MessageDigest { public void save(String source) throws IOException { final String digest = calculate(source); final File file = new File(source + "." + HASH_NAME); if (file.exists()) { if (!file.delete()) { throw new IOException("Unable to delete an existent file: " + file.getPath()); } } else { i... | @Test public void testSave() throws IOException { Sha1Digest sha1Digest = new Sha1Digest(); sha1Digest.save(MESSAGE_FILE); sha1Digest.verify(MESSAGE_FILE); } |
URLUtils { public static String rewritePath(final String inputUrl, final String string) { try { URI url = new URI(inputUrl); final String userInfo = url.getUserInfo(); final String host = url.getHost(); if (host == null) { throw new MaestroException("Invalid URI: null host"); } URI ret; if (host.equals(userInfo)) { ret... | @Test public void testURLPathRewrite() { String originalUrl = "amqp: String expectedUrl = "amqp: String ret = URLUtils.rewritePath(originalUrl, "worker"); assertEquals(expectedUrl, ret); }
@Test public void testURLPathRewriteWithUser() { String originalUrl = "amqp: String expectedUrl = "amqp: String ret = URLUtils.rewr... |
ContentStrategyFactory { public static ContentStrategy parse(final String sizeSpec) { ContentStrategy ret; if (sizeSpec.startsWith("~")) { ret = new VariableSizeContent(sizeSpec); } else { ret = new FixedSizeContent(sizeSpec); } return ret; } private ContentStrategyFactory(); static ContentStrategy parse(final String ... | @Test public void testParse() { assertTrue(ContentStrategyFactory.parse("100") instanceof FixedSizeContent); assertTrue(ContentStrategyFactory.parse("~100") instanceof VariableSizeContent); } |
VariableSizeContent implements ContentStrategy { @Override public ByteBuffer prepareContent() { final int currentLimit = ThreadLocalRandom.current().nextInt(this.lowerLimitInclusive, this.upperLimitExclusive); buffer.clear(); buffer.limit(currentLimit); return buffer; } VariableSizeContent(int size); VariableSizeCont... | @Test public void testPrepareContent() { VariableSizeContent content = new VariableSizeContent(100); assertEquals(96, content.minSize()); assertEquals(105, content.maxSize()); for (int i = 0; i < 100; i++) { ByteBuffer buffer = content.prepareContent(); final int length = buffer.remaining(); final int position = buffer... |
FixedSizeContent implements ContentStrategy { @Override public ByteBuffer prepareContent() { return buffer; } FixedSizeContent(int size); FixedSizeContent(final String sizeSpec); @Override ByteBuffer prepareContent(); } | @Test public void testPepareContent() { FixedSizeContent content = new FixedSizeContent(100); for (int i = 0; i < 100; i++) { ByteBuffer buffer = content.prepareContent(); final int length = buffer.remaining(); assertEquals(100, length); } } |
MessageSize { public static String variable(long value) { return "~" + Long.toString(value); } private MessageSize(); static String variable(long value); static String fixed(long value); static boolean isVariable(final String sizeSpec); static int toSizeFromSpec(final String sizeSpec); } | @Test public void testVariable() { assertEquals("~1024", MessageSize.variable(1024)); } |
WorkerStateInfoUtil { public static boolean isCleanExit(WorkerStateInfo wsi) { if (wsi.getExitStatus() == WorkerStateInfo.WorkerExitStatus.WORKER_EXIT_SUCCESS) { return true; } return wsi.getExitStatus() == WorkerStateInfo.WorkerExitStatus.WORKER_EXIT_STOPPED; } private WorkerStateInfoUtil(); static boolean isCleanExi... | @Test public void testCleanExitOnDefault() { WorkerStateInfo wsi = new WorkerStateInfo(); assertTrue(WorkerStateInfoUtil.isCleanExit(wsi)); assertNotNull(wsi.getExitStatus()); }
@Test public void testCleanExitOnStopped() { WorkerStateInfo wsi = new WorkerStateInfo(); wsi.setState(false, WorkerStateInfo.WorkerExitStatus... |
MessageSize { public static String fixed(long value) { return Long.toString(value); } private MessageSize(); static String variable(long value); static String fixed(long value); static boolean isVariable(final String sizeSpec); static int toSizeFromSpec(final String sizeSpec); } | @Test public void testFixed() { assertEquals("1024", MessageSize.fixed(1024)); } |
MessageSize { public static boolean isVariable(final String sizeSpec) { return sizeSpec.startsWith("~"); } private MessageSize(); static String variable(long value); static String fixed(long value); static boolean isVariable(final String sizeSpec); static int toSizeFromSpec(final String sizeSpec); } | @Test public void isVariable() { assertTrue(MessageSize.isVariable("~1024")); assertFalse(MessageSize.isVariable("1024")); } |
MessageSize { public static int toSizeFromSpec(final String sizeSpec) { if (isVariable(sizeSpec)) { return Integer.parseInt(sizeSpec.replace("~", "")); } return Integer.parseInt(sizeSpec); } private MessageSize(); static String variable(long value); static String fixed(long value); static boolean isVariable(final Stri... | @Test public void toSizeFromSpec() { assertEquals(1024, MessageSize.toSizeFromSpec("~1024")); } |
LangUtils { public static <T extends Closeable> void closeQuietly(T object) { if (object != null) { try { object.close(); } catch (IOException ignored) { } } } private LangUtils(); static void closeQuietly(T object); } | @Test public void closeQuietly() { LangUtils.closeQuietly(null); MockCloseeable mock = new MockCloseeable(); LangUtils.closeQuietly(mock); assertTrue(mock.closeCalled); } |
URLQuery { public boolean getBoolean(final String name, boolean defaultValue) { String value = getString(name, null); if (value == null) { return defaultValue; } if (value.equalsIgnoreCase("true")) { return true; } else { if (value.equalsIgnoreCase("false")) { return false; } } return defaultValue; } URLQuery(final Str... | @Test public void testQueryWithFalse() throws Exception { String url = "amqp: URLQuery urlQuery = new URLQuery(new URI(url)); assertFalse(urlQuery.getBoolean("value1", true)); assertTrue(urlQuery.getBoolean("value2", false)); } |
URLQuery { public Long getLong(final String name, final Long defaultValue) { String value = getString(name, null); if (value == null) { return defaultValue; } return Long.parseLong(value); } URLQuery(final String uri); URLQuery(URI uri); String getString(final String name, final String defaultValue); boolean getBoolea... | @Test public void testQueryWithLong() throws Exception { String url = "amqp: URLQuery urlQuery = new URLQuery(new URI(url)); assertEquals(1234L, (long) urlQuery.getLong("value1", 0L)); } |
ReportDao extends AbstractDao { public void insert(final Report report) { runEmptyInsert( "insert into report(test_id, test_number, test_name, test_script, test_host, test_host_role, " + "test_result, test_result_message, location, aggregated, test_description, test_comments, " + "valid, retired, retired_date, test_dat... | @Test public void testInsert() { Report report = new Report(); report.setTestHost("localhost"); report.setTestHostRole(HostTypes.SENDER_HOST_TYPE); report.setTestName("unit-test"); report.setTestNumber(1); report.setTestId(1); report.setLocation(this.getClass().getResource(".").getPath()); report.setTestResult(ResultSt... |
ReportDao extends AbstractDao { public List<Report> fetchAll() throws DataNotFoundException { return runQueryMany("select * from report", new BeanPropertyRowMapper<>(Report.class)); } ReportDao(); ReportDao(TemplateBuilder tp); void insert(final Report report); int update(final Report report); List<Report> fetch(); Li... | @Test public void testFetchAll() throws DataNotFoundException { List<Report> reports = dao.fetch(); assertTrue("The database should not be empty", reports.size() > 0); long aggregatedCount = reports.stream().filter(Report::isAggregated).count(); long expectedAggCount = 0; assertEquals("Aggregated reports should not be ... |
ReportDao extends AbstractDao { public List<Report> fetch() throws DataNotFoundException { return runQueryMany("select * from report where aggregated = false and valid = true order by report_id desc", new BeanPropertyRowMapper<>(Report.class)); } ReportDao(); ReportDao(TemplateBuilder tp); void insert(final Report rep... | @Test public void testFetchById() throws DataNotFoundException { List<Report> reports = dao.fetch(2, 1); assertTrue("There should be at least 3 records for the given ID", reports.size() >= 3); long aggregatedCount = reports.stream().filter(Report::isAggregated).count(); long expectedAggCount = 0; assertEquals("Aggregat... |
ReportDao extends AbstractDao { public List<ReportAggregationInfo> aggregationInfo() throws DataNotFoundException { return runQueryMany("SELECT test_id,test_number,sum(aggregated) AS aggregations FROM report " + "GROUP BY test_id,test_number ORDER BY test_id desc", new BeanPropertyRowMapper<>(ReportAggregationInfo.clas... | @Test public void testAggregationInfo() throws DataNotFoundException { List<ReportAggregationInfo> aggregationInfos = dao.aggregationInfo(); long expectedAggregatedCount = 2; assertEquals("Unexpected amount of aggregated records", expectedAggregatedCount, aggregationInfos.size()); } |
InterconnectInfoConverter { public List<Map<String, Object>> parseReceivedMessage(Map<?, ?> map) { List<Map<String, Object>> recordList = new ArrayList<>(); if (map == null || map.isEmpty()) { logger.warn("The received attribute map is empty or null"); return recordList; } Object tmpAttributeNames = map.get("attributeN... | @SuppressWarnings("unchecked") @Test public void parseReceivedMessage() { InterconnectInfoConverter converter = new InterconnectInfoConverter(); Map<String, Object> fakeMap = buildTestMap(); List<Map<String, Object>> ret = converter.parseReceivedMessage(fakeMap); assertNotNull(ret); assertEquals(3, ret.size()); Map<Str... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.