@Override public SELF has(Condition<? super ACTUAL> condition) { return super.has(condition); }
@Override public SELF has(Condition<? super ACTUAL> condition) { return super.has(condition); }
LithoAssertions.assertThat(layout).has(subComponentWith(c, textEquals("Doesn't match."))); } catch (final AssertionError assertionError) { LithoAssertions.assertThat(assertionError) LithoAssertions.assertThat(layout).has(subComponentWith(c, textEquals("Doesn't match."))); } catch (final AssertionError assertionError) { LithoAssertions.assertThat(assertionError.getMessage())
/** * Assert that the session has properties. * * @return the assertion for chaining. */ public MailSessionAssertions hasProperties() { Objects.instance().assertNotNull(info, actual); assertThat(session).has(new Condition<Session>() { @Override public boolean matches(Session value) { return value.getProperties() != null; } }); return this; }
/** * Assert that the session has specific property. * * @param property the property to assert. * @return the assertion for chaining. */ public MailSessionAssertions hasProperty(final String property) { Objects.instance().assertNotNull(info, actual); assertThat(session).has(new Condition<Session>() { @Override public boolean matches(Session value) { return value.getProperty(property) != null; } }); return this; }
@Test public void importCustomLineItemState() throws Exception { withStandardStates(client(), (State initialState, State nextState) -> withOrderOfCustomLineItems(client(), order -> { final CustomLineItem customLineItem = order.getCustomLineItems().get(0); assertThat(customLineItem).has(state(initialState)).has(not(state(nextState))); final Set<ItemState> itemStates = asSet(ItemState.of(nextState, 1L), ItemState.of(initialState, customLineItem.getQuantity() - 1)); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, ImportCustomLineItemState.of(customLineItem, itemStates))); assertThat(updatedOrder.getCustomLineItems().get(0)).has(itemStates(itemStates)); }) ); }
@Test public void importLineItemState() throws Exception { withStandardStates(client(), (State initialState, State nextState) -> withOrder(client(), order -> { final LineItem lineItem = order.getLineItems().get(0); assertThat(lineItem).has(state(initialState)).has(not(state(nextState))); final Set<ItemState> itemStates = asSet(ItemState.of(nextState, 1L), ItemState.of(initialState, lineItem.getQuantity() - 1)); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, ImportLineItemState.of(lineItem, itemStates))); assertThat(updatedOrder.getLineItems().get(0)).has(itemStates(itemStates)); //reference expansion final OrderByIdGet orderByIdGet = OrderByIdGet.of(order).withExpansionPaths(m -> m.lineItems().state().state()); final Order loadedOrder = client().executeBlocking(orderByIdGet); final Reference<State> state = new LinkedList<>(loadedOrder.getLineItems().get(0).getState()).getFirst().getState(); assertThat(state.getObj()).isNotNull(); return updatedOrder; }) ); }
@Test public void selectAPriceByCurrencyInProductProjectionQuery() { final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20)); withProductOfPrices(prices, product -> { final ProductProjectionQuery request = ProductProjectionQuery.ofStaged() .withPredicates(m -> m.id().is(product.getId()))//to limit the test scope .withPriceSelection(PriceSelection.of(EUR));//price selection config final PagedQueryResult<ProductProjection> result = client().executeBlocking(request); assertThat(result.getCount()).isEqualTo(1); final ProductVariant masterVariant = result.getResults().get(0).getMasterVariant(); assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30))); }); }
@Test public void execution() { withUpdatableChannelOfRole(client(), ChannelRole.PRIMARY, channel -> { final String key = channel.getKey(); final PagedQueryResult<Channel> pagedQueryResult = client().executeBlocking(ChannelQuery.of().byKey(key)); assertThat(pagedQueryResult).has(onlyTheResult(channel)); return channel; }); }
@Test public void selectAPriceByCurrencyInProductQuery() { final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20)); withProductOfPrices(prices, product -> { final ProductQuery request = ProductQuery.of() .withPredicates(m -> m.id().is(product.getId()))//to limit the test scope .withPriceSelection(PriceSelection.of(EUR));//price selection config final PagedQueryResult<Product> result = client().executeBlocking(request); assertThat(result.getCount()).isEqualTo(1); final ProductVariant masterVariant = result.getResults().get(0).getMasterData().getStaged().getMasterVariant(); assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30))); }); }
@Test public void selectAPriceByCurrencyInProductProjectionByIdGet() { final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20)); withProductOfPrices(prices, product -> { final ProductProjectionByIdGet request = ProductProjectionByIdGet.ofStaged(product) .withPriceSelection(PriceSelection.of(EUR));//price selection config final ProductProjection result = client().executeBlocking(request); final ProductVariant masterVariant = result.getMasterVariant(); assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30))); }); }
@Test public void selectAPriceByCurrency() { final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20)); withProductOfPrices(prices, product -> { final ProductProjectionSearch searchRequest = ProductProjectionSearch.ofStaged() .withQueryFilters(m -> m.id().is(product.getId()))//to limit the test scope .withPriceSelection(PriceSelection.of(EUR));//price selection config assertEventually(() -> { final PagedSearchResult<ProductProjection> result = client().executeBlocking(searchRequest); assertThat(result.getCount()).isEqualTo(1); final ProductVariant masterVariant = result.getResults().get(0).getMasterVariant(); assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30))); }); }); }
@Test public void selectAPriceByCurrencyInProductProjectionByKeyGet() { final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20)); withProductOfPrices(prices, product -> { final ProductProjection productProjection = client().executeBlocking(ProductProjectionByKeyGet.ofStaged(product.getKey()).withPriceSelection(PriceSelection.of(EUR))); final ProductVariant masterVariant = productProjection.getMasterVariant(); assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30))); }); }
@Test public void selectAPriceByCurrencyInProductByIdGet() { final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20)); withProductOfPrices(prices, product -> { final ProductByIdGet request = ProductByIdGet.of(product) .withPriceSelection(PriceSelection.of(EUR));//price selection config final Product result = client().executeBlocking(request); final ProductVariant masterVariant = result.getMasterData().getStaged().getMasterVariant(); assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30))); }); }
@Test public void selectAPriceByCurrencyInProductUpdateCommand() { ProductFixtures.withProduct(client(), product -> { final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20)); final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetPrices.of(1, prices)) .withPriceSelection(PriceSelection.of(EUR)); final Product updatedProduct = client().executeBlocking(cmd); final ProductVariant masterVariant = updatedProduct.getMasterData().getStaged().getMasterVariant(); assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30))); }); }
@Test public void selectAPriceByCurrencyInProductByKeyGet() { final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20)); withProductOfPrices(prices, product -> { final Product loadedProduct = client().executeBlocking(ProductByKeyGet.of(product.getKey()).withPriceSelection(PriceSelection.of(EUR))); final ProductVariant masterVariant = loadedProduct.getMasterData().getStaged().getMasterVariant(); assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30))); }); }
@Test public void isInSubtree() { final List<String> categoryIds1 = getCategoryIds("B-1", "C-2-2"); final List<String> categoryIds2 = getCategoryIds("B-1-2", "C-1-3"); final List<String> categoryIds3 = getCategoryIds("B-3", "C"); withProductInCategories(client(), categoryIds1, (Product product1) -> { withProductInCategories(client(), categoryIds2, (Product product2) -> { withProductInCategories(client(), categoryIds3, (Product product3) -> { assertEventually(() -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .withQueryFilters(m -> { final String categoryId = getCategoryIds("B-1").get(0); return m.categories().id().isInSubtree(categoryId); }) .plusQueryFilters(m -> m.id().isIn(asList(product1.getId(), product2.getId(), product3.getId()))); assertThat(client().executeBlocking(request)).has(onlyProducts(product1, product2)); }); }); }); }); }
@Test public void containsAll() { final List<String> categoryIds1 = getCategoryIds("A", "B-1", "C-2-2"); final List<String> categoryIds2 = getCategoryIds("A", "B-1"); final List<String> categoryIds3 = getCategoryIds("A", "B", "C"); withProductInCategories(client(), categoryIds1, (Product product1) -> { withProductInCategories(client(), categoryIds2, (Product product2) -> { withProductInCategories(client(), categoryIds3, (Product product3) -> { assertEventually(() -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .withQueryFilters(m -> m.categories().id().containsAll(categoryIds1)) .plusQueryFilters(m -> m.id().isIn(asList(product1.getId(), product2.getId(), product3.getId()))); assertThat(client().executeBlocking(request)).has(onlyProducts(product1)); }); }); }); }); }
@Test public void containsAny() { final List<String> categoryIds1 = getCategoryIds("A", "B-1", "C-2-2"); final List<String> categoryIds2 = getCategoryIds("A", "B-1"); final List<String> categoryIds3 = getCategoryIds("A", "B", "C"); withProductInCategories(client(), categoryIds1, (Product product1) -> { withProductInCategories(client(), categoryIds2, (Product product2) -> { withProductInCategories(client(), categoryIds3, (Product product3) -> { assertEventually(() -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .withQueryFilters(m -> m.categories().id().containsAny(categoryIds1)) .plusQueryFilters(m -> m.id().isIn(asList(product1.getId(), product2.getId(), product3.getId()))); assertThat(client().executeBlocking(request)).has(onlyProducts(product1, product2, product3)); }); }); }); }); }
@Test public void containsAnyIncludingSubtrees() { final List<String> categoryIds1 = getCategoryIds("A", "B-1", "C-2-2"); final List<String> categoryIds2 = getCategoryIds("A", "B-1"); final List<String> categoryIds3 = getCategoryIds("A", "B", "C"); withProductInCategories(client(), categoryIds1, (Product product1) -> { withProductInCategories(client(), categoryIds2, (Product product2) -> { withProductInCategories(client(), categoryIds3, (Product product3) -> { assertEventually(() -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .withQueryFilters(m -> m.categories().id().containsAnyIncludingSubtrees(getCategoryIds("C-2"))) .plusQueryFilters(m -> m.id().isIn(asList(product1.getId(), product2.getId(), product3.getId()))); assertThat(client().executeBlocking(request)).has(onlyProducts(product1)); }); }); }); }); }