Search in sources :

Example 1 with DataFacetChangeEvent

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!
    }
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) Skill(pcgen.core.Skill) CDOMObject(pcgen.cdom.base.CDOMObject) CDOMObject(pcgen.cdom.base.CDOMObject) CharID(pcgen.cdom.enumeration.CharID) CDOMReference(pcgen.cdom.base.CDOMReference) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 2 with DataFacetChangeEvent

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));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) Skill(pcgen.core.Skill) CDOMObject(pcgen.cdom.base.CDOMObject) CDOMObject(pcgen.cdom.base.CDOMObject) CharID(pcgen.cdom.enumeration.CharID) CDOMReference(pcgen.cdom.base.CDOMReference) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 3 with DataFacetChangeEvent

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));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) CDOMObject(pcgen.cdom.base.CDOMObject) VariableKey(pcgen.cdom.enumeration.VariableKey) CDOMObject(pcgen.cdom.base.CDOMObject) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID) Test(org.junit.Test)

Example 4 with DataFacetChangeEvent

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));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) CDOMObject(pcgen.cdom.base.CDOMObject) VariableKey(pcgen.cdom.enumeration.VariableKey) CDOMObject(pcgen.cdom.base.CDOMObject) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID) Test(org.junit.Test)

Example 5 with DataFacetChangeEvent

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));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) CDOMObject(pcgen.cdom.base.CDOMObject) VariableKey(pcgen.cdom.enumeration.VariableKey) CDOMObject(pcgen.cdom.base.CDOMObject) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID) Test(org.junit.Test)

Aggregations

CDOMObject (pcgen.cdom.base.CDOMObject)17 CharID (pcgen.cdom.enumeration.CharID)17 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)17 Test (org.junit.Test)15 VariableKey (pcgen.cdom.enumeration.VariableKey)8 PCTemplate (pcgen.core.PCTemplate)8 CDOMReference (pcgen.cdom.base.CDOMReference)4 AbstractExtractingFacetTest (pcgen.cdom.testsupport.AbstractExtractingFacetTest)4 PCClassLevel (pcgen.cdom.inst.PCClassLevel)3 Skill (pcgen.core.Skill)3