Search in sources :

Example 11 with MigrationRule

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);
}
Also used : MigrationRule(pcgen.core.system.MigrationRule) URI(java.net.URI) Test(org.junit.Test)

Example 12 with MigrationRule

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);
    }
}
Also used : MigrationRule(pcgen.core.system.MigrationRule) Test(org.junit.Test)

Example 13 with 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());
}
Also used : MigrationRule(pcgen.core.system.MigrationRule) Test(org.junit.Test)

Example 14 with MigrationRule

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");
}
Also used : MigrationRule(pcgen.core.system.MigrationRule)

Example 15 with MigrationRule

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);
}
Also used : MigrationRule(pcgen.core.system.MigrationRule) URI(java.net.URI) Test(org.junit.Test)

Aggregations

MigrationRule (pcgen.core.system.MigrationRule)25 Test (org.junit.Test)12 Before (org.junit.Before)6 URI (java.net.URI)3 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 UnreachableError (pcgen.base.lang.UnreachableError)1 ObjectType (pcgen.core.system.MigrationRule.ObjectType)1