/**
   * Assert if the FileOrdered have been copied It gets the list of files from the order, and gets
   * the file described in the list of files
   *
   * @param order the order to assert
   * @param nbFileCopied the expected number of files to be copied
   */
  private void assertFileOrderedExists(Order order, int nbFileCopied) {
    assertNotNull(order);
    assertNotNull(order.getResourceCollection());

    assertEquals(1, order.getResourceCollection().size());
    Representation result = null;
    try {

      String res = order.getResourceCollection().get(0);

      ClientResource cr = new ClientResource(res);

      ChallengeResponse chal =
          new ChallengeResponse(ChallengeScheme.HTTP_BASIC, userLogin, password);

      cr.setChallengeResponse(chal);

      result = cr.get(getMediaTest());

      assertNotNull(result);
      assertTrue(cr.getStatus().isSuccess());

      try {
        // get the list of files
        String text = result.getText();
        String[] contents = text.split("\r\n");
        assertNotNull(contents);
        assertEquals(nbFileCopied, contents.length);
        Reference content = new Reference(contents[0]);
        // asserts
        assertNotNull(content);
        assertNotSame("", content.toString());
        // get the file corresponding to the first url, check that this file
        // exists
        cr = new ClientResource(content);

        chal = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, userLogin, password);

        cr.setChallengeResponse(chal);

        result = cr.get(getMediaTest());
        assertNotNull(result);
        assertTrue(cr.getStatus().isSuccess());

      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } finally {
        RIAPUtils.exhaust(result);
      }

    } finally {
      RIAPUtils.exhaust(result);
    }
  }
  /**
   * Delete the given Order
   *
   * @param order the order to delete
   */
  protected void deleteOrder(Order order) {
    // TODO Auto-generated method stub
    String url = getOrderUrl() + "/" + order.getId();

    ClientResource cr = new ClientResource(url);
    ChallengeResponse chal = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, userLogin, password);

    cr.setChallengeResponse(chal);

    Representation result = cr.delete(getMediaTest());
    assertNotNull(result);
    assertTrue(cr.getStatus().isSuccess());
    Response response = getResponseOrderandUserstorage(getMediaTest(), result, Order.class);
    assertTrue(response.getSuccess());
    result.release();
  }
 /**
  * Assert if the order exists and is done
  *
  * @param order The order
  */
 protected void assertOrderDone(Order order) {
   assertNotNull(order);
   assertEquals("done", order.getStatus());
 }