/**
   * Test method for {@link org.bonitasoft.engine.command.api.impl.CommandServiceImpl#get(long)}.
   *
   * @throws SCommandNotFoundException
   * @throws SBonitaReadException
   */
  @Test
  public final void getById() throws SCommandNotFoundException, SBonitaReadException {
    final SCommand sCommand = mock(SCommand.class);
    when(persistence.selectById(any(SelectByIdDescriptor.class))).thenReturn(sCommand);

    Assert.assertEquals(sCommand, commandServiceImpl.get(456L));
  }
  @Test(expected = SCommandNotFoundException.class)
  public final void getByIdThrowException() throws SBonitaReadException, SCommandNotFoundException {
    when(persistence.selectById(any(SelectByIdDescriptor.class)))
        .thenThrow(new SBonitaReadException(""));

    commandServiceImpl.get(456L);
  }
  @Test(expected = SCommandGettingException.class)
  public final void getAllCommandsThrowException()
      throws SCommandGettingException, SBonitaReadException {
    when(persistence.selectList(any(SelectListDescriptor.class)))
        .thenThrow(new SBonitaReadException(""));

    commandServiceImpl.getAllCommands(0, 1, SCommandCriterion.NAME_DESC);
  }
  /**
   * Test method for {@link
   * org.bonitasoft.engine.command.api.impl.CommandServiceImpl#getAllCommands(int, int,
   * org.bonitasoft.engine.command.model.SCommandCriterion)}.
   *
   * @throws SCommandGettingException
   * @throws SBonitaReadException
   */
  @Test
  public final void getAllCommands() throws SCommandGettingException, SBonitaReadException {
    final List<SCommand> sCommands = new ArrayList<SCommand>();
    when(persistence.selectList(any(SelectListDescriptor.class))).thenReturn(sCommands);

    Assert.assertEquals(
        sCommands, commandServiceImpl.getAllCommands(0, 1, SCommandCriterion.NAME_ASC));
  }
  /**
   * Test method for {@link
   * org.bonitasoft.engine.command.api.impl.CommandServiceImpl#searchCommands(org.bonitasoft.engine.persistence.QueryOptions)}.
   *
   * @throws SBonitaSearchException
   * @throws SBonitaReadException
   */
  @Test
  public final void searchCommands() throws SBonitaSearchException, SBonitaReadException {
    final List<SCommand> sCommands = new ArrayList<SCommand>();
    final QueryOptions options = mock(QueryOptions.class);
    when(persistence.searchEntity(SCommand.class, options, null)).thenReturn(sCommands);

    Assert.assertEquals(sCommands, commandServiceImpl.searchCommands(options));
  }
  @Test(expected = SBonitaSearchException.class)
  public final void searchCommandsThrowException()
      throws SBonitaSearchException, SBonitaReadException {
    final QueryOptions options = mock(QueryOptions.class);
    when(persistence.searchEntity(SCommand.class, options, null))
        .thenThrow(new SBonitaReadException(""));

    commandServiceImpl.searchCommands(options);
  }
  /**
   * Test method for {@link
   * org.bonitasoft.engine.command.api.impl.CommandServiceImpl#getNumberOfCommands(org.bonitasoft.engine.persistence.QueryOptions)}.
   *
   * @throws SBonitaSearchException
   * @throws SBonitaReadException
   */
  @Test
  public final void getNumberOfCommands() throws SBonitaSearchException, SBonitaReadException {
    final long numberOfCommands = 54165L;
    final QueryOptions options = mock(QueryOptions.class);
    when(persistence.getNumberOfEntities(SCommand.class, options, null))
        .thenReturn(numberOfCommands);

    Assert.assertEquals(numberOfCommands, commandServiceImpl.getNumberOfCommands(options));
  }
  @Test(expected = SCommandNotFoundException.class)
  public final void getByNameNotExists() throws SBonitaReadException, SCommandNotFoundException {
    when(persistence.selectOne(any(SelectOneDescriptor.class))).thenReturn(null);

    commandServiceImpl.get("name");
  }