TraceCategoryRegistry implements ITraceCategoryRegistry { @Override public String getName(long categoryCode) { if (CATEGORIES_ALL == categoryCode) { return CATEGORIES_ALL_NAME; } if (categoryCode == 0) { throw new IllegalArgumentException("Illegal category code " + categoryCode); } int postition = mostSignificantBit(categoryCode); if (postition >= bitPos) { throw new IllegalArgumentException("No category for code " + categoryCode); } return nameAt(postition); } TraceCategoryRegistry(); @Override long get(String name); @Override String getName(long categoryCode); String nameAt(int n); static int mostSignificantBit(long n); @Override String toString();  }
@Test public void getNameInvalidCode() { TraceCategoryRegistry registry = new TraceCategoryRegistry(); final String expectedError = "No category for code"; String actualError = null; try { registry.getName(11); } catch (IllegalArgumentException iae) { actualError = iae.getMessage(); } Assert.assertTrue(actualError.contains(expectedError)); }