NMProtoUtils { public static FileDeletionTask convertProtoToFileDeletionTask( DeletionServiceDeleteTaskProto proto, DeletionService deletionService, int taskId) { String user = proto.hasUser() ? proto.getUser() : null; Path subdir = null; if (proto.hasSubdir()) { subdir = new Path(proto.getSubdir()); } List<Path> basePaths = null; List<String> basedirs = proto.getBasedirsList(); if (basedirs != null && basedirs.size() > 0) { basePaths = new ArrayList<>(basedirs.size()); for (String basedir : basedirs) { basePaths.add(new Path(basedir)); } } return new FileDeletionTask(taskId, deletionService, user, subdir, basePaths); } private  NMProtoUtils(); static DeletionTask convertProtoToDeletionTask(
      DeletionServiceDeleteTaskProto proto, DeletionService deletionService); static FileDeletionTask convertProtoToFileDeletionTask(
      DeletionServiceDeleteTaskProto proto, DeletionService deletionService,
      int taskId); static DockerContainerDeletionTask convertProtoToDockerContainerDeletionTask(
      DeletionServiceDeleteTaskProto proto, DeletionService deletionService,
      int taskId); static DeletionTaskRecoveryInfo convertProtoToDeletionTaskRecoveryInfo(
      DeletionServiceDeleteTaskProto proto, DeletionService deletionService);  }
@Test public void testConvertProtoToFileDeletionTask() throws Exception { DeletionService deletionService = mock(DeletionService.class); int id = 0; String user = "user"; Path subdir = new Path("subdir"); Path basedir = new Path("basedir"); DeletionServiceDeleteTaskProto.Builder protoBuilder = DeletionServiceDeleteTaskProto.newBuilder(); protoBuilder .setId(id) .setUser("user") .setSubdir(subdir.getName()) .addBasedirs(basedir.getName()); DeletionServiceDeleteTaskProto proto = protoBuilder.build(); DeletionTask deletionTask = NMProtoUtils.convertProtoToFileDeletionTask(proto, deletionService, id); assertEquals(DeletionTaskType.FILE.name(), deletionTask.getDeletionTaskType().name()); assertEquals(id, deletionTask.getTaskId()); assertEquals(subdir, ((FileDeletionTask) deletionTask).getSubDir()); assertEquals(basedir, ((FileDeletionTask) deletionTask).getBaseDirs().get(0)); }