public static NamenodeRole convert(NamenodeRoleProto role) {
    switch (role) {
    case NAMENODE:
      return NamenodeRole.NAMENODE;
    case BACKUP:
      return NamenodeRole.BACKUP;
    case CHECKPOINT:
      return NamenodeRole.CHECKPOINT;
    }
    return null;
  }
@Test
  public void testConvertBlocksWithLocations() {
    boolean[] testSuite = new boolean[]{false, true};
    for (int i = 0; i < testSuite.length; i++) {
      BlockWithLocations[] list = new BlockWithLocations[]{
          getBlockWithLocations(1, testSuite[i]),
          getBlockWithLocations(2, testSuite[i])};
      BlocksWithLocations locs = new BlocksWithLocations(list);
      BlocksWithLocationsProto locsProto = PBHelper.convert(locs);
      BlocksWithLocations locs2 = PBHelper.convert(locsProto);
      BlockWithLocations[] blocks = locs.getBlocks();
      BlockWithLocations[] blocks2 = locs2.getBlocks();
      assertEquals(blocks.length, blocks2.length);
      for (int j = 0; j < blocks.length; j++) {
        compare(blocks[j], blocks2[j]);
      }
    }
  }