@Test
 public void testIdVariable() throws Exception {
   String xml = "<charm id=\"otherTest\"/>";
   Element rootElement = DocumentUtilities.read(xml).getRootElement();
   String id = builder.build(rootElement);
   assertEquals("otherTest", id);
 }
 @Test
 public void testTraitPrerequisiteBuilder() throws Exception {
   String xml = "<trait id=\"Larceny\" value=\"3\"/>";
   Element rootElement = DocumentUtilities.read(xml).getRootElement();
   GenericTrait trait = builder.build(rootElement);
   assertEquals(AbilityType.Larceny, trait.getType());
   assertEquals(3, trait.getCurrentValue());
 }
 @Test
 public void testDefaultFreePicksPredicate() throws Exception {
   Element templateElement = DocumentUtilities.read(xml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   assertTrue(
       template.canBuyFromFreePicks(
           DummyCharmUtilities.createCharm("TestCharm", "Group"))); // $NON-NLS-1$ //$NON-NLS-2$
 }
 @Test
 public void testMortalCharmTemplate() throws Exception {
   Element templateElement = DocumentUtilities.read(xml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   ICharmTemplate charmTemplate = template.getCharmTemplate();
   assertEquals(MartialArtsLevel.Mortal, charmTemplate.getMartialArtsRules().getStandardLevel());
   assertFalse(charmTemplate.canLearnCharms());
 }
 @Test
 public void testGenericAttributes() throws Exception {
   String xml = "<charm><genericCharmAttribute attribute=\"test\"/></charm>"; // $NON-NLS-1$
   Element rootElement = DocumentUtilities.read(xml).getRootElement();
   ICharmAttribute[] attribute =
       new CharmAttributeBuilder()
           .buildCharmAttributes(rootElement, new ValuedTraitType(AbilityType.Brawl, 3));
   assertTrue(
       ArrayUtilities.containsValue(
           attribute, new CharmAttribute("testBrawl", false))); // $NON-NLS-1$
 }
 @Test
 public void testFavoringTraitTypeModified() throws Exception {
   String typeXml =
       "<magicTemplate>" //$NON-NLS-1$
           + "<freePicksPredicate type=\"Default\"/>" //$NON-NLS-1$
           + "<favoringTraitType type =\"AttributeType\"/>" //$NON-NLS-1$
           + "</magicTemplate>"; //$NON-NLS-1$
   Element templateElement = DocumentUtilities.read(typeXml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   assertEquals(FavoringTraitType.AttributeType, template.getFavoringTraitType());
 }
 @Test
 public void picksUpMartialArtsRules() throws Exception {
   String celestialXml =
       "<magicTemplate>"
           + //$NON-NLS-1$
           "<charmTemplate charmType=\"None\" ><martialArts rulesClass=\"net.sf.anathema.character.generic.dummy.magic.DummyMartialArtsRules\" level=\"Terrestrial\" /></charmTemplate>" //$NON-NLS-1$
           + "</magicTemplate>"; //$NON-NLS-1$
   Element templateElement = DocumentUtilities.read(celestialXml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   Assert.assertTrue(
       template.getCharmTemplate().getMartialArtsRules() instanceof DummyMartialArtsRules);
 }
 @Test
 public void testDefaultRulesSetting() throws Exception {
   String celestialXml =
       "<magicTemplate>"
           + //$NON-NLS-1$
           "<charmTemplate charmType=\"None\" ><martialArts level=\"Terrestrial\" /></charmTemplate>" //$NON-NLS-1$
           + "</magicTemplate>"; //$NON-NLS-1$
   Element templateElement = DocumentUtilities.read(celestialXml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   Assert.assertTrue(
       template.getCharmTemplate().getMartialArtsRules() instanceof DefaultMartialArtsRules);
 }
 @Test
 public void testFalseFreePicksPredicate() throws Exception {
   String customXml =
       "<magicTemplate>" //$NON-NLS-1$
           + "<freePicksPredicate defaultResponse=\"false\"/>" //$NON-NLS-1$
           + "<charmTemplate charmType=\"None\">" //$NON-NLS-1$
           + "<martialArts level=\"Mortal\"/></charmTemplate>" //$NON-NLS-1$
           + "<spellTemplate maximumSorceryCircle=\"None\" maximumNecromancyCircle=\"None\"/>" //$NON-NLS-1$
           + "</magicTemplate>"; //$NON-NLS-1$
   Element templateElement = DocumentUtilities.read(customXml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   assertFalse(
       template.canBuyFromFreePicks(
           DummyCharmUtilities.createCharm("TestCharm", "Group"))); // $NON-NLS-1$ //$NON-NLS-2$
 }
 @Test
 public void testAlienCharmsAllowed() throws Exception {
   String typeXml =
       "<magicTemplate>" //$NON-NLS-1$
           + "<charmTemplate charmType=\"None\">" //$NON-NLS-1$
           + " <alienCharms> <caste type=\"DummyCaste\"/></alienCharms>" //$NON-NLS-1$
           + "<martialArts level=\"Celestial\" highLevel=\"false\" />" //$NON-NLS-1$
           + "</charmTemplate>" //$NON-NLS-1$
           + "</magicTemplate>"; //$NON-NLS-1$
   Element templateElement = DocumentUtilities.read(typeXml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   assertTrue(
       template
           .getCharmTemplate()
           .isAllowedAlienCharms(new DummyCasteType("DummyCaste"))); // $NON-NLS-1$
 }
 @Test
 public void testParsesMaximumNecromancyCircle() throws Exception {
   String celestialXml =
       "<magicTemplate>"
           + //$NON-NLS-1$
           "<spellTemplate maximumSorceryCircle=\"Solar\" maximumNecromancyCircle=\"Labyrinth\"/>" //$NON-NLS-1$
           + "</magicTemplate>"; //$NON-NLS-1$
   Element templateElement = DocumentUtilities.read(celestialXml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   assertTrue(
       net.sf.anathema.lib.lang.ArrayUtilities.containsValue(
           template.getSpellMagic().getNecromancyCircles(), CircleType.Shadowlands));
   assertTrue(
       net.sf.anathema.lib.lang.ArrayUtilities.containsValue(
           template.getSpellMagic().getNecromancyCircles(), CircleType.Labyrinth));
   assertFalse(
       net.sf.anathema.lib.lang.ArrayUtilities.containsValue(
           template.getSpellMagic().getNecromancyCircles(), CircleType.Void));
 }
 @Test
 public void testHighLevelSettingModified() throws Exception {
   String celestialXml =
       "<magicTemplate>"
           + //$NON-NLS-1$
           "<charmTemplate charmType=\"None\" ><martialArts level=\"Terrestrial\" highLevel=\"true\"/></charmTemplate>" //$NON-NLS-1$
           + "</magicTemplate>"; //$NON-NLS-1$
   Element templateElement = DocumentUtilities.read(celestialXml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   DummyCharm dummyMartialArtsCharm = new DummyCharm("Dummy") { // $NON-NLS-1$
         @Override
         public boolean hasAttribute(Identified attribute) {
           return attribute.getId().equals("MartialArts")
               || attribute.getId().equals("Celestial"); // $NON-NLS-1$ //$NON-NLS-2$
         }
       };
   assertTrue(
       template
           .getCharmTemplate()
           .getMartialArtsRules()
           .isCharmAllowed(dummyMartialArtsCharm, null, false));
 }
Example #13
0
 @Test(expected = CharmException.class)
 public void testBadId() throws Exception {
   String xml = "<charm id=\"\"/>";
   Element rootElement = DocumentUtilities.read(xml).getRootElement();
   builder.build(rootElement);
 }
 @Test
 public void testFavoringTraitTypeUnmodified() throws Exception {
   Element templateElement = DocumentUtilities.read(xml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   assertEquals(FavoringTraitType.AbilityType, template.getFavoringTraitType());
 }
 @Test
 public void testMortalSpellTemplate() throws Exception {
   Element templateElement = DocumentUtilities.read(xml).getRootElement();
   GenericMagicTemplate template = parser.parseTemplate(templateElement);
   assertFalse(template.getSpellMagic().canLearnSpellMagic());
 }
 @Test(expected = PersistenceException.class)
 public void testValueMissing() throws Exception {
   String xml = "<trait id=\"Larceny\" />";
   Element rootElement = DocumentUtilities.read(xml).getRootElement();
   builder.build(rootElement);
 }
 private GenericPresentationTemplate parseXml(String xmlCode) throws AnathemaException {
   Element templateElement = DocumentUtilities.read(xmlCode).getRootElement();
   return parser.parseTemplate(templateElement);
 }