1 15 package hivemind.test.rules; 16 17 import org.apache.hivemind.internal.Module; 18 import org.apache.hivemind.schema.Translator; 19 import org.apache.hivemind.schema.rules.IdListTranslator; 20 import org.apache.hivemind.schema.rules.QualifiedIdTranslator; 21 import org.apache.hivemind.test.HiveMindTestCase; 22 import org.easymock.MockControl; 23 24 30 public class TestIdTranslators extends HiveMindTestCase 31 { 32 public void testNullId() 33 { 34 Translator t = new QualifiedIdTranslator(); 35 36 assertNull(t.translate(null, null, null, null)); 37 } 38 39 private Module getModule() 40 { 41 MockControl c = newControl(Module.class); 42 Module result = (Module) c.getMock(); 43 44 result.getModuleId(); 45 c.setReturnValue("foo.bar"); 46 47 return result; 48 } 49 50 public void testNonNullId() 51 { 52 Module m = getModule(); 53 54 replayControls(); 55 56 Translator t = new QualifiedIdTranslator(); 57 58 assertEquals("foo.bar.Baz", t.translate(m, null, "Baz", null)); 59 60 verifyControls(); 61 } 62 63 public void testNullList() 64 { 65 Translator t = new IdListTranslator(); 66 67 assertEquals(null, t.translate(null, null, null, null)); 68 } 69 70 public void testNonNullList() 71 { 72 Module m = getModule(); 73 74 replayControls(); 75 76 Translator t = new IdListTranslator(); 77 78 assertEquals("foo.bar.Baz,zip.Zap", t.translate(m, null, "Baz,zip.Zap", null)); 79 80 verifyControls(); 81 } 82 } 83 | Popular Tags |