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));
}
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));
}
Aggregations