NMProtoUtils { public static DeletionTask convertProtoToDeletionTask( DeletionServiceDeleteTaskProto proto, DeletionService deletionService) { int taskId = proto.getId(); if (proto.hasTaskType() && proto.getTaskType() != null) { if (proto.getTaskType().equals(DeletionTaskType.FILE.name())) { if (LOG.isDebugEnabled()) { LOG.debug("Converting recovered FileDeletionTask"); } return convertProtoToFileDeletionTask(proto, deletionService, taskId); } else if (proto.getTaskType().equals( DeletionTaskType.DOCKER_CONTAINER.name())) { if (LOG.isDebugEnabled()) { LOG.debug("Converting recovered DockerContainerDeletionTask"); } return convertProtoToDockerContainerDeletionTask(proto, deletionService, taskId); } } if (LOG.isDebugEnabled()) { LOG.debug("Unable to get task type, trying FileDeletionTask"); } return convertProtoToFileDeletionTask(proto, deletionService, taskId); } 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 testConvertProtoToDeletionTask() throws Exception { DeletionService deletionService = mock(DeletionService.class); DeletionServiceDeleteTaskProto.Builder protoBuilder = DeletionServiceDeleteTaskProto.newBuilder(); int id = 0; protoBuilder.setId(id); DeletionServiceDeleteTaskProto proto = protoBuilder.build(); DeletionTask deletionTask = NMProtoUtils.convertProtoToDeletionTask(proto, deletionService); assertEquals(DeletionTaskType.FILE, deletionTask.getDeletionTaskType()); assertEquals(id, deletionTask.getTaskId()); }