@Test public void getShippingInfo_whenShippingInfoInvalid_returnsNull() { assertNull(mShippingInfoWidget.getShippingInformation()); }
public ShippingInformation getShippingInformation() { if (!validateAllFields()) { return null; } Address address = new Address.Builder() .setCity(mCityEditText.getText().toString()) .setCountry(mCountryAutoCompleteTextView.getSelectedCountryCode()) .setLine1(mAddressEditText.getText().toString()) .setLine2(mAddressEditText2.getText().toString()) .setPostalCode(mPostalCodeEditText.getText().toString()) .setState(mStateEditText.getText().toString()).build(); ShippingInformation shippingInformation = new ShippingInformation(address,mNameEditText.getText().toString(), mPhoneNumberEditText.getText().toString() ); return shippingInformation; }
ShippingInfoWidget extends LinearLayout { public ShippingInformation getShippingInformation() { if (!validateAllFields()) { return null; } Address address = new Address.Builder() .setCity(mCityEditText.getText().toString()) .setCountry(mCountryAutoCompleteTextView.getSelectedCountryCode()) .setLine1(mAddressEditText.getText().toString()) .setLine2(mAddressEditText2.getText().toString()) .setPostalCode(mPostalCodeEditText.getText().toString()) .setState(mStateEditText.getText().toString()).build(); ShippingInformation shippingInformation = new ShippingInformation(address,mNameEditText.getText().toString(), mPhoneNumberEditText.getText().toString() ); return shippingInformation; } }
ShippingInfoWidget extends LinearLayout { public ShippingInformation getShippingInformation() { if (!validateAllFields()) { return null; } Address address = new Address.Builder() .setCity(mCityEditText.getText().toString()) .setCountry(mCountryAutoCompleteTextView.getSelectedCountryCode()) .setLine1(mAddressEditText.getText().toString()) .setLine2(mAddressEditText2.getText().toString()) .setPostalCode(mPostalCodeEditText.getText().toString()) .setState(mStateEditText.getText().toString()).build(); ShippingInformation shippingInformation = new ShippingInformation(address,mNameEditText.getText().toString(), mPhoneNumberEditText.getText().toString() ); return shippingInformation; } ShippingInfoWidget(Context context);  ShippingInfoWidget(Context context, AttributeSet attrs);  ShippingInfoWidget(Context context, AttributeSet attrs, int defStyleAttr); }
ShippingInfoWidget extends LinearLayout { public ShippingInformation getShippingInformation() { if (!validateAllFields()) { return null; } Address address = new Address.Builder() .setCity(mCityEditText.getText().toString()) .setCountry(mCountryAutoCompleteTextView.getSelectedCountryCode()) .setLine1(mAddressEditText.getText().toString()) .setLine2(mAddressEditText2.getText().toString()) .setPostalCode(mPostalCodeEditText.getText().toString()) .setState(mStateEditText.getText().toString()).build(); ShippingInformation shippingInformation = new ShippingInformation(address,mNameEditText.getText().toString(), mPhoneNumberEditText.getText().toString() ); return shippingInformation; } ShippingInfoWidget(Context context);  ShippingInfoWidget(Context context, AttributeSet attrs);  ShippingInfoWidget(Context context, AttributeSet attrs, int defStyleAttr); void setOptionalFields(@Nullable List<String> optionalAddressFields); void setHiddenFields(@Nullable List<String> hiddenAddressFields); ShippingInformation getShippingInformation(); void populateShippingInfo(@Nullable ShippingInformation shippingInformation); boolean validateAllFields(); }
ShippingInfoWidget extends LinearLayout { public ShippingInformation getShippingInformation() { if (!validateAllFields()) { return null; } Address address = new Address.Builder() .setCity(mCityEditText.getText().toString()) .setCountry(mCountryAutoCompleteTextView.getSelectedCountryCode()) .setLine1(mAddressEditText.getText().toString()) .setLine2(mAddressEditText2.getText().toString()) .setPostalCode(mPostalCodeEditText.getText().toString()) .setState(mStateEditText.getText().toString()).build(); ShippingInformation shippingInformation = new ShippingInformation(address,mNameEditText.getText().toString(), mPhoneNumberEditText.getText().toString() ); return shippingInformation; } ShippingInfoWidget(Context context);  ShippingInfoWidget(Context context, AttributeSet attrs);  ShippingInfoWidget(Context context, AttributeSet attrs, int defStyleAttr); void setOptionalFields(@Nullable List<String> optionalAddressFields); void setHiddenFields(@Nullable List<String> hiddenAddressFields); ShippingInformation getShippingInformation(); void populateShippingInfo(@Nullable ShippingInformation shippingInformation); boolean validateAllFields(); static final String ADDRESS_LINE_ONE_FIELD; static final String ADDRESS_LINE_TWO_FIELD; static final String CITY_FIELD; static final String POSTAL_CODE_FIELD; static final String STATE_FIELD; static final String PHONE_FIELD; }