### Question:
Invoice extends UdoDomainObject2<T> implements WithApplicationTenancyAny, WithApplicationTenancyPathPersisted { @Programmatic public InvoiceItem findFirstItemWithCharge(final Charge charge) { for (InvoiceItem item : getItems()) { if (item.getCharge().equals(charge)) { return item; } } return null; } Invoice(final String keyProperties); @Property(hidden = Where.ALL_TABLES) @PropertyLayout( named = "Application Level", describedAs = "Determines those users for whom this object is available to view and/or modify." ) ApplicationTenancy getApplicationTenancy(); String title(); @Property(hidden = Where.OBJECT_FORMS) String getNumber(); @Action( semantics = SemanticsOf.IDEMPOTENT, restrictTo = RestrictTo.PROTOTYPING ) Invoice updateAttribute(
            final InvoiceAttributeName name,
            @Parameter(maxLength = NotesType.Meta.MAX_LEN)
            @ParameterLayout(multiLine = Invoice.DescriptionType.Meta.MULTI_LINE) final String value,
            InvoiceAttributeAction action
    ); @Action(semantics = SemanticsOf.IDEMPOTENT) Invoice changeDueDate(final LocalDate dueDate); LocalDate default0ChangeDueDate(final LocalDate dueDate); String disableChangeDueDate(); @Action(semantics = SemanticsOf.IDEMPOTENT) Invoice changePaymentMethod(final PaymentMethod paymentMethod); PaymentMethod default0ChangePaymentMethod(); String disableChangePaymentMethod(); String validateChangePaymentMethod(final PaymentMethod paymentMethod); @Programmatic BigInteger nextItemSequence(); @Property(notPersisted = true) BigDecimal getTotalNetAmount(); @Property(notPersisted = true, hidden = Where.ALL_TABLES) BigDecimal getTotalVatAmount(); @Property(notPersisted = true) BigDecimal getTotalGrossAmount(); @Programmatic boolean isImmutableDueToState(); @Programmatic InvoiceItem findFirstItemWithCharge(final Charge charge); Invoice verify(); boolean hideVerify();  }### Answer:
@Test public void first_item_with_charge_works() throws Exception { InvoiceForTesting invoice = new InvoiceForTesting(); Charge charge1 = new Charge(); Charge charge2 = new Charge(); InvoiceItem itemWithCharge1 = new InvoiceItemForTesting(invoice); itemWithCharge1.setCharge(charge1); itemWithCharge1.setSequence(VT.bi(1)); InvoiceItem otherItemWithCharge1 = new InvoiceItemForTesting(invoice); otherItemWithCharge1.setCharge(charge1); otherItemWithCharge1.setSequence(VT.bi(2)); InvoiceItem itemWithCharge2 = new InvoiceItemForTesting(invoice); itemWithCharge2.setCharge(charge2); invoice.getItems().addAll(Arrays.asList(itemWithCharge1, otherItemWithCharge1, itemWithCharge2)); assertThat(invoice.getItems().size()).isEqualTo(3); assertThat(invoice.findFirstItemWithCharge(charge1)).isEqualTo(itemWithCharge1); assertThat(invoice.findFirstItemWithCharge(charge2)).isEqualTo(itemWithCharge2); }