@Before
  public void setup() {
    insuranceCart2QuoteListingPopulator = new InsuranceCart2QuoteListingPopulator();
    MockitoAnnotations.initMocks(this);

    quoteListingData = new InsuranceQuoteListingData();
    cartData = new CartData();
    final PriceData priceData = new PriceData();
    priceData.setFormattedValue(testFormattedValue);
    cartData.setTotalPrice(priceData);
    cartData.setCode(testCartCode);

    final List<OrderEntryData> entries = new ArrayList<>();
    final OrderEntryData orderEntryData = new OrderEntryData();
    final ProductData productData = new ProductData();
    productData.setName(testProductName);
    productData.setImages(imageDataList);
    orderEntryData.setProduct(productData);
    entries.add(orderEntryData);
    cartData.setEntries(entries);
    final SubscriptionPricePlanData pricePlanData = new SubscriptionPricePlanData();
    productData.setPrice(pricePlanData);

    quoteData = new InsuranceQuoteData();
    cartData.setInsuranceQuote(quoteData);
    quoteData.setFormattedExpiryDate(testQuoteFormattedExpiryDate);
  }
 @Test
 public void testReferencesForPurchasedInCategory() {
   final UserModel user = userService.getUserForUID("dejol");
   userService.setCurrentUser(user);
   List<ProductData> result =
       simpleSuggestionFacade.getReferencesForPurchasedInCategory(
           "cameras", Collections.EMPTY_LIST, false, null);
   Assert.assertEquals(4, result.size());
   result =
       simpleSuggestionFacade.getReferencesForPurchasedInCategory(
           "cameras", Collections.EMPTY_LIST, false, NumberUtils.INTEGER_ONE);
   Assert.assertEquals(1, result.size());
   result =
       simpleSuggestionFacade.getReferencesForPurchasedInCategory(
           "cameras", Arrays.asList(ProductReferenceTypeEnum.SIMILAR), false, null);
   Assert.assertEquals(1, result.size());
   result =
       simpleSuggestionFacade.getReferencesForPurchasedInCategory(
           "cameras", Arrays.asList(ProductReferenceTypeEnum.ACCESSORIES), false, null);
   Assert.assertEquals(2, result.size());
   result =
       simpleSuggestionFacade.getReferencesForPurchasedInCategory(
           "cameras", Arrays.asList(ProductReferenceTypeEnum.ACCESSORIES), true, null);
   Assert.assertEquals(1, result.size());
   final ProductData product = result.get(0);
   Assert.assertEquals("adapterDC", product.getCode());
   Assert.assertEquals("adapter", product.getName());
 }
コード例 #3
0
  protected String getPointOfServiceForStorePickup(
      final String productCode,
      final String locationQuery,
      final GeoPoint geoPoint,
      final int page,
      final AbstractSearchPageController.ShowMode showMode,
      final String sortCode,
      final Boolean cartPage,
      final Long entryNumber,
      final Model model,
      final RequestMethod requestMethod,
      final HttpServletResponse response) {
    final int pagination =
        getSiteConfigService().getInt(POINTOFSERVICE_DISPLAY_SEARCH_RESULTS_COUNT, 6);
    final ProductData productData = new ProductData();
    productData.setCode(productCode);

    final StoreFinderStockSearchPageData<PointOfServiceStockData> storeFinderStockSearchPageData;

    if (StringUtils.isNotBlank(locationQuery)) {
      storeFinderStockSearchPageData =
          storeFinderStockFacade.productSearch(
              locationQuery, productData, createPageableData(page, pagination, sortCode, showMode));
      model.addAttribute("locationQuery", locationQuery.trim());
      if (RequestMethod.POST.equals(requestMethod)
          && storeFinderStockSearchPageData.getPagination().getTotalNumberOfResults() > 0) {
        final UserLocationData userLocationData = new UserLocationData();

        if (geoPoint != null) {
          userLocationData.setPoint(geoPoint);
        }

        userLocationData.setSearchTerm(locationQuery);
        customerLocationFacade.setUserLocationData(userLocationData);
        cookieGenerator.addCookie(response, generatedUserLocationDataString(userLocationData));
      }
    } else if (geoPoint != null) {
      storeFinderStockSearchPageData =
          storeFinderStockFacade.productSearch(
              geoPoint, productData, createPageableData(page, pagination, sortCode, showMode));
      model.addAttribute("geoPoint", geoPoint);
      if (RequestMethod.POST.equals(requestMethod)
          && storeFinderStockSearchPageData.getPagination().getTotalNumberOfResults() > 0) {
        final UserLocationData userLocationData = new UserLocationData();
        userLocationData.setPoint(geoPoint);
        customerLocationFacade.setUserLocationData(userLocationData);
        cookieGenerator.addCookie(response, generatedUserLocationDataString(userLocationData));
      }
    } else {
      storeFinderStockSearchPageData = emptyStoreFinderResult(productData);
    }

    populateModel(model, storeFinderStockSearchPageData, showMode);

    model.addAttribute("cartPage", cartPage);
    model.addAttribute("entryNumber", entryNumber);

    return ControllerConstants.Views.Fragments.Product.StorePickupSearchResults;
  }
 @Override
 public void populate(final SearchResultValueData source, final ProductData target) {
   // super.populate(source, target);
   target.setMultidimensional(this.<Boolean>getValue(source, MULTIDIMENSIONAL));
   target.setFirstVariantUrl(this.<String>getValue(source, FIRST_VARIANT_URL));
   setPriceRange(source, target);
   setFirstCategoryNameList(source, target);
 }
コード例 #5
0
  @Override
  public void populate(final ProductModel source, final ProductData target) {
    Assert.notNull(source, "Parameter source cannot be null.");
    Assert.notNull(target, "Parameter target cannot be null.");

    target.setCode(source.getCode());
    target.setName(source.getName());
    target.setUrl(getProductModelUrlResolver().resolve(source));
  }
コード例 #6
0
  @Test
  public void testPopulate() {
    // create search result values
    final SearchResultValueData searchResultValueData = new SearchResultValueData();
    final Map<String, Object> searchValueMap = new HashMap<String, Object>();
    searchValueMap.put(BillingPlanModel.BILLINGFREQUENCY, "monthly");
    searchValueMap.put(ProductModel.SOLDINDIVIDUALLY, Boolean.TRUE);
    searchValueMap.put(SubscriptionTermModel.TERMOFSERVICERENEWAL, "yearly");
    searchValueMap.put("termLimit", "18 months");
    searchValueMap.put("lowestBundlePriceValue", Double.valueOf(1.99));
    searchResultValueData.setValues(searchValueMap);

    final CurrencyModel currency = new CurrencyModel();
    currency.setIsocode("USD");
    final PriceData priceData = new PriceData();
    priceData.setValue(BigDecimal.valueOf(1.99));
    priceData.setCurrencyIso(currency.getIsocode());
    given(commonI18NService.getCurrentCurrency()).willReturn(currency);
    given(
            priceDataFactory.create(
                PriceDataType.BUY, BigDecimal.valueOf(1.99), currency.getIsocode()))
        .willReturn(priceData);

    final ProductData productData = new ProductData();
    searchProductTelcoPopulator.populate(searchResultValueData, productData);

    assertNotNull("", productData.getSubscriptionTerm());
    assertNotNull("", productData.getSubscriptionTerm().getBillingPlan());
    assertNotNull("", productData.getSubscriptionTerm().getBillingPlan().getBillingTime());
    assertEquals(
        "",
        searchProductTelcoPopulator.getValue(searchResultValueData, "billingTime"),
        productData.getSubscriptionTerm().getBillingPlan().getBillingTime().getName());
    assertEquals(
        "",
        searchProductTelcoPopulator.getValue(searchResultValueData, ProductModel.SOLDINDIVIDUALLY),
        Boolean.valueOf(productData.isSoldIndividually()));
    assertNotNull("", productData.getSubscriptionTerm().getTermOfServiceFrequency());
    assertEquals(
        "",
        searchProductTelcoPopulator.getValue(searchResultValueData, "termLimit"),
        productData.getSubscriptionTerm().getTermOfServiceFrequency().getName());
    assertNotNull("", productData.getLowestBundlePrice());
    assertEquals(
        "",
        BigDecimal.valueOf(
            ((Double)
                    searchProductTelcoPopulator.getValue(
                        searchResultValueData, "lowestBundlePriceValue"))
                .doubleValue()),
        productData.getLowestBundlePrice().getValue());
  }
コード例 #7
0
 @Override
 public void populate(final SearchResultValueData source, final ProductData target)
     throws ConversionException {
   Assert.notNull(source, "Parameter source cannot be null.");
   Assert.notNull(target, "Parameter target cannot be null.");
   final Boolean internalOnlyFlag = (Boolean) source.getValues().get("internalOnly");
   target.setInternalOnly(internalOnlyFlag == null ? false : internalOnlyFlag.booleanValue());
 }
コード例 #8
0
  /**
   * Populates the elements in tree with the information retrieved from the variant..
   *
   * @param productModel the product to take the data from.
   * @param productData the data to put the data in.
   * @throws de.hybris.platform.servicelayer.dto.converter.ConversionException
   */
  @Override
  public void populate(final ProductModel productModel, final ProductData productData)
      throws ConversionException {

    final Collection<VariantProductModel> variants = getVariants(productModel);
    for (final VariantProductModel variant : variants) {
      populateNodes(productData.getVariantMatrix(), variant, productModel);
    }
  }
 /**
  * Set list of first categories for the {@link ProductData}.
  *
  * @param source The {@link SearchResultValueData} containing the priceRange.
  * @param target The {@link ProductData} to be modified.
  */
 protected void setFirstCategoryNameList(
     final SearchResultValueData source, final ProductData target) {
   final String categoryListSolr = this.<String>getValue(source, FIRST_CATEGORY_NAME_LIST);
   if (StringUtils.isNotEmpty(categoryListSolr)) {
     final List<SolrFirstVariantCategoryEntryData> variantCategoryList =
         categoryManager.buildFirstVariantCategoryListFromSolrProperty(categoryListSolr);
     target.setFirstCategoryNameList(variantCategoryList);
   }
 }
  /**
   * Set price range for the {@link ProductData}. If there is no priceRange in the source, no {@link
   * PriceRangeData} will be set in the target.
   *
   * @param source The {@link SearchResultValueData} containing the priceRange.
   * @param target The {@link ProductData} to be modified.
   */
  protected void setPriceRange(final SearchResultValueData source, final ProductData target) {
    final PriceRangeData priceRange = new PriceRangeData();
    final String priceRangeValue = this.<String>getValue(source, PRICE_RANGE);
    if (StringUtils.isNotEmpty(priceRangeValue)) {
      final SolrPriceRange solrPriceRange =
          SolrPriceRange.buildSolrPriceRangePairFromProperty(priceRangeValue);
      if (solrPriceRange != null) {
        priceRange.setMinPrice(createPriceData(solrPriceRange.getLower()));
        priceRange.setMaxPrice(createPriceData(solrPriceRange.getHigher()));
      }
    }

    target.setPriceRange(priceRange);
  }
コード例 #11
0
ファイル: Functions.java プロジェクト: raliev2/tn
  /**
   * JSP EL Function to get an image for a Product in a specific format based on the product code.
   *
   * @param product The product.
   * @param productCode The desired product code.
   * @param format The desired format.
   * @return The image.
   */
  public static ImageData getImageForProductCode(
      final ProductData product, final String productCode, final String format) {
    if (product != null && productCode != null && format != null) {

      int selectedIndex = 0;

      for (int i = 1; i <= product.getCategories().size(); i++) {
        int j = 0;
        final List<VariantMatrixElementData> theMatrix;

        if (i == 1) {
          theMatrix = product.getVariantMatrix();
        } else {
          theMatrix = product.getVariantMatrix().get(selectedIndex).getElements();
          selectedIndex = 0;
        }

        if (theMatrix.get(selectedIndex).getParentVariantCategory().getHasImage()) {
          for (final VariantMatrixElementData matrixElementData : theMatrix) {
            if (matrixElementData.getVariantOption().getVariantOptionQualifiers() != null
                && productCode.equals(matrixElementData.getVariantOption().getCode())) {
              for (final VariantOptionQualifierData variantOption :
                  matrixElementData.getVariantOption().getVariantOptionQualifiers()) {
                if (format.equals(variantOption.getImage().getFormat())) {
                  return variantOption.getImage();
                }
              }
              selectedIndex = j;
            }

            j++;
          }
        }
      }
    }
    return null;
  }
コード例 #12
0
ファイル: Functions.java プロジェクト: raliev2/tn
 /**
  * JSP EL Function to get a primary Image for a Product in a specific format
  *
  * @param product the product
  * @param format the desired format
  * @return the image
  */
 public static ImageData getPrimaryImageForProductAndFormat(
     final ProductData product, final String format) {
   if (product != null && format != null) {
     final Collection<ImageData> images = product.getImages();
     if (images != null && !images.isEmpty()) {
       for (final ImageData image : images) {
         if (ImageDataType.PRIMARY.equals(image.getImageType())
             && format.equals(image.getFormat())) {
           return image;
         }
       }
     }
   }
   return null;
 }