Search in sources :

Example 11 with DataFacetChangeEvent

use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.

the class VariableFacetTest method testAddSameTwo.

@Test
public void testAddSameTwo() {
    Object source = new Object();
    CDOMObject t1 = new PCTemplate();
    VariableKey vk1 = VariableKey.getConstant("Var1");
    VariableKey vk2 = VariableKey.getConstant("Var2");
    t1.put(vk1, FormulaFactory.getFormulaFor(2));
    t1.put(vk2, FormulaFactory.getFormulaFor(4));
    DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_ADDED);
    getFacet().dataAdded(dfce);
    assertTrue(getFacet().contains(id, vk1));
    assertTrue(getFacet().contains(id, vk2));
    assertFalse(getFacet().contains(altid, vk1));
    assertFalse(getFacet().contains(id, VariableKey.getConstant("Var3")));
}
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 12 with DataFacetChangeEvent

use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.

the class VariableFacetTest method testAddSameTwice.

@Test
public void testAddSameTwice() {
    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")));
}
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 13 with DataFacetChangeEvent

use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.

the class VariableFacetTest method testAddRemove2First.

@Test
public void testAddRemove2First() {
    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, t2, source, DataFacetChangeEvent.DATA_REMOVED);
    getFacet().dataRemoved(dfce);
    assertTrue(getFacet().contains(id, vk));
    dfce = new DataFacetChangeEvent<>(id, t1, 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 14 with DataFacetChangeEvent

use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.

the class VariableFacetTest method testAddSimple.

@Test
public void testAddSimple() {
    Object source = new Object();
    CDOMObject t1 = new PCTemplate();
    VariableKey vk = VariableKey.getConstant("Var1");
    t1.put(vk, FormulaFactory.getFormulaFor(2));
    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")));
}
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 15 with DataFacetChangeEvent

use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.

the class LocalSkillCostFacetTest method removeCosts.

private void removeCosts(CharID cid, CDOMObject cl) {
    DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(cid, cl, new Object(), DataFacetChangeEvent.DATA_REMOVED);
    getFacet().dataRemoved(dfce);
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) CDOMObject(pcgen.cdom.base.CDOMObject) CDOMObject(pcgen.cdom.base.CDOMObject) CharID(pcgen.cdom.enumeration.CharID)

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