nus-yam/ex-repair huggingface dataset:
Program: 130844
Project: 130844
Buggy source:
@Test public void expandLineItemsDiscount() throws Exception {
  final RelativeCartDiscountValue relativeCartDiscountValue=RelativeCartDiscountValue.of(15000);
  withDiscountedLineItem(client(),relativeCartDiscountValue,(cart) -> {
    final CartQuery query=CartQuery.of().withPredicates(m -> m.id().is(cart.getId())).withExpansionPaths(m -> m.lineItems().discountedPricePerQuantity().discountedPrice().includedDiscounts().discount());
    assertEventually(() -> {
      final Cart loadedCart=client().executeBlocking(query).head().get();
      final Reference<CartDiscount> cartDiscountReference=loadedCart.getLineItems().get(0).getDiscountedPricePerQuantity().get(0).getDiscountedPrice().getIncludedDiscounts().get(0).getDiscount();
      assertThat(cartDiscountReference.getObj()).isNotNull();
      final CartDiscount lineItemDiscount=cartDiscountReference.getObj();
      assertThat(lineItemDiscount).isNotNull();
      final CartDiscountValue customLineItemDiscountValue=lineItemDiscount.getValue();
      assertThat(customLineItemDiscountValue).isEqualTo(relativeCartDiscountValue);
    }
);
  }
);
}

Fixed version (ground truth):
@Test public void expandLineItemsDiscount() throws Exception {
  final RelativeCartDiscountValue relativeCartDiscountValue=RelativeCartDiscountValue.of(15000);
  withCartHavingCartDiscountedLineItem(client(),relativeCartDiscountValue,(cart) -> {
    final CartQuery query=CartQuery.of().withPredicates(m -> m.id().is(cart.getId())).withExpansionPaths(m -> m.lineItems().discountedPricePerQuantity().discountedPrice().includedDiscounts().discount());
    assertEventually(() -> {
      final Cart loadedCart=client().executeBlocking(query).head().get();
      final Reference<CartDiscount> cartDiscountReference=loadedCart.getLineItems().get(0).getDiscountedPricePerQuantity().get(0).getDiscountedPrice().getIncludedDiscounts().get(0).getDiscount();
      assertThat(cartDiscountReference.getObj()).isNotNull();
      final CartDiscount lineItemDiscount=cartDiscountReference.getObj();
      final CartDiscountValue customLineItemDiscountValue=lineItemDiscount.getValue();
      assertThat(customLineItemDiscountValue).isEqualTo(relativeCartDiscountValue);
    }
);
  }
);
}
Program: 130845
Project: 130845
Buggy source:
@Test public void expandCustomLineItemsDiscount() throws Exception {
  final RelativeCartDiscountValue relativeCartDiscountValue=RelativeCartDiscountValue.of(10000);
  withDiscountedCustomLineItem(client(),relativeCartDiscountValue,(cart) -> {
    final CartQuery query=CartQuery.of().withPredicates(m -> m.id().is(cart.getId())).withExpansionPaths(m -> m.customLineItems().discountedPricePerQuantity().discountedPrice().includedDiscounts().discount());
    assertEventually(() -> {
      final Cart loadedCart=client().executeBlocking(query).head().get();
      final Reference<CartDiscount> cartDiscountReference=loadedCart.getCustomLineItems().get(0).getDiscountedPricePerQuantity().get(0).getDiscountedPrice().getIncludedDiscounts().get(0).getDiscount();
      assertThat(cartDiscountReference.getObj()).isNotNull();
      final CartDiscount customLineItemDiscount=cartDiscountReference.getObj();
      assertThat(customLineItemDiscount).isNotNull();
      final CartDiscountValue customLineItemDiscountValue=customLineItemDiscount.getValue();
      assertThat(customLineItemDiscountValue).isEqualTo(relativeCartDiscountValue);
    }
);
  }
);
}

Fixed version (ground truth):
@Test public void expandCustomLineItemsDiscount() throws Exception {
  final RelativeCartDiscountValue relativeCartDiscountValue=RelativeCartDiscountValue.of(10000);
  withCartHavingDiscountedCustomLineItem(client(),relativeCartDiscountValue,(cart) -> {
    final CartQuery query=CartQuery.of().withPredicates(m -> m.id().is(cart.getId())).withExpansionPaths(m -> m.customLineItems().discountedPricePerQuantity().discountedPrice().includedDiscounts().discount());
    assertEventually(() -> {
      final Cart loadedCart=client().executeBlocking(query).head().get();
      final Reference<CartDiscount> cartDiscountReference=loadedCart.getCustomLineItems().get(0).getDiscountedPricePerQuantity().get(0).getDiscountedPrice().getIncludedDiscounts().get(0).getDiscount();
      assertThat(cartDiscountReference.getObj()).isNotNull();
      final CartDiscount customLineItemDiscount=cartDiscountReference.getObj();
      final CartDiscountValue customLineItemDiscountValue=customLineItemDiscount.getValue();
      assertThat(customLineItemDiscountValue).isEqualTo(relativeCartDiscountValue);
    }
);
  }
);
}
Program: 130846
Project: 130846
Buggy source:
public static void withCartHavingDiscountedCustomLineItem(final BlockingSphereClient client,final RelativeCartDiscountValue relativeCartDiscountValue,final Consumer<Cart> consumer){
  withTaxedProduct(client,product -> {
    withCustomerAndFilledCart(client,(customer,cart) -> {
      CartDiscountFixtures.withCartDiscount(client,builder -> builder.cartPredicate(CartDiscountPredicate.of("String_Node_Str" + customer.getId() + "String_Node_Str")).value(relativeCartDiscountValue).target(CustomLineItemsTarget.of("String_Node_Str")),cartDiscount -> {
        assertThat(cart.getCustomLineItems()).hasSize(0);
        final MonetaryAmount money=MoneyImpl.of("String_Node_Str",EUR);
        final String slug="String_Node_Str";
        final LocalizedString name=en("String_Node_Str");
        final CustomLineItemDraft item=CustomLineItemDraft.of(name,slug,money,product.getTaxCategory(),5L,null);
        final AddCustomLineItem addCustomLineItemAction=AddCustomLineItem.of(item);
        final Cart updatedCart=client.executeBlocking(CartUpdateCommand.of(cart,asList(addCustomLineItemAction)));
        consumer.accept(updatedCart);
      }
);
      final Cart cartToDelete=client.executeBlocking(CartByIdGet.of(cart));
      client.executeBlocking(CartDeleteCommand.of(cartToDelete));
    }
);
  }
);
}

Fixed version (ground truth):
public static void withCartHavingDiscountedCustomLineItem(final BlockingSphereClient client,final RelativeCartDiscountValue relativeCartDiscountValue,final UnaryOperator<Cart> op){
  withTaxedProduct(client,product -> {
    withCustomer(client,(customer) -> {
      CartDiscountFixtures.withCartDiscount(client,builder -> builder.cartPredicate(CartDiscountPredicate.of("String_Node_Str" + customer.getId() + "String_Node_Str")).value(relativeCartDiscountValue).target(CustomLineItemsTarget.of("String_Node_Str")),cartDiscount -> {
        withCart(client,(cart) -> {
          assertThat(cart.getCustomLineItems()).hasSize(0);
          final MonetaryAmount money=MoneyImpl.of("String_Node_Str",EUR);
          final String slug="String_Node_Str";
          final LocalizedString name=en("String_Node_Str");
          final CustomLineItemDraft item=CustomLineItemDraft.of(name,slug,money,product.getTaxCategory(),5L,null);
          final AddCustomLineItem addCustomLineItemAction=AddCustomLineItem.of(item);
          final List<UpdateAction<Cart>> updateActions=asList(addCustomLineItemAction,SetCustomerId.of(customer.getId()),Recalculate.of().withUpdateProductData(true));
          final Cart updatedCart=client.executeBlocking(CartUpdateCommand.of(cart,updateActions));
          final Cart cartToDelete=op.apply(updatedCart);
          return cartToDelete;
        }
);
      }
);
    }
);
  }
);
}
Program: 130847
Project: 130847
Buggy source:
public static void withCartHavingCartDiscountedLineItem(final BlockingSphereClient client,final RelativeCartDiscountValue relativeCartDiscountValue,final Consumer<Cart> consumer){
  withTaxedProduct(client,product -> {
    withCart(client,(cart) -> {
      withCustomer(client,(customer) -> {
        CartDiscountFixtures.withCartDiscount(client,builder -> builder.cartPredicate(CartDiscountPredicate.of("String_Node_Str" + customer.getId() + "String_Node_Str")).value(relativeCartDiscountValue).target(LineItemsTarget.of("String_Node_Str" + product.getId() + "String_Node_Str")),cartDiscount -> {
          assertThat(cart.getLineItems()).hasSize(0);
          final long quantity=3;
          final String productId=product.getId();
          final AddLineItem addLineItemAction=AddLineItem.of(productId,1,quantity);
          final List<UpdateAction<Cart>> updateActions=asList(addLineItemAction,SetCustomerId.of(customer.getId()),Recalculate.of().withUpdateProductData(true));
          final Cart updatedCart=client.executeBlocking(CartUpdateCommand.of(cart,updateActions));
          consumer.accept(updatedCart);
        }
);
      }
);
      final Cart cartToDelete=client.executeBlocking(CartByIdGet.of(cart));
      return cartToDelete;
    }
);
  }
);
}

Fixed version (ground truth):
public static void withCartHavingCartDiscountedLineItem(final BlockingSphereClient client,final RelativeCartDiscountValue relativeCartDiscountValue,final UnaryOperator<Cart> op){
  withTaxedProduct(client,product -> {
    withCustomer(client,(customer) -> {
      CartDiscountFixtures.withCartDiscount(client,builder -> builder.cartPredicate(CartDiscountPredicate.of("String_Node_Str" + customer.getId() + "String_Node_Str")).value(relativeCartDiscountValue).target(LineItemsTarget.of("String_Node_Str" + product.getId() + "String_Node_Str")),cartDiscount -> {
        withCart(client,(cart) -> {
          assertThat(cart.getLineItems()).hasSize(0);
          final long quantity=3;
          final String productId=product.getId();
          final AddLineItem addLineItemAction=AddLineItem.of(productId,1,quantity);
          final List<UpdateAction<Cart>> updateActions=asList(addLineItemAction,SetCustomerId.of(customer.getId()),Recalculate.of().withUpdateProductData(true));
          final Cart updatedCart=client.executeBlocking(CartUpdateCommand.of(cart,updateActions));
          final Cart cartToDelete=op.apply(updatedCart);
          return cartToDelete;
        }
);
      }
);
    }
);
  }
);
}
Program: 130848
Project: 130848
Buggy source:
@Test public void expandLineItemsDiscount() throws Exception {
  final RelativeCartDiscountValue relativeCartDiscountValue=RelativeCartDiscountValue.of(15000);
  withCartHavingCartDiscountedLineItem(client(),relativeCartDiscountValue,(cart) -> {
    final CartQuery query=CartQuery.of().withPredicates(m -> m.id().is(cart.getId())).withExpansionPaths(m -> m.lineItems().discountedPricePerQuantity().discountedPrice().includedDiscounts().discount());
    assertEventually(() -> {
      final Cart loadedCart=client().executeBlocking(query).head().get();
      final Reference<CartDiscount> cartDiscountReference=loadedCart.getLineItems().get(0).getDiscountedPricePerQuantity().get(0).getDiscountedPrice().getIncludedDiscounts().get(0).getDiscount();
      assertThat(cartDiscountReference.getObj()).isNotNull();
      final CartDiscount lineItemDiscount=cartDiscountReference.getObj();
      final CartDiscountValue customLineItemDiscountValue=lineItemDiscount.getValue();
      assertThat(customLineItemDiscountValue).isEqualTo(relativeCartDiscountValue);
    }
);
  }
);
}

Fixed version (ground truth):
@Test public void expandLineItemsDiscount() throws Exception {
  final RelativeCartDiscountValue relativeCartDiscountValue=RelativeCartDiscountValue.of(15000);
  withCartHavingCartDiscountedLineItem(client(),relativeCartDiscountValue,(cart) -> {
    final CartQuery query=CartQuery.of().withPredicates(m -> m.id().is(cart.getId())).withExpansionPaths(m -> m.lineItems().discountedPricePerQuantity().discountedPrice().includedDiscounts().discount());
    final Cart loadedCart=client().executeBlocking(query).head().get();
    final Reference<CartDiscount> cartDiscountReference=loadedCart.getLineItems().get(0).getDiscountedPricePerQuantity().get(0).getDiscountedPrice().getIncludedDiscounts().get(0).getDiscount();
    assertThat(cartDiscountReference.getObj()).isNotNull();
    final CartDiscount lineItemDiscount=cartDiscountReference.getObj();
    final CartDiscountValue customLineItemDiscountValue=lineItemDiscount.getValue();
    assertThat(customLineItemDiscountValue).isEqualTo(relativeCartDiscountValue);
    return loadedCart;
  }
);
}
Program: 130849
Project: 130849
Buggy source:
@Test public void expandCustomLineItemsDiscount() throws Exception {
  final RelativeCartDiscountValue relativeCartDiscountValue=RelativeCartDiscountValue.of(10000);
  withCartHavingDiscountedCustomLineItem(client(),relativeCartDiscountValue,(cart) -> {
    final CartQuery query=CartQuery.of().withPredicates(m -> m.id().is(cart.getId())).withExpansionPaths(m -> m.customLineItems().discountedPricePerQuantity().discountedPrice().includedDiscounts().discount());
    assertEventually(() -> {
      final Cart loadedCart=client().executeBlocking(query).head().get();
      final Reference<CartDiscount> cartDiscountReference=loadedCart.getCustomLineItems().get(0).getDiscountedPricePerQuantity().get(0).getDiscountedPrice().getIncludedDiscounts().get(0).getDiscount();
      assertThat(cartDiscountReference.getObj()).isNotNull();
      final CartDiscount customLineItemDiscount=cartDiscountReference.getObj();
      final CartDiscountValue customLineItemDiscountValue=customLineItemDiscount.getValue();
      assertThat(customLineItemDiscountValue).isEqualTo(relativeCartDiscountValue);
    }
);
  }
);
}

Fixed version (ground truth):
@Test public void expandCustomLineItemsDiscount() throws Exception {
  final RelativeCartDiscountValue relativeCartDiscountValue=RelativeCartDiscountValue.of(10000);
  withCartHavingDiscountedCustomLineItem(client(),relativeCartDiscountValue,(cart) -> {
    final CartQuery query=CartQuery.of().withPredicates(m -> m.id().is(cart.getId())).withExpansionPaths(m -> m.customLineItems().discountedPricePerQuantity().discountedPrice().includedDiscounts().discount());
    final Cart loadedCart=client().executeBlocking(query).head().get();
    final Reference<CartDiscount> cartDiscountReference=loadedCart.getCustomLineItems().get(0).getDiscountedPricePerQuantity().get(0).getDiscountedPrice().getIncludedDiscounts().get(0).getDiscount();
    assertThat(cartDiscountReference.getObj()).isNotNull();
    final CartDiscount customLineItemDiscount=cartDiscountReference.getObj();
    final CartDiscountValue customLineItemDiscountValue=customLineItemDiscount.getValue();
    assertThat(customLineItemDiscountValue).isEqualTo(relativeCartDiscountValue);
    return loadedCart;
  }
);
}
Program: 130851
Project: 130851
Buggy source:
/** 
 * @param addressId Is the Id of the address to find.
 * @return Address or null
 */
@Nullable default Address getAddressById(final String addressId){
  return findAddressById(addressId).orElse(null);
}

Fixed version (ground truth):
/** 
 * Find the address in   {@link #getAddresses()} by the address id
 * @param addressId the Id string of the address to find
 * @return Address or null
 */
@Nullable default Address getAddressById(final String addressId){
  return findAddressById(addressId).orElse(null);
}
Program: 130852
Project: 130852
Buggy source:
public static SphereClient ofRetry(final SphereClient delegate){
  final int maxAttempts=5;
  final List<RetryRule> retryRules=singletonList(RetryRule.of(RetryPredicate.ofMatchingStatusCodes(BAD_GATEWAY_502,SERVICE_UNAVAILABLE_503,GATEWAY_TIMEOUT_504),unused -> RetryAction.ofScheduledRetry(maxAttempts,context -> Duration.ofSeconds(context.getAttempt() * 2))));
  return RetrySphereClientDecorator.of(delegate,retryRules);
}

Fixed version (ground truth):
public static SphereClient ofRetry(final SphereClient delegate){
  final int maxAttempts=5;
  final List<RetryRule> retryRules=singletonList(RetryRule.of(RetryPredicate.ofMatchingStatusCodes(BAD_GATEWAY_502,SERVICE_UNAVAILABLE_503,GATEWAY_TIMEOUT_504),RetryAction.ofScheduledRetry(maxAttempts,context -> Duration.ofSeconds(context.getAttempt() * 2))));
  return RetrySphereClientDecorator.of(delegate,retryRules);
}
Program: 130853
Project: 130853
Buggy source:
public static SphereClient ofRetry(final SphereClient delegate){
  final List<RetryRule> retryRules=singletonList(RetryRule.of(isDeleteAndNewVersionIsKnown(),c -> retryWithNewVersion()));
  return RetrySphereClientDecorator.of(delegate,retryRules);
}

Fixed version (ground truth):
public static SphereClient ofRetry(final SphereClient delegate){
  final List<RetryRule> retryRules=singletonList(RetryRule.of(isDeleteAndNewVersionIsKnown(),retryWithNewVersion()));
  return RetrySphereClientDecorator.of(delegate,retryRules);
}
Program: 130854
Project: 130854
Buggy source:
@Override public PaymentStatus build(){
  return new PaymentStatus(interfaceCode,interfaceText,state);
}

Fixed version (ground truth):
@Override public PaymentStatus build(){
  return new PaymentStatusImpl(interfaceCode,interfaceText,state);
}
Program: 130855
Project: 130855
Buggy source:
protected <E extends SphereEnumeration>SphereEnumerationOptionalQueryModel<T,E> enumerationQueryModel(final String pathSegment){
  return new SphereEnumerationQueryModelImpl<>(this,pathSegment);
}

Fixed version (ground truth):
protected <E extends SphereEnumeration>SphereEnumerationQueryModelImpl<T,E> enumerationQueryModel(final String pathSegment){
  return new SphereEnumerationQueryModelImpl<>(this,pathSegment);
}
Program: 130856
Project: 130856
Buggy source:
CategoryExpansionModel<ProductProjection> categories();

Fixed version (ground truth):
CategoryExpansionModel<T> categories();
Program: 130857
Project: 130857
Buggy source:
ProductVariantExpansionModel<ProductProjection> allVariants();

Fixed version (ground truth):
ProductVariantExpansionModel<T> allVariants();
Program: 130858
Project: 130858
Buggy source:
@Override public CategoryExpansionModel<ProductProjection> categories(){
  return CategoryExpansionModel.of(pathExpression(),"String_Node_Str");
}

Fixed version (ground truth):
@Override public CategoryExpansionModel<T> categories(){
  return CategoryExpansionModel.of(pathExpression(),"String_Node_Str");
}
Program: 130859
Project: 130859
Buggy source:
@Override public ProductVariantExpansionModel<ProductProjection> allVariants(){
  final List<String> parents=pathExpression();
  final List<String> currentPaths=asList(MASTER_VARIANT,VARIANTS);
  final List<String> paths;
  if (parents.isEmpty()) {
    paths=currentPaths;
  }
 else {
    paths=parents.stream().flatMap(p -> currentPaths.stream().map(c -> (isEmpty(p) ? "String_Node_Str" : p + "String_Node_Str") + c)).collect(Collectors.toList());
  }
  return new ProductVariantExpansionModelImpl<>(paths,null);
}

Fixed version (ground truth):
@Override public ProductVariantExpansionModel<T> allVariants(){
  final List<String> parents=pathExpression();
  final List<String> currentPaths=asList(MASTER_VARIANT,VARIANTS);
  final List<String> paths;
  if (parents.isEmpty()) {
    paths=currentPaths;
  }
 else {
    paths=parents.stream().flatMap(p -> currentPaths.stream().map(c -> (isEmpty(p) ? "String_Node_Str" : p + "String_Node_Str") + c)).collect(Collectors.toList());
  }
  return new ProductVariantExpansionModelImpl<>(paths,null);
}
Program: 130860
Project: 130860
Buggy source:
@Test public void customerAlreadyRegistered(){
  withCustomer(client(),customer -> {
    final String email=customer.getEmail();
    final CustomerDraftDsl draft=CustomerDraftBuilder.of(email,"String_Node_Str").build();
    final CustomerCreateCommand cmd=CustomerCreateCommand.of(draft);
    final Throwable throwable=catchThrowable(() -> client().executeBlocking(cmd));
    assertThat(throwable).isInstanceOf(ErrorResponseException.class);
    final ErrorResponseException e=(ErrorResponseException)throwable;
    assertThat(e.getErrors().get(0).getCode()).isEqualTo(DuplicateFieldError.CODE);
    final DuplicateFieldError error=e.getErrors().get(0).as(DuplicateFieldError.class);
    assertThat(error.getDuplicateValue()).isEqualTo(email);
    assertThat(error.getField()).isEqualTo("String_Node_Str");
  }
);
}

Fixed version (ground truth):
@Test public void customerAlreadyRegistered(){
  withCustomer(client(),customer -> {
    final String email=customer.getEmail();
    final CustomerDraftDsl draft=CustomerDraftBuilder.of(email,"String_Node_Str").build();
    final CustomerCreateCommand cmd=CustomerCreateCommand.of(draft);
    final Throwable throwable=catchThrowable(() -> client().executeBlocking(cmd));
    assertThat(throwable).isInstanceOf(ErrorResponseException.class);
    final ErrorResponseException e=(ErrorResponseException)throwable;
    assertThat(e.getErrors().get(0).getCode()).isEqualTo(DuplicateFieldError.CODE);
    final DuplicateFieldError error=e.getErrors().get(0).as(DuplicateFieldError.class);
    assertThat(error.getDuplicateValue().toLowerCase()).isEqualTo(email);
    assertThat(error.getField()).isEqualTo("String_Node_Str");
  }
);
}
Program: 130861
Project: 130861
Buggy source:
@Test public void toStringDoesNotContainPassword(){
  final CustomerPasswordResetCommand cmd=CustomerPasswordResetCommand.of(Versioned.of("String_Node_Str",3L),"String_Node_Str","String_Node_Str");
  assertThat(cmd.toString()).doesNotContain("String_Node_Str");
}

Fixed version (ground truth):
@Test public void toStringDoesNotContainPassword(){
  final CustomerPasswordResetCommand cmd=CustomerPasswordResetCommand.ofTokenAndPassword("String_Node_Str","String_Node_Str");
  assertThat(cmd.toString()).doesNotContain("String_Node_Str");
}
Program: 130862
Project: 130862
Buggy source:
@Override public RootJsonQueryModel<T> value(){
  return new CustomObjectValueRootJsonQueryModelImpl(null,"String_Node_Str");
}

Fixed version (ground truth):
@Override public RootJsonQueryModel<T> value(){
  return new CustomObjectValueRootJsonQueryModelImpl<>(null,"String_Node_Str");
}
Program: 130863
Project: 130863
Buggy source:
/** 
 * Creates a blocking client with a configured default timeout for blocking requests. The asynchronous calls won't have a timeout by default.
 * @param delegate underlying sphere client which may be initialized with the {@link SphereClientFactory}.
 * @param defaultTimeout the default maximum duration to wait (to block the thread) which should be greater than the timeout of the underlying HTTP client
 * @return wrapped client which can perform blocking calls.
 */
static BlockingSphereClient of(final SphereClient delegate,final Duration defaultTimeout){
  return of(delegate,defaultTimeout.get(ChronoUnit.NANOS),TimeUnit.NANOSECONDS);
}

Fixed version (ground truth):
/** 
 * Creates a blocking client with a configured default timeout for blocking requests. The asynchronous calls won't have a timeout by default.
 * @param delegate underlying sphere client which may be initialized with the {@link SphereClientFactory}.
 * @param defaultTimeout the default maximum duration to wait (to block the thread) which should be greater than the timeout of the underlying HTTP client
 * @return wrapped client which can perform blocking calls.
 */
static BlockingSphereClient of(final SphereClient delegate,final Duration defaultTimeout){
  return of(delegate,defaultTimeout.toMillis(),TimeUnit.MILLISECONDS);
}
Program: 130864
Project: 130864
Buggy source:
@Override public <T>T executeBlocking(final SphereRequest<T> sphereRequest,final Duration duration){
  return executeBlocking(sphereRequest,duration.get(ChronoUnit.NANOS),TimeUnit.NANOSECONDS);
}

Fixed version (ground truth):
@Override public <T>T executeBlocking(final SphereRequest<T> sphereRequest,final Duration duration){
  return executeBlocking(sphereRequest,duration.toMillis(),TimeUnit.MILLISECONDS);
}
Program: 130865
Project: 130865
Buggy source:
public static SphereClient of(final SphereClient delegate,final Duration duration){
  return of(delegate,duration.get(ChronoUnit.NANOS),TimeUnit.NANOSECONDS);
}

Fixed version (ground truth):
public static SphereClient of(final SphereClient delegate,final Duration duration){
  return of(delegate,duration.toMillis(),TimeUnit.MILLISECONDS);
}
Program: 130866
Project: 130866
Buggy source:
public static <S extends CompletionStage<T>,T>Collector<S,?,List<T>> blockingWaitForEachCollector(final Duration duration){
  return blockingWaitForEachCollector(duration.get(ChronoUnit.NANOS),TimeUnit.NANOSECONDS);
}

Fixed version (ground truth):
public static <S extends CompletionStage<T>,T>Collector<S,?,List<T>> blockingWaitForEachCollector(final Duration duration){
  return blockingWaitForEachCollector(duration.toMillis(),TimeUnit.MILLISECONDS);
}
Program: 130867
Project: 130867
Buggy source:
public ExpansionModelImpl(final List<String> parentExpressions,final String path){
  final List<String> nullSafeParentExpressions=parentExpressions == null ? Collections.singletonList("String_Node_Str") : parentExpressions;
  this.pathExpressions=!isEmpty(path) ? nullSafeParentExpressions.stream().map(p -> isEmpty(p) ? path : p + "String_Node_Str" + path).collect(Collectors.toList()) : nullSafeParentExpressions;
}

Fixed version (ground truth):
public ExpansionModelImpl(@Nullable final List<String> parentExpressions,@Nullable final String path){
  this(parentExpressions,path != null ? singletonList(path) : null);
}
Program: 130868
Project: 130868
Buggy source:
@Test public void execution() throws Exception {
  withFilledCart(client(),cart -> {
    final OrderFromCartCreateCommand createCommand=OrderFromCartCreateCommand.of(cart).plusExpansionPaths(m -> m.cart());
    final Order order=client().executeBlocking(createCommand);
    assertThat(order.getLineItems()).isEqualTo(cart.getLineItems());
    assertThat(order.getCustomLineItems()).isEqualTo(cart.getCustomLineItems());
    assertThat(order.getCart().getId()).isEqualTo(cart.getId());
    final Cart orderedCart=order.getCart().getObj();
    assertThat(orderedCart).isNotNull();
    assertThat(orderedCart.getId()).isEqualTo(cart.getId());
    assertThat(orderedCart.getCartState()).isEqualTo(CartState.ORDERED);
  }
);
}

Fixed version (ground truth):
@Test public void execution() throws Exception {
  withFilledCart(client(),cart -> {
    final OrderFromCartCreateCommand createCommand=OrderFromCartCreateCommand.of(cart).plusExpansionPaths(m -> m.cart());
    final Order order=client().executeBlocking(createCommand);
    assertThat(order.getLineItems()).isEqualTo(cart.getLineItems());
    assertThat(order.getCustomLineItems()).isEqualTo(cart.getCustomLineItems());
    assertThat(order.getCart().getId()).isEqualTo(cart.getId());
    assertThat(order.getCart()).is(expanded());
    final Cart orderedCart=order.getCart().getObj();
    assertThat(orderedCart).isNotNull();
    assertThat(orderedCart.getId()).isEqualTo(cart.getId());
    assertThat(orderedCart.getCartState()).isEqualTo(CartState.ORDERED);
  }
);
}
Program: 130869
Project: 130869
Buggy source:
public BadRequestException(){
  super(400);
}

Fixed version (ground truth):
public BadRequestException(final String message){
  super(message,400);
}
Program: 130870
Project: 130870
Buggy source:
ErrorResponseException(final Integer statusCode,final String message,final List<? extends SphereError> errors){
  this.statusCode=statusCode;
  this.message=message;
  this.errors=errors == null ? Collections.<SphereError>emptyList() : errors;
}

Fixed version (ground truth):
ErrorResponseException(final Integer statusCode,final String message,final List<? extends SphereError> errors){
  super(message);
  this.statusCode=statusCode;
  this.errors=errors == null ? Collections.<SphereError>emptyList() : errors;
}
Program: 130871
Project: 130871
Buggy source:
public static void withShippingMethodForGermany(final TestClient client,final Consumer<ShippingMethod> consumer){
  final Optional<Zone> zoneOptional=client.execute(ZoneQuery.of().byCountry(DE)).head();
  final Zone zone;
  if (zoneOptional.isPresent()) {
    zone=zoneOptional.get();
  }
 else {
    zone=client.execute(ZoneCreateCommand.of(ZoneDraft.of("String_Node_Str",asSet(Location.of(DE)))));
  }
  withUpdateableShippingMethod(client,shippingMethodWithOutZone -> {
    final ShippingMethod updated=client.execute(ShippingMethodUpdateCommand.of(shippingMethodWithOutZone,AddZone.of(zone)));
    return updated;
  }
);
}

Fixed version (ground truth):
public static void withShippingMethodForGermany(final TestClient client,final Consumer<ShippingMethod> consumer){
  final Optional<Zone> zoneOptional=client.execute(ZoneQuery.of().byCountry(DE)).head();
  final Zone zone;
  if (zoneOptional.isPresent()) {
    zone=zoneOptional.get();
  }
 else {
    zone=client.execute(ZoneCreateCommand.of(ZoneDraft.of("String_Node_Str",asSet(Location.of(DE)))));
  }
  withUpdateableShippingMethod(client,shippingMethodWithOutZone -> {
    final ShippingMethod updated=client.execute(ShippingMethodUpdateCommand.of(shippingMethodWithOutZone,asList(AddZone.of(zone),AddShippingRate.of(ShippingRate.of(EURO_1),zone))));
    consumer.accept(updated);
    return updated;
  }
);
}
Program: 130872
Project: 130872
Buggy source:
/** 
 * Encodes urls with US-ASCII.
 * @param s String which should be URL encoded
 * @return url encoded s
 */
public static String urlEncode(final String s){
  final String encoding="String_Node_Str";
  try {
    return URLEncoder.encode(s,encoding);
  }
 catch (  final UnsupportedEncodingException e) {
    throw new RuntimeException(String.format("String_Node_Str",s,encoding));
  }
}

Fixed version (ground truth):
/** 
 * Encodes urls with UTF-8.
 * @param s String which should be URL encoded
 * @return url encoded s
 */
public static String urlEncode(final String s){
  final String encoding="String_Node_Str";
  try {
    return URLEncoder.encode(s,encoding);
  }
 catch (  final UnsupportedEncodingException e) {
    throw new CompletionException(String.format("String_Node_Str",s,encoding),e);
  }
}
Program: 130874
Project: 130874
Buggy source:
public static <T>T deserialize(final HttpResponse httpResponse,final JavaType javaType){
  return SphereJsonUtils.readObject(Optional.ofNullable(httpResponse.getResponseBody()).orElseThrow(() -> new JsonException(httpResponse)),javaType);
}

Fixed version (ground truth):
protected static <T>T deserialize(final HttpResponse httpResponse,final JavaType javaType){
  return SphereJsonUtils.readObject(Optional.ofNullable(httpResponse.getResponseBody()).orElseThrow(() -> new JsonException(httpResponse)),javaType);
}
Program: 130875
Project: 130875
Buggy source:
@Test public void queryTaxedPrice() throws Exception {
  withFilledCart(client(),cart -> {
    final Cart loadedCart=execute(CartQuery.of().withSort(m -> m.createdAt().sort().desc()).withLimit(1).withPredicates(m -> m.taxedPrice().isPresent().and(m.taxedPrice().totalNet().centAmount().is(centAmountOf(cart.getTaxedPrice().getTotalNet()))).and(m.taxedPrice().totalGross().centAmount().is(centAmountOf(cart.getTaxedPrice().getTotalGross()))))).head().get();
    assertThat(loadedCart.getId()).isEqualTo(cart.getId());
  }
);
}

Fixed version (ground truth):
@Test public void queryTaxedPrice() throws Exception {
  withFilledCart(client(),cart -> {
    final Cart loadedCart=execute(CartQuery.of().withSort(m -> m.createdAt().sort().desc()).withLimit(1).withPredicates(m -> m.taxedPrice().isPresent().and(m.taxedPrice().totalNet().centAmount().is(centAmountOf(cart.getTaxedPrice().getTotalNet()))).and(m.taxedPrice().totalGross().centAmount().is(centAmountOf(cart.getTaxedPrice().getTotalGross())).and(m.id().is(cart.getId()))))).head().get();
    assertThat(loadedCart.getId()).isEqualTo(cart.getId());
  }
);
}
Program: 130876
Project: 130876
Buggy source:
@Test public void queryForAllMessages() throws Exception {
  withOrderAndReturnInfo(client(),((order,returnInfo) -> {
    final MessageQuery query=MessageQuery.of().withPredicates(m -> m.type().is("String_Node_Str")).withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1);
    final Message message=execute(query).head().get();
    assertThat(message.getResource().getObj()).isNotNull();
    assertThat(message.getResource()).isEqualTo(order.toReference());
    assertThat(message.getResource().getId()).isEqualTo(order.getId());
  }
));
}

Fixed version (ground truth):
@Test public void queryForAllMessages() throws Exception {
  withOrderAndReturnInfo(client(),((order,returnInfo) -> {
    final MessageQuery query=MessageQuery.of().withPredicates(m -> m.type().is("String_Node_Str").and(m.resource().is(order))).withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1);
    final Message message=execute(query).head().get();
    assertThat(message.getResource().getObj()).isNotNull();
    assertThat(message.getResource()).isEqualTo(order.toReference());
    assertThat(message.getResource().getId()).isEqualTo(order.getId());
  }
));
}
Program: 130877
Project: 130877
Buggy source:
@Test public void messageGetPayload() throws Exception {
  withOrderAndReturnInfo(client(),((order,returnInfo) -> {
    final Query<Message> query=MessageQuery.of().withPredicates(m -> m.type().is(ReturnInfoAddedMessage.MESSAGE_HINT)).withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1);
    final PagedQueryResult<Message> pagedQueryResult=execute(query);
    final Message message=pagedQueryResult.head().get();
    final String fetchedItemId=message.getPayload().get("String_Node_Str").get("String_Node_Str").get(0).get("String_Node_Str").asText();
    final String actualItemId=returnInfo.getItems().get(0).getId();
    assertThat(fetchedItemId).isEqualTo(actualItemId).isNotNull();
  }
));
}

Fixed version (ground truth):
@Test public void messageGetPayload() throws Exception {
  withOrderAndReturnInfo(client(),((order,returnInfo) -> {
    final Query<Message> query=MessageQuery.of().withPredicates(m -> m.type().is(ReturnInfoAddedMessage.MESSAGE_HINT).and(m.resource().is(order))).withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1);
    final PagedQueryResult<Message> pagedQueryResult=execute(query);
    final Message message=pagedQueryResult.head().get();
    final String fetchedItemId=message.getPayload().get("String_Node_Str").get("String_Node_Str").get(0).get("String_Node_Str").asText();
    final String actualItemId=returnInfo.getItems().get(0).getId();
    assertThat(fetchedItemId).isEqualTo(actualItemId).isNotNull();
  }
));
}
Program: 130878
Project: 130878
Buggy source:
@Test public void queryForASpecificMessage() throws Exception {
  withOrderAndReturnInfo(client(),((order,returnInfo) -> {
    final Query<ReturnInfoAddedMessage> query=MessageQuery.of().withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1).forMessageType(ReturnInfoAddedMessage.MESSAGE_HINT);
    final PagedQueryResult<ReturnInfoAddedMessage> pagedQueryResult=execute(query);
    final ReturnInfoAddedMessage message=pagedQueryResult.head().get();
    assertThat(message.getReturnInfo()).isEqualTo(returnInfo);
    assertThat(message.getResource().getObj()).isNotNull();
    assertThat(message.getResource().getId()).isEqualTo(order.getId());
  }
));
}

Fixed version (ground truth):
@Test public void queryForASpecificMessage() throws Exception {
  withOrderAndReturnInfo(client(),((order,returnInfo) -> {
    final Query<ReturnInfoAddedMessage> query=MessageQuery.of().withPredicates(m -> m.resource().is(order)).withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1).forMessageType(ReturnInfoAddedMessage.MESSAGE_HINT);
    final PagedQueryResult<ReturnInfoAddedMessage> pagedQueryResult=execute(query);
    final ReturnInfoAddedMessage message=pagedQueryResult.head().get();
    assertThat(message.getReturnInfo()).isEqualTo(returnInfo);
    assertThat(message.getResource().getObj()).isNotNull();
    assertThat(message.getResource().getId()).isEqualTo(order.getId());
  }
));
}
Program: 130879
Project: 130879
Buggy source:
private void assertOrderIsFound(final Function<Order,OrderQuery> p,final boolean shouldFind){
  withOrder(client(),order -> {
    final OrderQuery query=p.apply(order).withSort(QuerySort.of("String_Node_Str"));
    final String id=client().execute(query).head().orElseThrow(() -> new RuntimeException("String_Node_Str")).getId();
    if (shouldFind) {
      assertThat(id).isEqualTo(order.getId());
    }
 else {
      assertThat(id).isNotEqualTo(order.getId());
    }
  }
);
}

Fixed version (ground truth):
private void assertOrderIsFound(final Function<Order,OrderQuery> p,final boolean shouldFind){
  withOrder(client(),order -> {
    assertEventually(() -> {
      final OrderQuery query=p.apply(order).withSort(QuerySort.of("String_Node_Str"));
      final List<Order> results=client().execute(query).getResults();
      if (shouldFind) {
        assertThat(results).extracting("String_Node_Str").contains(order.getId());
      }
 else {
        assertThat(results).extracting("String_Node_Str").doesNotContain(order.getId());
      }
    }
);
  }
);
}
Program: 130880
Project: 130880
Buggy source:
@Test public void message(){
  ProductFixtures.withUpdateableProduct(client(),product -> {
    assertThat(product.getMasterData().isPublished()).isFalse();
    final Product publishedProduct=execute(ProductUpdateCommand.of(product,Publish.of()));
    final PagedQueryResult<ProductPublishedMessage> queryResult=execute(MessageQuery.of().withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1).forMessageType(ProductPublishedMessage.MESSAGE_HINT));
    final ProductPublishedMessage message=queryResult.head().get();
    assertThat(message.getResource().getId()).isEqualTo(product.getId());
    assertThat(message.getProductProjection().getMasterVariant()).isEqualTo(publishedProduct.getMasterData().getCurrent().getMasterVariant());
    assertThat(message.getResource().getObj().getMasterData().getCurrent().getSlug()).isEqualTo(message.getProductProjection().getSlug());
    return publishedProduct;
  }
);
}

Fixed version (ground truth):
@Test public void message(){
  ProductFixtures.withUpdateableProduct(client(),product -> {
    assertThat(product.getMasterData().isPublished()).isFalse();
    final Product publishedProduct=execute(ProductUpdateCommand.of(product,Publish.of()));
    final PagedQueryResult<ProductPublishedMessage> queryResult=execute(MessageQuery.of().withPredicates(m -> m.resource().is(product)).withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1).forMessageType(ProductPublishedMessage.MESSAGE_HINT));
    final ProductPublishedMessage message=queryResult.head().get();
    assertThat(message.getResource().getId()).isEqualTo(product.getId());
    assertThat(message.getProductProjection().getMasterVariant()).isEqualTo(publishedProduct.getMasterData().getCurrent().getMasterVariant());
    assertThat(message.getResource().getObj().getMasterData().getCurrent().getSlug()).isEqualTo(message.getProductProjection().getSlug());
    return publishedProduct;
  }
);
}
Program: 130881
Project: 130881
Buggy source:
@Test public void message(){
  ProductFixtures.withUpdateableProduct(client(),product -> {
    assertThat(product.getMasterData().isPublished()).isFalse();
    final Product unpublishedProduct=execute(ProductUpdateCommand.of(product,asList(Publish.of(),Unpublish.of())));
    final PagedQueryResult<ProductUnpublishedMessage> queryResult=execute(MessageQuery.of().withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1).forMessageType(ProductUnpublishedMessage.MESSAGE_HINT));
    final ProductUnpublishedMessage message=queryResult.head().get();
    assertThat(message.getResource().getId()).isEqualTo(product.getId());
    assertThat(message.getResource().getObj().getMasterData().isPublished()).isFalse();
    return unpublishedProduct;
  }
);
}

Fixed version (ground truth):
@Test public void message(){
  ProductFixtures.withUpdateableProduct(client(),product -> {
    assertThat(product.getMasterData().isPublished()).isFalse();
    final Product unpublishedProduct=execute(ProductUpdateCommand.of(product,asList(Publish.of(),Unpublish.of())));
    assertEventually(() -> {
      final PagedQueryResult<ProductUnpublishedMessage> queryResult=execute(MessageQuery.of().withPredicates(m -> m.resource().is(unpublishedProduct)).withSort(m -> m.createdAt().sort().desc()).withExpansionPaths(m -> m.resource()).withLimit(1).forMessageType(ProductUnpublishedMessage.MESSAGE_HINT));
      final ProductUnpublishedMessage message=queryResult.head().get();
      assertThat(message.getResource().getId()).as("String_Node_Str").isEqualTo(product.getId());
      assertThat(message.getResource().getObj().getMasterData().isPublished()).isFalse();
    }
);
    return unpublishedProduct;
  }
);
}
Program: 130882
Project: 130882
Buggy source:
/** 
 * Finds a product variant by id.
 * @param variantId the id of the variant to find
 * @return optional of a variant matching variantId
 * @see #getVariantOrMaster(int)
 */
@Nullable default ProductVariant getVariant(final int variantId){
  final ProductVariant result;
  if (variantId == getMasterVariant().getId()) {
    result=getMasterVariant();
  }
 else {
    result=getVariants().stream().filter(v -> v.getId() == variantId).findFirst().orElse(null);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Finds a product variant by id.
 * @param variantId the id of the variant to find
 * @return variant or null if no variant exists with {@code id}
 * @see #getVariantOrMaster(int)
 */
@Nullable default ProductVariant getVariant(final int variantId){
  final ProductVariant result;
  if (variantId == getMasterVariant().getId()) {
    result=getMasterVariant();
  }
 else {
    result=getVariants().stream().filter(v -> v.getId() == variantId).findFirst().orElse(null);
  }
  return result;
}
Program: 130883
Project: 130883
Buggy source:
public static <T extends ResourceView<T>,C extends UpdateCommandDsl<T,C>>UpdateCommandDslBuilder<T,C> of(final Versioned<T> versioned,final List<? extends UpdateAction<T>> updateActions,final TypeReference<T> typeReference,final String baseEndpointWithoutId,final Function<UpdateCommandDslBuilder<T,C>,C> creationFunction){
  return new UpdateCommandDslBuilder<>(versioned,updateActions,typeReference,baseEndpointWithoutId,creationFunction);
}

Fixed version (ground truth):
public static <T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>UpdateCommandDslBuilder<T,C> of(final Versioned<T> versioned,final List<? extends UpdateAction<T>> updateActions,final TypeReference<T> typeReference,final String baseEndpointWithoutId,final Function<UpdateCommandDslBuilder<T,C>,C> creationFunction){
  return new UpdateCommandDslBuilder<>(versioned,updateActions,typeReference,baseEndpointWithoutId,creationFunction);
}
Program: 130884
Project: 130884
Buggy source:
public static TaxRateBuilder of(final TaxRate template){
  return of(template.getName(),template.getAmount(),template.isIncludedInPrice(),template.getCountry()).id(template.getId()).state(template.getState());
}

Fixed version (ground truth):
public static TaxRateBuilder of(final String name,final double amount,final boolean includedInPrice,final CountryCode country){
  return new TaxRateBuilder(name,amount,includedInPrice,country);
}
Program: 130885
Project: 130885
Buggy source:
@Override public ProductDraft get(){
  final ProductVariantDraft masterVariant=ProductVariantDraftBuilder.of().plusAttribute(Sizes.ATTRIBUTE.draftOf(Sizes.S)).plusAttribute(Colors.ATTRIBUTE.draftOf(Colors.GREEN)).sku(UUID.randomUUID().toString()).prices(Price.of(MoneyImpl.ofCents(1234,EUR))).build();
  final ProductVariantDraft secondVariant=ProductVariantDraftBuilder.of().plusAttribute(Sizes.ATTRIBUTE.draftOf(Sizes.M)).plusAttribute(Colors.ATTRIBUTE.draftOf(Colors.GREEN)).sku(UUID.randomUUID().toString()).prices(Price.of(MoneyImpl.ofCents(1234,EUR)),Price.of(MoneyImpl.ofCents(600,EUR)).withCustomerGroup(customerGroup)).build();
  final LocalizedStrings slug=en(name).slugifiedUnique();
  return ProductDraftBuilder.of(productType,en(name),slug,masterVariant).variants(asList(secondVariant)).description(en(name)).metaTitle(en("String_Node_Str")).metaDescription(en("String_Node_Str")).metaKeywords(en("String_Node_Str")).build();
}

Fixed version (ground truth):
@Override public ProductDraft get(){
  final ProductVariantDraft masterVariant=ProductVariantDraftBuilder.of().plusAttribute(Sizes.ATTRIBUTE.draftOf(Sizes.S)).plusAttribute(Colors.ATTRIBUTE.draftOf(Colors.GREEN)).sku(UUID.randomUUID().toString()).prices(Price.of(MoneyImpl.ofCents(1234,EUR))).build();
  final ProductVariantDraft secondVariant=ProductVariantDraftBuilder.of().plusAttribute(Sizes.ATTRIBUTE.draftOf(Sizes.M)).plusAttribute(Colors.ATTRIBUTE.draftOf(Colors.GREEN)).sku(UUID.randomUUID().toString()).prices(Price.of(MoneyImpl.ofCents(1234,EUR)),Price.of(MoneyImpl.ofCents(600,EUR)).withCustomerGroup(customerGroup)).build();
  final LocalizedString slug=en(name).slugifiedUnique();
  return ProductDraftBuilder.of(productType,en(name),slug,masterVariant).variants(asList(secondVariant)).description(en(name)).metaTitle(en("String_Node_Str")).metaDescription(en("String_Node_Str")).metaKeywords(en("String_Node_Str")).build();
}
Program: 130886
Project: 130886
Buggy source:
private LocalizedStrings en(final String value){
  return LocalizedStrings.of(Locale.ENGLISH,value);
}

Fixed version (ground truth):
private LocalizedString en(final String value){
  return LocalizedString.of(Locale.ENGLISH,value);
}
Program: 130887
Project: 130887
Buggy source:
@Override public void serialize(final SphereEnumeration sphereEnumeration,final JsonGenerator jsonGenerator,final SerializerProvider serializerProvider) throws IOException {
  final String sphereName=SphereEnumeration.toSphereName(sphereEnumeration.name());
  jsonGenerator.writeString(sphereName);
}

Fixed version (ground truth):
@Override public void serialize(final SphereEnumeration sphereEnumeration,final JsonGenerator jsonGenerator,final SerializerProvider serializerProvider) throws IOException {
  final String sphereName=sphereEnumeration.toSphereName();
  jsonGenerator.writeString(sphereName);
}
Program: 130888
Project: 130888
Buggy source:
static String toSphereName(final String uppercaseName){
  return Arrays.stream(StringUtils.split(uppercaseName,'_')).map(s -> s.toLowerCase()).map(StringUtils::capitalize).collect(joining("String_Node_Str"));
}

Fixed version (ground truth):
default String toSphereName(){
  return SphereEnumerationUtils.toSphereName(name());
}
Program: 130889
Project: 130889
Buggy source:
@Test public void queryByNameScenario(){
  assertModelsNotPresent();
  final List<Product> instances=createInBackendByName(modelNames());
  final List<String> actualNames=instances.stream().map(o -> extractName(o)).filter(name -> modelNames().contains(name)).sorted().collect(toList());
  assertThat(actualNames).overridingErrorMessage(String.format("String_Node_Str",IterableUtils.toString(modelNames()))).isEqualTo(modelNames());
  final String nameToFind=modelNames().get(1);
  final List<Product> results=execute(queryObjectForName(nameToFind)).getResults();
  assertThat(results).hasSize(1);
  assertThat(getNames(results)).isEqualTo(asList(nameToFind));
  assertModelsNotPresent();
}

Fixed version (ground truth):
@Test public void queryByNameScenario(){
  assertModelsNotPresent();
  final List<Product> instances=createInBackendByName(modelNames());
  final List<String> actualNames=instances.stream().map(o -> extractName(o)).filter(name -> modelNames().contains(name)).sorted().collect(toList());
  final StringJoiner joiner=new StringJoiner("String_Node_Str");
  modelNames().forEach(item -> joiner.add(item.toString()));
  assertThat(actualNames).overridingErrorMessage(String.format("String_Node_Str","String_Node_Str" + joiner.toString() + "String_Node_Str")).isEqualTo(modelNames());
  final String nameToFind=modelNames().get(1);
  final List<Product> results=execute(queryObjectForName(nameToFind)).getResults();
  assertThat(results).hasSize(1);
  assertThat(getNames(results)).isEqualTo(asList(nameToFind));
  assertModelsNotPresent();
}