use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class MigrationLoaderTest method testParseInvalidSourceLine.
@Test
public void testParseInvalidSourceLine() throws Exception {
String sourceMigration = "SOURCE:Bob's Magic Store NEWKEY:XYZ - Bobs Magic Store";
migrationLoader.parseLine(null, sourceMigration, new URI("http://UNIT_TEST_CASE"));
boolean found = false;
List<MigrationRule> migrationRuleList = SystemCollections.getUnmodifiableMigrationRuleList(SettingsHandler.getGame().getName());
for (MigrationRule migrationRule : migrationRuleList) {
if (migrationRule.getObjectType() == ObjectType.SOURCE && migrationRule.getOldKey().equals("Bob's Magic Store")) {
found = true;
}
}
assertFalse("Invalid source line was accepted.", found);
}
use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class MigrationLoaderTest method testParseFirstTokenInValidCharsInSourceKey.
/**
* Check that these invalid characters are rejected in a source key |;.%*=[]
*/
@Test
public void testParseFirstTokenInValidCharsInSourceKey() {
String invalidChars = "|;%*=[]";
for (char invalid : invalidChars.toCharArray()) {
MigrationRule migrationRule = migrationLoader.parseFirstToken("SOURCE:Old" + invalid, "", sourceURI);
assertNull("Key containing " + invalid + " should have been rejected.", migrationRule);
}
}
use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class MigrationLoaderTest method testParseFirstTokenValidSource.
@Test
public void testParseFirstTokenValidSource() {
MigrationRule migrationRule = migrationLoader.parseFirstToken("SOURCE:Old Key", "", sourceURI);
assertNotNull(migrationRule);
assertEquals("Object type", ObjectType.SOURCE, migrationRule.getObjectType());
assertEquals("Old key", "Old Key", migrationRule.getOldKey());
assertNull("Old category", migrationRule.getOldCategory());
}
use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class SourceMigrationTest method setUp.
/**
* @throws java.lang.Exception
*/
@Override
public void setUp() throws Exception {
super.setUp();
gameMode = SettingsHandler.getGame().getName();
MigrationRule sourceRule = new MigrationRule(ObjectType.SOURCE, "OldKey1");
sourceRule.setMaxVer("6.0.1");
sourceRule.setNewKey("NewKey1");
SystemCollections.addToMigrationRulesList(sourceRule, gameMode);
MigrationRule sourceRule2 = new MigrationRule(ObjectType.SOURCE, "OldKey2");
sourceRule2.setMaxVer("6.0.1");
sourceRule2.setMinVer("5.17.7");
sourceRule2.setNewKey("LateNewKey");
SystemCollections.addToMigrationRulesList(sourceRule2, gameMode);
MigrationRule sourceRule2A = new MigrationRule(ObjectType.SOURCE, "OldKey2");
sourceRule2A.setMaxVer("5.16.4");
sourceRule2A.setMaxDevVer("5.17.5");
sourceRule2A.setNewKey("EarlyNewKey");
SystemCollections.addToMigrationRulesList(sourceRule2A, gameMode);
MigrationRule sourceRuleDiffGame = new MigrationRule(ObjectType.SOURCE, "OldKey3");
sourceRuleDiffGame.setMaxVer("6.0.0");
sourceRuleDiffGame.setNewKey("NewKeyModern");
SystemCollections.addToMigrationRulesList(sourceRuleDiffGame, "modern");
}
use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class MigrationLoaderTest method testParseSourceLine.
@Test
public void testParseSourceLine() throws Exception {
String sourceMigration = "SOURCE:Bob's Magic Store NEWKEY:XYZ - Bobs Magic Store MAXVER:5.17.10";
migrationLoader.parseLine(null, sourceMigration, new URI("http://UNIT_TEST_CASE"));
boolean found = false;
List<MigrationRule> migrationRuleList = SystemCollections.getUnmodifiableMigrationRuleList(SettingsHandler.getGame().getName());
for (MigrationRule migrationRule : migrationRuleList) {
if (migrationRule.getObjectType() == ObjectType.SOURCE && migrationRule.getOldKey().equals("Bob's Magic Store")) {
assertNull("new category", migrationRule.getNewCategory());
assertEquals("new key", "XYZ - Bobs Magic Store", migrationRule.getNewKey());
assertEquals("max ver", "5.17.10", migrationRule.getMaxVer());
assertNull("max dev ver", migrationRule.getMaxDevVer());
found = true;
}
}
assertTrue("Unable to find migration rule", found);
}
Aggregations