当前位置: 首页>>代码示例>>Java>>正文


Java PagedQueryResult类代码示例

本文整理汇总了Java中io.sphere.sdk.queries.PagedQueryResult的典型用法代码示例。如果您正苦于以下问题:Java PagedQueryResult类的具体用法?Java PagedQueryResult怎么用?Java PagedQueryResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PagedQueryResult类属于io.sphere.sdk.queries包,在下文中一共展示了PagedQueryResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeRequest

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
protected final CompletionStage<Optional<Cart>> executeRequest(final CartQuery baseQuery) {
    final CartQuery request = CartQueryHook.runHook(getHookRunner(), baseQuery);
    return getSphereClient().execute(request)
            .thenApply(PagedQueryResult::head)
            .thenApplyAsync(cartOpt -> {
                cartOpt.ifPresent(cart -> CartLoadedHook.runHook(getHookRunner(), cart));
                return cartOpt;
            }, HttpExecution.defaultContext());
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:10,代码来源:AbstractSingleCartQueryExecutor.java

示例2: jobInventoryEntryCreation

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
@Test
public void jobInventoryEntryCreation() throws Exception {
    final int amountOfProducts = 10;
    withJoyrideChannels(sphereClient, joyrideChannels -> {
        withListOfProductProjections(sphereClient, amountOfProducts, productProjections -> {
            assertThat(productProjections).hasSize(amountOfProducts);
            assertThat(joyrideChannels).hasSize(CHANNEL_KEYS.size());
            final InventoryEntryQuery inventoryBaseQuery = InventoryEntryQuery.of();
            final PagedQueryResult<InventoryEntry> inventoryEntryPagedQueryResult = sphereClient.executeBlocking(inventoryBaseQuery.withLimit(0));
            assertThat(inventoryEntryPagedQueryResult.getTotal()).isZero();
            executeInventoryEntryCreationJob();
            validateInventoryEntries(amountOfProducts, joyrideChannels, productProjections, inventoryBaseQuery);
            deleteInventoryEntries(sphereClient);
            return productProjections;
        });
    });
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:18,代码来源:InventoryEntryCreationJobIntegrationTest.java

示例3: deleteCartDiscountAndDiscountCodes

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
public static void deleteCartDiscountAndDiscountCodes(final BlockingSphereClient client, final String englishCartDiscountName, final String cartDiscountSortOrder) {
    final CartDiscountQuery cartDiscountQuery = CartDiscountQuery.of()
            .withPredicates(cartDiscountQueryModel -> cartDiscountQueryModel.name().lang(Locale.ENGLISH).is(englishCartDiscountName));
    final PagedQueryResult<CartDiscount> cartDiscountQueryResult = client.executeBlocking(cartDiscountQuery);
    final List<CartDiscount> cartDiscountsToDelete = cartDiscountQueryResult.getResults().stream()
            .filter(cartDiscount -> cartDiscount.getSortOrder().equals(cartDiscountSortOrder))
            .collect(Collectors.toList());
    final Set<String> cartDiscountIds = cartDiscountsToDelete.stream()
            .map(CartDiscount::getId)
            .collect(Collectors.toSet());
    final PagedQueryResult<DiscountCode> discountCodeQueryResult = client.executeBlocking(DiscountCodeQuery.of());
    final List<DiscountCode> discountCodesToDelete = discountCodeQueryResult.getResults().stream()
            .filter(discountCode -> discountCode.getCartDiscounts().stream().filter(ref -> cartDiscountIds.contains(ref.getId())).findAny().isPresent())
            .collect(Collectors.toList());
    discountCodesToDelete.forEach(discountCode -> deleteDiscountCodeWithRetry(client, discountCode));
    cartDiscountsToDelete.forEach(cartDiscount -> deleteCartDiscountWithRetry(client, cartDiscount));
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:18,代码来源:CartDiscountTestFixtures.java

示例4: isExecuted

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
@Test
public void isExecuted() throws Exception {
    withProductAssignedToOneCategory(categoryIds -> {
        final CategoriesWithProductCountQuery query = CategoriesWithProductCountQuery.of()
                .withPredicates(QueryPredicate.of(CategoryQueryModel.of().id().isIn(categoryIds).toSphereQuery()))
                .withSort(QuerySort.of(CategoryQueryModel.of().createdAt().sort().asc().toSphereSort()))
                .withLimit(2)
                .withOffset(1);
        final PagedQueryResult<CategoryWithProductCount> result = sphereClient.executeBlocking(query);
        assertThat(result.getOffset()).as("offset").isEqualTo(1);
        assertThat(result.getCount()).as("count").isEqualTo(2);
        assertThat(result.getTotal()).as("total").isEqualTo(3);
        assertThat(result.getResults())
                .as("results")
                .extracting(CategoryWithProductCount::hasProducts)
                .isNotNull();
    });
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:19,代码来源:CategoriesWithProductCountQueryIntegrationTest.java

示例5: setup

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
/**
 * Prepares mock data for unit testing the CTP QueryAll utilities; specifically stubs a {@link SphereClient}
 * to always return a {@link PagedQueryResult} containing 4 identical mock categories on every call of
 * {@link SphereClient#execute(SphereRequest)}.
 */
@BeforeClass
public static void setup() {
    final Category mockCategory = mock(Category.class);
    when(mockCategory.getKey()).thenReturn(CATEGORY_KEY);
    when(mockCategory.getId()).thenReturn(CATEGORY_ID);

    final PagedQueryResult<Category> pagedQueryResult =
        PagedQueryResult.of(Arrays.asList(mockCategory, mockCategory, mockCategory, mockCategory));
    when(sphereClient.execute(any())).thenReturn(CompletableFuture.completedFuture(pagedQueryResult));
}
 
开发者ID:commercetools,项目名称:commercetools-sync-java,代码行数:16,代码来源:QueryAllTest.java

示例6: fetchProjectionWithPriceSelection

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
private ProductProjection fetchProjectionWithPriceSelection(final BlockingSphereClient sphereClient, final ProductProjection productProjection, final Channel channel) {
    final CountryCode country = channel.getAddress().getCountry();
    final CurrencyUnit currency = Monetary.getCurrency(country.toLocale());
    final PriceSelection priceSelection = PriceSelection.of(currency).withPriceCountry(country);
    final ProductProjectionQuery productProjectionQuery = ProductProjectionQuery.ofCurrent().withPredicates(m -> m.id().is(productProjection.getId())).withPriceSelection(priceSelection);
    final PagedQueryResult<ProductProjection> result = sphereClient.executeBlocking(productProjectionQuery);
    return result.getResults().get(0);
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:9,代码来源:AvailabilityPricesImportJobConfiguration.java

示例7: findLastProductWithInventory

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
static Optional<ProductProjection> findLastProductWithInventory(final BlockingSphereClient sphereClient) {
    final InventoryEntryQuery inventoryEntryQuery = InventoryEntryQuery.of().withSort(m -> m.lastModifiedAt().sort().desc()).withLimit(1L);
    final Optional<InventoryEntry> inventoryEntryOptional = sphereClient.execute(inventoryEntryQuery).toCompletableFuture().join().head();
    return inventoryEntryOptional.map(inventoryEntry -> {
        final PagedQueryResult<ProductProjection> productProjectionPagedQueryResult
                = sphereClient.executeBlocking(ProductProjectionQuery.ofCurrent().plusPredicates(product -> product.allVariants().where(m -> m.sku().is(inventoryEntry.getSku()))));
        return productProjectionPagedQueryResult.head();
    }).orElse(Optional.empty());
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:10,代码来源:InventoryEntryCreationJobConfiguration.java

示例8: validateInventoryEntries

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
private void validateInventoryEntries(final int amountOfProducts, final List<Channel> joyrideChannels, final List<ProductProjection> productProjections, final InventoryEntryQuery inventoryBaseQuery) {
    final PagedQueryResult<InventoryEntry> inventoryEntriesAfterJobExecution = sphereClient.executeBlocking(inventoryBaseQuery);
    final int expectedAmountOfInventoryEntries = joyrideChannels.size() * amountOfProducts;
    assertThat(inventoryEntriesAfterJobExecution.getTotal()).isEqualTo(expectedAmountOfInventoryEntries);
    inventoryEntriesAfterJobExecution
            .getResults()
            .forEach(inventoryEntry -> {
                final Long expectedStockQuantity = stockQuantityByChannelAndProductVariant(joyrideChannels, productProjections, inventoryEntry);
                assertThat(expectedStockQuantity).isEqualTo(inventoryEntry.getQuantityOnStock());
            });
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:12,代码来源:InventoryEntryCreationJobIntegrationTest.java

示例9: updateOrDeleteResources

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
public static <T, S> void updateOrDeleteResources(final BlockingSphereClient sphereClient, final Query<T> query, final Function<T, S> function) {
    long resourceCount;
    long processedItems = 0L;
    long totalItems = sphereClient.executeBlocking(query).getTotal();
    logger.info("Items to process: " + totalItems);
    do {
        final PagedQueryResult<T> pagedQueryResult = sphereClient.executeBlocking(query);
        resourceCount = pagedQueryResult.getCount();
        pagedQueryResult.getResults().forEach(item -> function.apply(item));
        if (resourceCount > 0) {
            processedItems += resourceCount;
            logger.info("Processed " + processedItems + " of " + totalItems);
        }
    } while (resourceCount > 0);
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:16,代码来源:TestUtils.java

示例10: jobCreatesOrders

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
@Test
public void jobCreatesOrders() throws Exception {

    Path csvPath = Paths.get("data/orders/orders.csv");

    List<String> skus = extractSkusFromCSV(csvPath);
    createProductWithSkus(sphereClient, new HashSet<>(skus));

    final Map<String, JobParameter> jobParametersMap = new HashMap<>();
    jobParametersMap.put("resource", new JobParameter("file://" + csvPath.toAbsolutePath()));
    addCommercetoolsCredentialValues(env, jobParametersMap);
    final JobParameters jobParameters = new JobParameters(jobParametersMap);
    final JobExecution jobExecution = jobLauncherTestUtils.launchJob(jobParameters);
    assertThat(jobExecution.getExitStatus()).isEqualTo(ExitStatus.COMPLETED);


    final OrderQuery orderQuery = OrderQuery.of().withLimit(0);
    final PagedQueryResult<Order> categoryPagedQueryResult = sphereClient.executeBlocking(orderQuery);

    assertThat(categoryPagedQueryResult.getTotal()).isEqualTo(ordersCountUsingEmailAndOrderId(csvPath));

    OrderQuery query = OrderQuery.of().withPredicates(model -> model.customerEmail().is("303"))
            .plusPredicates(model -> model.orderNumber().is("1"));
    final PagedQueryResult<Order> firstOrderResult = sphereClient.executeBlocking(query);

    assertThat(firstOrderResult.getCount()).isEqualTo(1);
    Order order = firstOrderResult.getResults().get(0);

    assertThat(order.getTotalPrice()).isEqualTo(MoneyImpl.ofCents(73375, "EUR"));

    assertThat(order.getLineItems()).extracting("variant")
            .extracting("sku")
            .containsExactly("A0E20000000252G", "M0E20000000DZKB", "A0E200000002AD2");

    assertThat(order.getLineItems()).extracting("quantity")
            .containsExactly(1L, 1L, 1L);

}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:39,代码来源:OrdersImportJobConfigurationIntegrationTest.java

示例11: executeRequest

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
protected final CompletionStage<Optional<Order>> executeRequest(final OrderQuery baseQuery) {
    final OrderQuery query = OrderQueryHook.runHook(getHookRunner(), baseQuery);
    return getSphereClient().execute(query)
            .thenApply(PagedQueryResult::head)
            .thenApplyAsync(orderOpt -> {
                orderOpt.ifPresent(order -> OrderLoadedHook.runHook(getHookRunner(), order));
                return orderOpt;
            }, HttpExecution.defaultContext());
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:10,代码来源:AbstractSingleOrderQueryExecutor.java

示例12: executeRequest

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
protected final CompletionStage<Optional<Customer>> executeRequest(final CustomerQuery baseQuery) {
    final CustomerQuery request = CustomerQueryHook.runHook(getHookRunner(), baseQuery);
    return getSphereClient().execute(request)
            .thenApply(PagedQueryResult::head)
            .thenApplyAsync(customerOpt -> {
                customerOpt.ifPresent(customer -> CustomerLoadedHook.runHook(getHookRunner(), customer));
                return customerOpt;
            }, HttpExecution.defaultContext());
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:10,代码来源:AbstractSingleCustomerQueryExecutor.java

示例13: executeRequest

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
protected final CompletionStage<Optional<Order>> executeRequest(final OrderQuery baseQuery) {
    final OrderQuery request = OrderQueryHook.runHook(getHookRunner(), baseQuery);
    return getSphereClient().execute(request)
            .thenApply(PagedQueryResult::head)
            .thenApplyAsync(orderOpt -> {
                orderOpt.ifPresent(order -> OrderLoadedHook.runHook(getHookRunner(), order));
                return orderOpt;
            }, HttpExecution.defaultContext());
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:10,代码来源:AbstractSingleOrderQueryExecutor.java

示例14: executeRequest

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
protected final CompletionStage<Optional<ShoppingList>> executeRequest(final ShoppingListQuery baseQuery) {
    final ShoppingListQuery request = ShoppingListQueryHook.runHook(getHookRunner(), baseQuery);
    return getSphereClient().execute(request)
            .thenApply(PagedQueryResult::head)
            .thenApplyAsync(shoppingListOpt -> {
                shoppingListOpt.ifPresent(shoppingList -> ShoppingListLoadedHook.runHook(getHookRunner(), shoppingList));
                return shoppingListOpt;
            }, HttpExecution.defaultContext());
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:10,代码来源:AbstractSingleShoppingListQueryExecutor.java

示例15: resultTypeReference

import io.sphere.sdk.queries.PagedQueryResult; //导入依赖的package包/类
public static TypeReference<PagedQueryResult<CategoryWithProductCount>> resultTypeReference() {
    return new TypeReference<PagedQueryResult<CategoryWithProductCount>>() {
        @Override
        public String toString() {
            return "TypeReference<PagedQueryResult<CategoryWithProductCount>>";
        }
    };
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:9,代码来源:CategoriesWithProductCountQuery.java


注:本文中的io.sphere.sdk.queries.PagedQueryResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。