public static ReservationDefinition convertReservationDefinition(
      ReservationDefinitionInfo definitionInfo) {
    if (definitionInfo == null || definitionInfo.getReservationRequests() == null
        || definitionInfo.getReservationRequests().getReservationRequest() == null
        || definitionInfo.getReservationRequests().getReservationRequest().isEmpty()) {
      throw new RuntimeException("definitionInfo Or ReservationRequests is Null.");
    }

    // basic variable
    long arrival = definitionInfo.getArrival();
    long deadline = definitionInfo.getDeadline();

    // ReservationRequests reservationRequests
    String name = definitionInfo.getReservationName();
    String recurrenceExpression = definitionInfo.getRecurrenceExpression();
    Priority priority = Priority.newInstance(definitionInfo.getPriority());

    // reservation requests info
    List<ReservationRequest> reservationRequestList = new ArrayList<>();

    ReservationRequestsInfo reservationRequestsInfo = definitionInfo.getReservationRequests();

    List<ReservationRequestInfo> reservationRequestInfos =
        reservationRequestsInfo.getReservationRequest();

    for (ReservationRequestInfo resRequestInfo : reservationRequestInfos) {
      ResourceInfo resourceInfo = resRequestInfo.getCapability();
      Resource capability =
          Resource.newInstance(resourceInfo.getMemorySize(), resourceInfo.getvCores());
      ReservationRequest reservationRequest = ReservationRequest.newInstance(capability,
          resRequestInfo.getNumContainers(), resRequestInfo.getMinConcurrency(),
          resRequestInfo.getDuration());
      reservationRequestList.add(reservationRequest);
    }

    ReservationRequestInterpreter[] values = ReservationRequestInterpreter.values();
    ReservationRequestInterpreter reservationRequestInterpreter =
        values[reservationRequestsInfo.getReservationRequestsInterpreter()];
    ReservationRequests reservationRequests = ReservationRequests.newInstance(
        reservationRequestList, reservationRequestInterpreter);

    ReservationDefinition definition = ReservationDefinition.newInstance(
        arrival, deadline, reservationRequests, name, recurrenceExpression, priority);

    return definition;
  }
@Test
  public void testConvertReservationDefinition() {
    // Prepare parameters
    ReservationId reservationId = ReservationId.newInstance(Time.now(), 1);
    ReservationSubmissionRequestInfo requestInfo =
        getReservationSubmissionRequestInfo(reservationId);
    ReservationDefinitionInfo expectDefinitionInfo = requestInfo.getReservationDefinition();

    // ReservationDefinitionInfo conversion ReservationDefinition
    ReservationDefinition convertDefinition =
        RouterServerUtil.convertReservationDefinition(expectDefinitionInfo);

    // reservationDefinition is not null
    assertNotNull(convertDefinition);
    assertEquals(expectDefinitionInfo.getArrival(), convertDefinition.getArrival());
    assertEquals(expectDefinitionInfo.getDeadline(), convertDefinition.getDeadline());

    Priority priority = convertDefinition.getPriority();
    assertNotNull(priority);
    assertEquals(expectDefinitionInfo.getPriority(), priority.getPriority());
    assertEquals(expectDefinitionInfo.getRecurrenceExpression(),
        convertDefinition.getRecurrenceExpression());
    assertEquals(expectDefinitionInfo.getReservationName(), convertDefinition.getReservationName());

    ReservationRequestsInfo expectRequestsInfo = expectDefinitionInfo.getReservationRequests();
    List<ReservationRequestInfo> expectRequestsInfoList =
        expectRequestsInfo.getReservationRequest();

    ReservationRequests convertReservationRequests =
        convertDefinition.getReservationRequests();
    assertNotNull(convertReservationRequests);

    List<ReservationRequest> convertRequestList =
        convertReservationRequests.getReservationResources();
    assertNotNull(convertRequestList);
    assertEquals(1, convertRequestList.size());

    ReservationRequestInfo expectResRequestInfo = expectRequestsInfoList.get(0);
    ReservationRequest convertResRequest = convertRequestList.get(0);
    assertNotNull(convertResRequest);
    assertEquals(expectResRequestInfo.getNumContainers(), convertResRequest.getNumContainers());
    assertEquals(expectResRequestInfo.getDuration(), convertResRequest.getDuration());

    ResourceInfo expectResourceInfo = expectResRequestInfo.getCapability();
    Resource convertResource = convertResRequest.getCapability();
    assertNotNull(expectResourceInfo);
    assertEquals(expectResourceInfo.getMemorySize(), convertResource.getMemorySize());
    assertEquals(expectResourceInfo.getvCores(), convertResource.getVirtualCores());
  }