ChargeRequest { public @NonNull Builder newBuilder() { return newBuilder(totalAmount, currencyCode); } ChargeRequest(Builder builder); @NonNull Builder newBuilder(); @NonNull Builder newBuilder(int totalAmount, CurrencyCode currencyCode); @Override boolean equals(Object o); @Override int hashCode(); final int totalAmount; @NonNull final CurrencyCode currencyCode; @NonNull final Set<TenderType> tenderTypes; @Nullable final String note; final long autoReturnMillis; @Nullable final String locationId; @Nullable final String requestMetadata; @Nullable final String customerId; }
@Test public void copyKeepingAmount() { ChargeRequest request = new ChargeRequest.Builder(1_00, USD).restrictTendersTo(CARD) .autoReturn(4, SECONDS) .enforceBusinessLocation("location") .requestMetadata("metadata") .customerId("customerId") .note("note") .build(); ChargeRequest updatedRequest = request.newBuilder() .restrictTendersTo(CASH) .autoReturn(5, SECONDS) .enforceBusinessLocation("location2") .requestMetadata("metadata2") .customerId("customerId2") .note("note2") .build(); assertThat(updatedRequest.totalAmount).isEqualTo(1_00); assertThat(updatedRequest.currencyCode).isEqualTo(USD); assertThat(updatedRequest.tenderTypes).containsExactly(CASH); assertThat(updatedRequest.autoReturnMillis).isEqualTo(5_000); assertThat(updatedRequest.locationId).isEqualTo("location2"); assertThat(updatedRequest.requestMetadata).isEqualTo("metadata2"); assertThat(updatedRequest.customerId).isEqualTo("customerId2"); assertThat(updatedRequest.note).isEqualTo("note2"); }
@Test public void copyUpdatingAmount() { ChargeRequest request = new ChargeRequest.Builder(1_00, USD).restrictTendersTo(CARD) .autoReturn(4, SECONDS) .enforceBusinessLocation("location") .requestMetadata("metadata") .customerId("customerId") .note("note") .build(); ChargeRequest updatedRequest = request.newBuilder(2_00, CAD).build(); assertThat(updatedRequest.totalAmount).isEqualTo(2_00); assertThat(updatedRequest.currencyCode).isEqualTo(CAD); assertThat(updatedRequest.tenderTypes).containsExactly(CARD); assertThat(updatedRequest.autoReturnMillis).isEqualTo(4_000); assertThat(updatedRequest.locationId).isEqualTo("location"); assertThat(updatedRequest.requestMetadata).isEqualTo("metadata"); assertThat(updatedRequest.customerId).isEqualTo("customerId"); assertThat(updatedRequest.note).isEqualTo("note"); }