Search in sources :

Example 1 with ClassLevelObjectChangeEvent

use of pcgen.cdom.facet.model.ClassFacet.ClassLevelObjectChangeEvent in project pcgen by PCGen.

the class ClassFacetTest method testSetClassLevel.

@Test
public void testSetClassLevel() {
    PCClass t1 = new PCClass();
    facet.addClass(id, t1);
    PCClassLevel pcl = new PCClassLevel();
    pcl.put(IntegerKey.LEVEL, 3);
    PCClassLevel old = facet.getClassLevel(id, t1, 3);
    try {
        assertTrue(facet.setClassLevel(id, t1, pcl));
        ClassLevelObjectChangeEvent event = classListener.lastLevelObjectEvent;
        assertSame(id, event.getCharID());
        assertEquals(t1, event.getPCClass());
        assertEquals(old, event.getOldLevel());
        assertEquals(pcl, event.getNewLevel());
    } catch (CloneNotSupportedException e) {
        fail(e.getMessage());
    }
    assertEquals(pcl, facet.getClassLevel(id, t1, 3));
}
Also used : ClassLevelObjectChangeEvent(pcgen.cdom.facet.model.ClassFacet.ClassLevelObjectChangeEvent) PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 2 with ClassLevelObjectChangeEvent

use of pcgen.cdom.facet.model.ClassFacet.ClassLevelObjectChangeEvent in project pcgen by PCGen.

the class ClassFacetTest method testSetClassLevelUseless.

@Test
public void testSetClassLevelUseless() {
    PCClass t1 = new PCClass();
    facet.addClass(id, t1);
    PCClassLevel pcl = new PCClassLevel();
    pcl.put(IntegerKey.LEVEL, 3);
    PCClassLevel old = facet.getClassLevel(id, t1, 3);
    assertEquals(0, classListener.addEventObjectCount);
    try {
        assertTrue(facet.setClassLevel(id, t1, pcl));
        ClassLevelObjectChangeEvent event = classListener.lastLevelObjectEvent;
        assertSame(id, event.getCharID());
        assertEquals(t1, event.getPCClass());
        assertEquals(old, event.getOldLevel());
        assertEquals(pcl, event.getNewLevel());
    } catch (CloneNotSupportedException e) {
        fail(e.getMessage());
    }
    assertEquals(1, classListener.addEventObjectCount);
    //Now useless but still returns true
    try {
        assertTrue(facet.setClassLevel(id, t1, pcl));
    } catch (CloneNotSupportedException e) {
        fail(e.getMessage());
    }
    //Guarantee no new event
    assertEquals(1, classListener.addEventObjectCount);
    assertEquals(pcl, facet.getClassLevel(id, t1, 3));
}
Also used : ClassLevelObjectChangeEvent(pcgen.cdom.facet.model.ClassFacet.ClassLevelObjectChangeEvent) PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ClassLevelObjectChangeEvent (pcgen.cdom.facet.model.ClassFacet.ClassLevelObjectChangeEvent)2 PCClassLevel (pcgen.cdom.inst.PCClassLevel)2 PCClass (pcgen.core.PCClass)2