Helps Junit tests
| 91 | * Helps Junit tests |
| 92 | */ |
| 93 | @SuppressWarnings("nls") |
| 94 | public final class TestHelper |
| 95 | { |
| 96 | private static final Logger LOG = Logger.getLogger(TestHelper.class.getName()); |
| 97 | |
| 98 | private static boolean loaded = false; |
| 99 | private static final LstObjectFileLoader<Equipment> eqLoader = new GenericLoader<>(Equipment.class); |
| 100 | private static final LstObjectFileLoader<Ability> abLoader = new AbilityLoader(); |
| 101 | private static CampaignSourceEntry source; |
| 102 | |
| 103 | private TestHelper() |
| 104 | { |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Make some size adjustments |
| 109 | */ |
| 110 | public static void makeSizeAdjustments() |
| 111 | { |
| 112 | final String sizes = |
| 113 | "Fine|Diminutive|Tiny|Small|Medium|Large|Huge|Gargantuan|Colossal"; |
| 114 | final StringTokenizer aTok = new StringTokenizer(sizes, "|"); |
| 115 | GameMode gamemode = SystemCollections.getGameModeNamed("3.5"); |
| 116 | if (gamemode == null) |
| 117 | { |
| 118 | gamemode = new GameMode("3.5"); |
| 119 | SystemCollections.addToGameModeList(gamemode); |
| 120 | GameModeFileLoader.addDefaultTabInfo(gamemode); |
| 121 | } |
| 122 | SettingsHandler.setGame("3.5"); |
| 123 | int count = 0; |
| 124 | while (aTok.hasMoreTokens()) |
| 125 | { |
| 126 | SizeAdjustment sa = BuildUtilities.createSize(aTok.nextToken(), count++); |
| 127 | Globals.getContext().getReferenceContext().importObject(sa); |
| 128 | } |
| 129 | Globals.getContext().getReferenceContext() |
| 130 | .silentlyGetConstructedCDOMObject(SizeAdjustment.class, "M").put( |
| 131 | ObjectKey.IS_DEFAULT_SIZE, true); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Make some equipment |
| 136 | * @param input Equipment source line to be parsed |
| 137 | * @return true if OK |
| 138 | */ |
| 139 | public static boolean makeEquipment(final String input) |
| 140 | { |
| 141 | loadPlugins(); |
| 142 | try |
| 143 | { |
| 144 | final CampaignSourceEntry source = createSource(TestHelper.class); |
| 145 | eqLoader.parseLine(Globals.getContext(), null, input, source); |
| 146 | return true; |
| 147 | } catch (Exception e) |
| 148 | { |
| 149 | // TODO Deal with Exception? |
| 150 | } |