@Test public void setStatusChangesStatus() { Consent consent = new DefaultConsent(ID_STRING, DESCRIPTION_STRING, false); consent.setStatus(ConsentStatus.NO); Assert.assertSame(consent.getStatus(), ConsentStatus.NO); consent.setStatus(ConsentStatus.YES); Assert.assertSame(consent.getStatus(), ConsentStatus.YES); }
@Test public void testNormalInitialization() { boolean required = true; Consent consent = new DefaultConsent(ID_STRING, DESCRIPTION_STRING, required); Assert.assertSame(consent.getId(), ID_STRING); Assert.assertSame(consent.getDescription(), DESCRIPTION_STRING); Assert.assertSame(consent.isRequired(), required); Assert.assertSame(consent.getStatus(), ConsentStatus.NOT_SET); }
@Test public void producesCorrectJson() { ConsentStatus status = ConsentStatus.NO; boolean required = false; Consent consent = new DefaultConsent(ID_STRING, DESCRIPTION_STRING, required); consent.setStatus(status); JSONObject json = consent.toJson(); Assert.assertNotNull(json); Assert.assertSame(json.getString("id"), ID_STRING); Assert.assertSame(json.getString("description"), DESCRIPTION_STRING); Assert.assertSame(json.getString("status"), status.toString()); Assert.assertSame(json.getBoolean("isRequired"), required); }
@Test public void copiesCorrectly() { ConsentStatus status = ConsentStatus.NO; boolean required = false; Consent original = new DefaultConsent(ID_STRING, DESCRIPTION_STRING, required); original.setStatus(status); Consent copy = DefaultConsent.copy(original); Assert.assertSame(copy.getId(), ID_STRING); Assert.assertSame(copy.getDescription(), DESCRIPTION_STRING); Assert.assertSame(copy.getStatus(), status); Assert.assertSame(copy.isRequired(), required); }