### Question:
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; }### Answer:
@Test public void getShippingInfo_whenShippingInfoInvalid_returnsNull() { assertNull(mShippingInfoWidget.getShippingInformation()); }
@Test public void getShippingInfo_whenShippingInfoValid_returnsExpected() { mStateEditText.setText("CA"); mCityEditText.setText("San Francisco"); mAddressLine1EditText.setText("185 Berry St"); mAddressLine2EditText.setText("10th Floor"); mNameEditText.setText("Fake Name"); mPhoneEditText.setText("(123) 456 - 7890"); mPostalEditText.setText("12345"); mCountryAutoCompleteTextView.updateUIForCountryEntered(Locale.US.getDisplayCountry()); ShippingInformation inputShippingInfo = mShippingInfoWidget.getShippingInformation(); assertEquals(inputShippingInfo.toMap(), mShippingInfo.toMap()); }