### Question:
UserRestrictionParams extends RequestParams<UserRestrictionParams> implements IUserRestrictionsParams<UserRestrictionParams>, DataRestrictions { void build(@NonNull Context.Regs.Builder builder) { builder.setGdpr(subjectToGDPR()); builder.setCoppa(hasCoppa != null && hasCoppa); String iabUsPrivacyString = getUsPrivacy(); if (!TextUtils.isEmpty(iabUsPrivacyString)) { assert iabUsPrivacyString != null; RegsCcpaExtension regsCcpaExtension = RegsCcpaExtension.newBuilder() .setUsPrivacy(iabUsPrivacyString) .build(); builder.addExt(Any.pack(regsCcpaExtension)); } }  @Override void merge(@NonNull UserRestrictionParams instance); @Override UserRestrictionParams setConsentConfig(boolean hasConsent, String consentString); @Override UserRestrictionParams setSubjectToGDPR(Boolean subject); @Override UserRestrictionParams setCoppa(Boolean coppa); @Override boolean canSendGeoPosition(); @Override boolean canSendUserInfo(); @Override boolean canSendDeviceInfo(); @Override boolean canSendIfa(); @Override boolean isUserInGdprScope(); @Override boolean isUserHasConsent(); @Override boolean isUserGdprProtected(); @Override boolean isUserAgeRestricted(); @Nullable @Override String getUsPrivacy();  }### Answer:
@Test public void buildRegs_ccpaNotPresentInSharedPreference_extensionIsNotSet() { BidMachineImpl.get().getIabSharedPreference().initialize(context); Context.Regs.Builder builder = Context.Regs.newBuilder(); BidMachineImpl.get() .getUserRestrictionParams() .build(builder); assertEquals(0, builder.getExtCount()); }
@Test public void buildRegs_ccpaIsEmptyInSharedPreference_extensionIsNotSet() { BidMachineImpl.get().getIabSharedPreference().initialize(context); Context.Regs.Builder builder = Context.Regs.newBuilder(); BidMachineImpl.get() .getUserRestrictionParams() .build(builder); assertEquals(0, builder.getExtCount()); }
@Test public void buildRegs_ccpaIsPresentInSharedPreferenceButWrongType_extensionIsSet() throws Exception { defaultSharedPreferences.edit() .putInt(IABSharedPreference.IAB_US_PRIVACY_STRING, 123) .apply(); BidMachineImpl.get().getIabSharedPreference().initialize(context); Context.Regs.Builder builder = Context.Regs.newBuilder(); BidMachineImpl.get() .getUserRestrictionParams() .build(builder); assertEquals(0, builder.getExtCount()); }