Test the definition and application of abilities. @throws PersistenceLayerException
()
| 836 | * @throws PersistenceLayerException |
| 837 | */ |
| 838 | @Test |
| 839 | void testAddAbility() throws PersistenceLayerException |
| 840 | { |
| 841 | LoadContext context = Globals.getContext(); |
| 842 | // Create some abilities to be added |
| 843 | AbilityCategory cat = context.getReferenceContext().constructCDOMObject( |
| 844 | AbilityCategory.class, "TestCat"); |
| 845 | Ability ab1 = new Ability(); |
| 846 | ab1.setName("Ability1"); |
| 847 | ab1.setCDOMCategory(cat); |
| 848 | context.getReferenceContext().importObject(ab1); |
| 849 | Ability ab2 = new Ability(); |
| 850 | ab2.setName("Ability2"); |
| 851 | ab2.setCDOMCategory(cat); |
| 852 | context.getReferenceContext().importObject(ab2); |
| 853 | |
| 854 | // Link them to a template |
| 855 | CampaignSourceEntry source; |
| 856 | try |
| 857 | { |
| 858 | source = new CampaignSourceEntry(new Campaign(), |
| 859 | new URI("file:/" + getClass().getName() + ".java")); |
| 860 | } |
| 861 | catch (URISyntaxException e) |
| 862 | { |
| 863 | throw new UnreachableError(e); |
| 864 | } |
| 865 | |
| 866 | String classPCCText = |
| 867 | "CLASS:Cleric HD:8 TYPE:PC TYPE:Base.PC FACT:Abb|Clr ABILITY:TestCat|AUTOMATIC|Ability1\n" |
| 868 | + "CLASS:Cleric STARTSKILLPTS:2\n" |
| 869 | + "2 ABILITY:TestCat|AUTOMATIC|Ability2"; |
| 870 | PCClass pcclass = parsePCClassText(classPCCText, source); |
| 871 | CDOMSingleRef<AbilityCategory> acRef = |
| 872 | context.getReferenceContext().getCDOMReference( |
| 873 | AbilityCategory.class, "TestCat"); |
| 874 | |
| 875 | finishLoad(); |
| 876 | |
| 877 | CDOMReference<AbilityList> autoList = AbilityList.getAbilityListReference(acRef, Nature.AUTOMATIC); |
| 878 | Collection<CDOMReference<Ability>> mods = pcclass.getListMods(autoList); |
| 879 | assertEquals(1, mods.size()); |
| 880 | CDOMReference<Ability> ref = mods.iterator().next(); |
| 881 | Collection<Ability> abilities = ref.getContainedObjects(); |
| 882 | assertEquals(1, abilities.size()); |
| 883 | assertEquals(ab1, abilities.iterator().next()); |
| 884 | Collection<AssociatedPrereqObject> assocs = pcclass.getListAssociations(autoList, ref); |
| 885 | assertEquals(1, assocs.size()); |
| 886 | |
| 887 | PCClassLevel level = pcclass.getOriginalClassLevel(2); |
| 888 | mods = level.getListMods(autoList); |
| 889 | assertEquals(1, mods.size()); |
| 890 | ref = mods.iterator().next(); |
| 891 | abilities = ref.getContainedObjects(); |
| 892 | assertEquals(1, abilities.size()); |
| 893 | assertEquals(ab2, abilities.iterator().next()); |
| 894 | assocs = level.getListAssociations(autoList, ref); |
| 895 | assertEquals(1, assocs.size()); |
nothing calls this directly
no test coverage detected