private JSONObject getGDPRConsentObject() { JSONObject gdprConsent = new JSONObject(); try { Context context = this.getContext(); if (context != null) { Boolean consentRequired = ANGDPRSettings.getConsentRequired(context); // Only populate GDPR Consent object if Consent Required true/false. Otherwise treat it as unknown, impbus knows how to handle it. if (consentRequired != null) { gdprConsent.put(GDPR_CONSENT_REQUIRED, consentRequired); gdprConsent.put(GDPR_CONSENT_STRING, ANGDPRSettings.getConsentString(context)); } } } catch (JSONException e) { } return gdprConsent; }
/** * Test gdpr_consent in /ut request body * @throws Exception */ @Test public void testGDPRSettings() throws Exception { executionSteps(); JSONObject postDataBeforeGDPRValueSet = inspectPostData(); assertFalse(postDataBeforeGDPRValueSet.has("gdpr_consent")); ANGDPRSettings.setConsentRequired(activity,true); ANGDPRSettings.setConsentString(activity,"fooBar"); executionSteps(); JSONObject postDataWithGDPRValueSet = inspectPostData(); assertEquals(true, postDataWithGDPRValueSet.getJSONObject("gdpr_consent").getBoolean("consent_required")); assertEquals("fooBar", postDataWithGDPRValueSet.getJSONObject("gdpr_consent").getString("consent_string")); }