@Test
	public void acceptedRequestIsFullyApplied() throws EngineException
	{
		RegistrationContext defContext = new RegistrationContext(false, TriggeringMode.manualAtLogin);
		initAndCreateForm(false, null);
		RegistrationRequest request = getRequest();
		String id3 = registrationsMan.submitRegistrationRequest(request, defContext);
		registrationsMan.processRegistrationRequest(id3, null, 
				RegistrationRequestAction.accept, "a2", "p2");
		RegistrationRequestState fromDb = registrationsMan.getRegistrationRequests().get(0);
		assertEquals(request, fromDb.getRequest());
		assertEquals(2, fromDb.getAdminComments().size());
		assertEquals("p2", fromDb.getAdminComments().get(1).getContents());
		assertEquals("a2", fromDb.getAdminComments().get(0).getContents());
		assertEquals(RegistrationRequestStatus.accepted, fromDb.getStatus());
		assertEquals(id3, fromDb.getRequestId());
		assertNotNull(fromDb.getTimestamp());
		Entity added = idsMan.getEntity(new EntityParam(new IdentityTaV(X500Identity.ID, "CN=registration test")));
		assertEquals(EntityState.valid, added.getState());
		assertEquals(EngineInitialization.DEFAULT_CREDENTIAL_REQUIREMENT,
				added.getCredentialInfo().getCredentialRequirementId());
		assertThat(fromDb.getCreatedEntityId(), is(added.getId()));
		CredentialPublicInformation cpi = added.getCredentialInfo().getCredentialsState().get(
				EngineInitialization.DEFAULT_CREDENTIAL);
		assertEquals(LocalCredentialState.correct, cpi.getState());
		EntityParam addedP = new EntityParam(added.getId());
		Collection<String> groups = idsMan.getGroups(addedP).keySet();
		assertTrue(groups.contains("/"));
		assertTrue(groups.contains("/A"));
		assertTrue(groups.contains("/B"));
		Collection<AttributesClass> acs = acMan.getEntityAttributeClasses(addedP, "/");
		assertEquals(1, acs.size());
		assertEquals(InitializerCommon.NAMING_AC, acs.iterator().next().getName());
		Collection<AttributeExt> attrs = attrsMan.getAttributes(addedP, "/", "cn");
		assertEquals(1, attrs.size());
		assertEquals("val", attrs.iterator().next().getValues().get(0));
		attrs = attrsMan.getAttributes(addedP, "/", "email");
		assertEquals(1, attrs.size());
		String value = attrs.iterator().next().getValues().get(0);
		VerifiableEmail ve = new VerifiableEmail(JsonUtil.parse(value)); //FIXME - this is likely wrong
		assertEquals("foo@example.com", ve.getValue());
		assertEquals(false, ve.getConfirmationInfo().isConfirmed());
	}
@Test
	public void acceptedRequestIsFullyApplied() throws EngineException
	{
		RegistrationContext defContext = new RegistrationContext(false, TriggeringMode.manualAtLogin);
		initAndCreateForm(false, null);
		RegistrationRequest request = getRequest();
		String id3 = registrationsMan.submitRegistrationRequest(request, defContext);
		registrationsMan.processRegistrationRequest(id3, null, 
				RegistrationRequestAction.accept, "a2", "p2");
		RegistrationRequestState fromDb = registrationsMan.getRegistrationRequests().get(0);
		assertEquals(request, fromDb.getRequest());
		assertEquals(2, fromDb.getAdminComments().size());
		assertEquals("p2", fromDb.getAdminComments().get(1).getContents());
		assertEquals("a2", fromDb.getAdminComments().get(0).getContents());
		assertEquals(RegistrationRequestStatus.accepted, fromDb.getStatus());
		assertEquals(id3, fromDb.getRequestId());
		assertNotNull(fromDb.getTimestamp());
		Entity added = idsMan.getEntity(new EntityParam(new IdentityTaV(X500Identity.ID, "CN=registration test")));
		assertEquals(EntityState.valid, added.getState());
		assertEquals(EngineInitialization.DEFAULT_CREDENTIAL_REQUIREMENT,
				added.getCredentialInfo().getCredentialRequirementId());
		assertThat(fromDb.getCreatedEntityId(), is(added.getId()));
		CredentialPublicInformation cpi = added.getCredentialInfo().getCredentialsState().get(
				EngineInitialization.DEFAULT_CREDENTIAL);
		assertEquals(LocalCredentialState.correct, cpi.getState());
		EntityParam addedP = new EntityParam(added.getId());
		Collection<String> groups = idsMan.getGroups(addedP).keySet();
		assertTrue(groups.contains("/"));
		assertTrue(groups.contains("/A"));
		assertTrue(groups.contains("/B"));
		Collection<AttributesClass> acs = acMan.getEntityAttributeClasses(addedP, "/");
		assertEquals(1, acs.size());
		assertEquals(InitializerCommon.NAMING_AC, acs.iterator().next().getName());
		Collection<AttributeExt> attrs = attrsMan.getAttributes(addedP, "/", "cn");
		assertEquals(1, attrs.size());
		assertEquals("val", attrs.iterator().next().getValues().get(0));
		attrs = attrsMan.getAttributes(addedP, "/", "email");
		assertEquals(1, attrs.size());
		String value = attrs.iterator().next().getValues().get(0);
		VerifiableEmail ve = new VerifiableEmail(JsonUtil.parse(value));
		assertEquals("foo@example.com", ve.getValue());
		assertEquals(false, ve.getConfirmationInfo().isConfirmed());
	}
@test public void acceptedrequestisfullyapplied() throws engineexception { registrationcontext defcontext = new registrationcontext(false, triggeringmode.manualatlogin); initandcreateform(false, null); registrationrequest request = getrequest(); string id3 = registrationsman.submitregistrationrequest(request, defcontext); registrationsman.processregistrationrequest(id3, null, registrationrequestaction.accept, "a2", "p2"); registrationrequeststate fromdb = registrationsman.getregistrationrequests().get(0); assertequals(request, fromdb.getrequest()); assertequals(2, fromdb.getadmincomments().size()); assertequals("p2", fromdb.getadmincomments().get(1).getcontents()); assertequals("a2", fromdb.getadmincomments().get(0).getcontents()); assertequals(registrationrequeststatus.accepted, fromdb.getstatus()); assertequals(id3, fromdb.getrequestid()); assertnotnull(fromdb.gettimestamp()); entity added = idsman.getentity(new entityparam(new identitytav(x500identity.id, "cn=registration test"))); assertequals(entitystate.valid, added.getstate()); assertequals(engineinitialization.default_credential_requirement, added.getcredentialinfo().getcredentialrequirementid()); assertthat(fromdb.getcreatedentityid(), is(added.getid())); credentialpublicinformation cpi = added.getcredentialinfo().getcredentialsstate().get( engineinitialization.default_credential); assertequals(localcredentialstate.correct, cpi.getstate()); entityparam addedp = new entityparam(added.getid()); collection<string> groups = idsman.getgroups(addedp).keyset(); asserttrue(groups.contains("/")); asserttrue(groups.contains("/a")); asserttrue(groups.contains("/b")); collection<attributesclass> acs = acman.getentityattributeclasses(addedp, "/"); assertequals(1, acs.size()); assertequals(initializercommon.naming_ac, acs.iterator().next().getname()); collection<attributeext> attrs = attrsman.getattributes(addedp, "/", "cn"); assertequals(1, attrs.size()); assertequals("val", attrs.iterator().next().getvalues().get(0)); attrs = attrsman.getattributes(addedp, "/", "email"); assertequals(1, attrs.size()); string value = attrs.iterator().next().getvalues().get(0); verifiableemail ve = new verifiableemail(jsonutil.parse(value)); assertequals("foo@example.com", ve.getvalue()); assertequals(false, ve.getconfirmationinfo().isconfirmed()); }