use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.
the class LocalSkillCostFacetTest method testAddBadSource.
@Test
public void testAddBadSource() {
Skill t1 = getObject();
PCClassLevel pcl = new PCClassLevel();
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, pcl, new Object(), DataFacetChangeEvent.DATA_ADDED);
ListKey<CDOMReference<Skill>> lk = ListKey.LOCALCSKILL;
pcl.addToListFor(lk, CDOMDirectSingleRef.getRef(t1));
try {
getFacet().dataAdded(dfce);
fail();
} catch (IllegalArgumentException e) {
// Yep!
}
}
use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.
the class LocalSkillCostFacetTest method testRemoveSecondSource.
@Test
public void testRemoveSecondSource() {
Skill t1 = getObject();
assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
addCost(id, class1, t1, SkillCost.CLASS);
PCClassLevel pcl = new PCClassLevel();
pcl.put(ObjectKey.PARENT, class1);
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, pcl, new Object(), DataFacetChangeEvent.DATA_ADDED);
ListKey<CDOMReference<Skill>> lk = ListKey.LOCALCSKILL;
pcl.addToListFor(lk, CDOMDirectSingleRef.getRef(t1));
getFacet().dataAdded(dfce);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
removeCosts(id, pcl);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
}
use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.
the class VariableFacetTest method testAddEmptyObject.
@Test
public void testAddEmptyObject() {
Object source = new Object();
CDOMObject t1 = new PCTemplate();
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_ADDED);
getFacet().dataAdded(dfce);
VariableKey vk = VariableKey.getConstant("Var1");
assertFalse(getFacet().contains(id, vk));
}
use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.
the class VariableFacetTest method testAddRemove1First.
@Test
public void testAddRemove1First() {
Object source = new Object();
CDOMObject t1 = new PCTemplate();
CDOMObject t2 = new PCTemplate();
VariableKey vk = VariableKey.getConstant("Var1");
t1.put(vk, FormulaFactory.getFormulaFor(2));
t2.put(vk, FormulaFactory.getFormulaFor(4));
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_ADDED);
getFacet().dataAdded(dfce);
assertTrue(getFacet().contains(id, vk));
assertFalse(getFacet().contains(altid, vk));
assertFalse(getFacet().contains(id, VariableKey.getConstant("Var2")));
dfce = new DataFacetChangeEvent<>(id, t2, source, DataFacetChangeEvent.DATA_ADDED);
getFacet().dataAdded(dfce);
assertTrue(getFacet().contains(id, vk));
assertFalse(getFacet().contains(altid, vk));
assertFalse(getFacet().contains(id, VariableKey.getConstant("Var2")));
dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_REMOVED);
getFacet().dataRemoved(dfce);
assertTrue(getFacet().contains(id, vk));
dfce = new DataFacetChangeEvent<>(id, t2, source, DataFacetChangeEvent.DATA_REMOVED);
getFacet().dataRemoved(dfce);
assertFalse(getFacet().contains(id, vk));
}
use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.
the class VariableFacetTest method testUselessRemove.
@Test
public void testUselessRemove() {
Object source = new Object();
CDOMObject t1 = new PCTemplate();
VariableKey vk1 = VariableKey.getConstant("Var1");
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_REMOVED);
getFacet().dataRemoved(dfce);
assertFalse(getFacet().contains(id, vk1));
}
Aggregations