}
assertNotNull("Portlet Def is null", pd);
ContentFragmentImpl f1 = new ContentFragmentImpl(TEST_ENTITY);
f1.setName(pd.getUniqueName());
PortletEntity entity = entityAccess.generateEntityFromFragment(f1);
// TODO: how to access prefs of entity??
/*
PreferenceSetComposite prefs = (PreferenceSetComposite) entity.getPreferenceSet();
prefs.remove("pref1");
assertNotNull(prefs);
assertNull(prefs.get("pref1"));
// test adding a pref
prefs.add("pref1", Arrays.asList(new String[]
{ "1" }));
assertNotNull(prefs.get("pref1"));
// Remove should return the deleted pref
assertNotNull(prefs.remove("pref1"));
// Should be gone
assertNull(prefs.get("pref1"));
// Add it back so we can test tole back
prefs.add("pref1", Arrays.asList(new String[]
{ "1" }));
entityAccess.storePortletEntity(entity);
prefs = (PreferenceSetComposite) entity.getPreferenceSet();
assertNotNull(prefs.get("pref1"));
PreferenceComposite pref = (PreferenceComposite) prefs.get("pref1");
List<String> prefValues = pref.getValuesList();
assertEquals(1, prefValues.size());
prefValues.set(0, "2");
pref.setValues(prefValues);
prefValues = pref.getValuesList();
assertEquals("2", prefValues.get(0));
prefValues.add("3");
prefs.add("pref2", prefValues);
entity.store();
prefs = (PreferenceSetComposite)entity.getPreferenceSet();
PreferenceComposite pref2 = (PreferenceComposite) prefs.get("pref2");
assertNotNull(pref2);
prefValues = pref2.getValuesList();
assertEquals(2, prefValues.size());
pref2.addValue("4");
prefValues = pref2.getValuesList();
assertEquals(3, prefValues.size());
assertEquals("2", prefValues.get(0));
assertEquals("3", prefValues.get(1));
assertEquals("4", prefValues.get(2));
// testing preferences null values assignments fix, issue JS2-607
prefValues.set(0,null);
pref2.setValues(prefValues);
entity.store();
prefs = (PreferenceSetComposite)entity.getPreferenceSet();
pref2 = (PreferenceComposite) prefs.get("pref2");
prefValues = pref2.getValuesList();
assertNull("pref2.value[0] should be null", prefValues.get(0));
assertEquals(3, prefValues.size());
assertEquals("3", prefValues.get(1));
prefValues.set(0, "2");
prefValues.set(1, null);
prefValues.set(2, "3");
pref2.setValues(prefValues);
entity.store();
prefs = (PreferenceSetComposite)entity.getPreferenceSet();
pref2 = (PreferenceComposite) prefs.get("pref2");
prefValues = pref2.getValuesList();
assertNull("pref2.value[1] should be null", prefValues.get(1));
assertTrue(pref2.isValueSet());
pref2.setValues(null);
assertFalse(pref2.isValueSet());
entity.store();
prefs = (PreferenceSetComposite)entity.getPreferenceSet();
pref2 = (PreferenceComposite) prefs.get("pref2");
assertNull(pref2);
*/
PortletEntity entity2 = entityAccess.getPortletEntityForFragment(f1);
assertTrue("entity id ", entity2.getId().toString().equals(TEST_ENTITY));
assertNotNull("entity's portlet ", entity2.getPortletDefinition());
PortletEntity entity5 = entityAccess.newPortletEntityInstance(pd);
System.out.println("before storing entity: " + entity5.getId());
entityAccess.storePortletEntity(entity5);
System.out.println("store done: " + entity5.getId());
ContentFragmentImpl f2 = new ContentFragmentImpl(TEST_ENTITY);
f2.setName(pd.getUniqueName());
PortletEntity entity6 = entityAccess.getPortletEntityForFragment(f2);
assertNotNull(entity6);
System.out.println("reget : " + entity6.getId());
entityAccess.removePortletEntity(entity6);
}