Program: 130873
Project: 130873
Buggy source:
@Test public void fullTest(){
  withStateByBuilder(client(),stateBuilder -> stateBuilder.initial(true).type(PAYMENT_STATE),paidState -> {
    TypeFixtures.withUpdateableType(client(),type -> {
      CustomerFixtures.withCustomerAndCart(client(),((customer,cart) -> {
        final MonetaryAmount totalAmount=cart.getTotalPrice();
        final PaymentStatus paymentStatus=PaymentStatusBuilder.of().interfaceCode(randomKey()).interfaceText(randomString()).state(paidState).build();
        final PaymentMethodInfo paymentMethodInfo=PaymentMethodInfoBuilder.of().paymentInterface("String_Node_Str").method("String_Node_Str").name(randomSlug()).build();
        final List<Transaction> transactions=Collections.singletonList(TransactionBuilder.of(TransactionType.CHARGE,totalAmount,ZonedDateTime.now()).timestamp(ZonedDateTime.now()).interactionId(randomKey()).build());
        final String externalId=randomKey();
        final String interfaceId=randomKey();
        final ZonedDateTime authorizedUntil=ZonedDateTime.now().plusMonths(1);
        final PaymentDraftBuilder paymentDraftBuilder=PaymentDraftBuilder.of(totalAmount).customer(customer).externalId(externalId).interfaceId(interfaceId).amountAuthorized(totalAmount).amountPaid(totalAmount).authorizedUntil(authorizedUntil).amountRefunded(EURO_1).paymentMethodInfo(paymentMethodInfo).custom(CustomFieldsDraft.ofTypeKeyAndObjects(type.getKey(),singletonMap(TypeFixtures.STRING_FIELD_NAME,"String_Node_Str"))).paymentStatus(paymentStatus).transactions(transactions).interfaceInteractions(asList("String_Node_Str","String_Node_Str").stream().map(s -> CustomFieldsDraft.ofTypeKeyAndObjects(type.getKey(),singletonMap(TypeFixtures.STRING_FIELD_NAME,s))).collect(toList()));
        final Payment payment=execute(PaymentCreateCommand.of(paymentDraftBuilder.build()));
        final PaymentQuery paymentQuery=PaymentQuery.of().withPredicates(m -> m.id().is(payment.getId()).and(m.customer().is(customer)).and(m.externalId().is(externalId)).and(m.interfaceId().is(interfaceId)).and(m.amountPlanned().currencyCode().is(totalAmount.getCurrency())).and(m.amountAuthorized().currencyCode().is(totalAmount.getCurrency())).and(m.amountPaid().currencyCode().is(totalAmount.getCurrency())).and(m.amountRefunded().currencyCode().is(totalAmount.getCurrency())).and(m.paymentMethodInfo().method().is(paymentMethodInfo.getMethod())).and(m.paymentMethodInfo().paymentInterface().is(paymentMethodInfo.getPaymentInterface())).and(m.paymentMethodInfo().name().locale(ENGLISH).is(paymentMethodInfo.getName().get(ENGLISH))).and(m.custom().type().is(type)).and(m.paymentStatus().interfaceCode().is(paymentStatus.getInterfaceCode())).and(m.paymentStatus().interfaceText().is(paymentStatus.getInterfaceText())).and(m.paymentStatus().state().is(paidState)).and(m.transactions().amount().currencyCode().is(totalAmount.getCurrency())).and(m.transactions().interactionId().is(transactions.get(0).getInteractionId()))).withExpansionPaths(m -> m.customer()).plusExpansionPaths(m -> m.paymentStatus().state());
        final PagedQueryResult<Payment> pagedQueryResult=execute(paymentQuery);
        assertThat(pagedQueryResult).has(onlyTheResult(payment));
        final Payment loadedPayment=pagedQueryResult.head().get();
        assertThat(loadedPayment.getCustomer()).is(expanded(customer));
        assertThat(loadedPayment.getPaymentStatus().getState()).is(expanded(paidState));
        execute(PaymentDeleteCommand.of(payment));
      }
));
      return type;
    }
);
  }
);
}

Fixed version (ground truth):
@Test public void fullTest(){
  withStateByBuilder(client(),stateBuilder -> stateBuilder.initial(true).type(PAYMENT_STATE),paidState -> {
    TypeFixtures.withUpdateableType(client(),type -> {
      CustomerFixtures.withCustomerAndCart(client(),((customer,cart) -> {
        final MonetaryAmount totalAmount=cart.getTotalPrice();
        final PaymentStatus paymentStatus=PaymentStatusBuilder.of().interfaceCode(randomKey()).interfaceText(randomString()).state(paidState).build();
        final PaymentMethodInfo paymentMethodInfo=PaymentMethodInfoBuilder.of().paymentInterface("String_Node_Str").method("String_Node_Str").name(randomSlug()).build();
        final TransactionType transactionType=TransactionType.CHARGE;
        final List<Transaction> transactions=Collections.singletonList(TransactionBuilder.of(transactionType,totalAmount,ZonedDateTime.now()).timestamp(ZonedDateTime.now()).interactionId(randomKey()).build());
        final String externalId=randomKey();
        final String interfaceId=randomKey();
        final ZonedDateTime authorizedUntil=ZonedDateTime.now().plusMonths(1);
        final PaymentDraftBuilder paymentDraftBuilder=PaymentDraftBuilder.of(totalAmount).customer(customer).externalId(externalId).interfaceId(interfaceId).amountAuthorized(totalAmount).amountPaid(totalAmount).authorizedUntil(authorizedUntil).amountRefunded(EURO_1).paymentMethodInfo(paymentMethodInfo).custom(CustomFieldsDraft.ofTypeKeyAndObjects(type.getKey(),singletonMap(TypeFixtures.STRING_FIELD_NAME,"String_Node_Str"))).paymentStatus(paymentStatus).transactions(transactions).interfaceInteractions(asList("String_Node_Str","String_Node_Str").stream().map(s -> CustomFieldsDraft.ofTypeKeyAndObjects(type.getKey(),singletonMap(TypeFixtures.STRING_FIELD_NAME,s))).collect(toList()));
        final Payment payment=execute(PaymentCreateCommand.of(paymentDraftBuilder.build()));
        final PaymentQuery paymentQuery=PaymentQuery.of().withPredicates(m -> m.id().is(payment.getId()).and(m.customer().is(customer)).and(m.externalId().is(externalId)).and(m.interfaceId().is(interfaceId)).and(m.amountPlanned().currencyCode().is(totalAmount.getCurrency())).and(m.amountAuthorized().currencyCode().is(totalAmount.getCurrency())).and(m.amountPaid().currencyCode().is(totalAmount.getCurrency())).and(m.amountRefunded().currencyCode().is(totalAmount.getCurrency())).and(m.paymentMethodInfo().method().is(paymentMethodInfo.getMethod())).and(m.paymentMethodInfo().paymentInterface().is(paymentMethodInfo.getPaymentInterface())).and(m.paymentMethodInfo().name().locale(ENGLISH).is(paymentMethodInfo.getName().get(ENGLISH))).and(m.custom().type().is(type)).and(m.paymentStatus().interfaceCode().is(paymentStatus.getInterfaceCode())).and(m.paymentStatus().interfaceText().is(paymentStatus.getInterfaceText())).and(m.paymentStatus().state().is(paidState)).and(m.transactions().type().is(transactionType)).and(m.transactions().amount().currencyCode().is(totalAmount.getCurrency())).and(m.transactions().interactionId().is(transactions.get(0).getInteractionId()))).withExpansionPaths(m -> m.customer()).plusExpansionPaths(m -> m.paymentStatus().state());
        final PagedQueryResult<Payment> pagedQueryResult=execute(paymentQuery);
        assertThat(pagedQueryResult).has(onlyTheResult(payment));
        final Payment loadedPayment=pagedQueryResult.head().get();
        assertThat(loadedPayment.getCustomer()).is(expanded(customer));
        assertThat(loadedPayment.getPaymentStatus().getState()).is(expanded(paidState));
        execute(PaymentDeleteCommand.of(payment));
      }
));
      return type;
    }
);
  }
);
}