/** * Tests translation of HBase qualifiers have multiple separators (the Kiji qualifier contains the * separator). */ @Test public void testMultipleSeparators() throws Exception { KijiColumnName kijiColumnName = mTranslator.toKijiColumnName(getHBaseColumnName("inMemory", "purchases:left:right")); assertEquals("purchases", kijiColumnName.getFamily()); assertEquals("left:right", kijiColumnName.getQualifier()); }
@Before public void readLayout() throws Exception { final KijiTableLayout tableLayout = KijiTableLayout.newLayout( KijiTableLayouts.getLayout(KijiTableLayouts.FULL_FEATURED_IDENTITY)); mTranslator = HBaseColumnNameTranslator.from(tableLayout); }
@Test public void testTranslateFromHBaseToKiji() throws Exception { KijiColumnName infoName = mTranslator.toKijiColumnName(getHBaseColumnName("default", "info:name")); assertEquals("info:name", infoName.toString()); KijiColumnName infoEmail = mTranslator.toKijiColumnName(getHBaseColumnName("default", "info:email")); assertEquals("info:email", infoEmail.toString()); KijiColumnName recommendationsProduct = mTranslator.toKijiColumnName(getHBaseColumnName("inMemory", "recommendations:product")); assertEquals("recommendations:product", recommendationsProduct.toString()); KijiColumnName purchases = mTranslator.toKijiColumnName(getHBaseColumnName("inMemory", "purchases:foo")); assertEquals("purchases:foo", purchases.toString()); }
@Test public void testTranslateFromKijiToHBase() throws Exception { HBaseColumnName infoName = mTranslator.toHBaseColumnName(KijiColumnName.create("info:name")); assertEquals("default", infoName.getFamilyAsString()); assertEquals("info:name", infoName.getQualifierAsString()); HBaseColumnName infoEmail = mTranslator.toHBaseColumnName(KijiColumnName.create("info:email")); assertEquals("default", infoEmail.getFamilyAsString()); assertEquals("info:email", infoEmail.getQualifierAsString()); HBaseColumnName recommendationsProduct = mTranslator.toHBaseColumnName(KijiColumnName.create("recommendations:product")); assertEquals("inMemory", recommendationsProduct.getFamilyAsString()); assertEquals("recommendations:product", recommendationsProduct.getQualifierAsString()); HBaseColumnName purchases = mTranslator.toHBaseColumnName(KijiColumnName.create("purchases:foo")); assertEquals("inMemory", purchases.getFamilyAsString()); assertEquals("purchases:foo", purchases.getQualifierAsString()); }
/** * Tests that an exception is thrown when the first part of the HBase qualifier doesn't match a * Kiji family. */ @Test(expected = NoSuchColumnException.class) public void testNoSuchKijiFamily() throws Exception { mTranslator.toKijiColumnName(getHBaseColumnName("inMemory", "fakeFamily:fakeQualifier")); }
/** * Tests that an exception is thrown when the HBase family doesn't match a Kiji locality group. */ @Test(expected = NoSuchColumnException.class) public void testNoSuchKijiLocalityGroup() throws Exception { mTranslator.toKijiColumnName( getHBaseColumnName("fakeLocalityGroup", "fakeFamily:fakeQualifier")); }
/** Tests that an exception is thrown when trying to translate a non-existent Kiji column. */ @Test(expected = NoSuchColumnException.class) public void testNoSuchHBaseColumn() throws Exception { mTranslator.toHBaseColumnName(KijiColumnName.create("doesnt:exist")); }