@Test
  public void create() {
    // Given
    ProcessControl processControl = processControlFactoryForTest.newProcessControl();

    ProcessControlEntity processControlEntity =
        processControlEntityFactoryForTest.newProcessControlEntity();
    when(processControlJpaRepository.findOne(processControl.getProcessId())).thenReturn(null);

    processControlEntity = new ProcessControlEntity();
    processControlServiceMapper.mapProcessControlToProcessControlEntity(
        processControl, processControlEntity);
    ProcessControlEntity processControlEntitySaved =
        processControlJpaRepository.save(processControlEntity);

    ProcessControl processControlSaved = processControlFactoryForTest.newProcessControl();
    when(processControlServiceMapper.mapProcessControlEntityToProcessControl(
            processControlEntitySaved))
        .thenReturn(processControlSaved);

    // When
    ProcessControl processControlResult = processControlService.create(processControl);

    // Then
    assertTrue(processControlResult == processControlSaved);
  }
  @Test
  public void findAll() {
    // Given
    List<ProcessControlEntity> processControlEntitys = new ArrayList<ProcessControlEntity>();
    ProcessControlEntity processControlEntity1 =
        processControlEntityFactoryForTest.newProcessControlEntity();
    processControlEntitys.add(processControlEntity1);
    ProcessControlEntity processControlEntity2 =
        processControlEntityFactoryForTest.newProcessControlEntity();
    processControlEntitys.add(processControlEntity2);
    when(processControlJpaRepository.findAll()).thenReturn(processControlEntitys);

    ProcessControl processControl1 = processControlFactoryForTest.newProcessControl();
    when(processControlServiceMapper.mapProcessControlEntityToProcessControl(processControlEntity1))
        .thenReturn(processControl1);
    ProcessControl processControl2 = processControlFactoryForTest.newProcessControl();
    when(processControlServiceMapper.mapProcessControlEntityToProcessControl(processControlEntity2))
        .thenReturn(processControl2);

    // When
    List<ProcessControl> processControlsFounds = processControlService.findAll();

    // Then
    assertTrue(processControl1 == processControlsFounds.get(0));
    assertTrue(processControl2 == processControlsFounds.get(1));
  }
  @Test
  public void findById() {
    // Given
    Integer processId = mockValues.nextInteger();

    ProcessControlEntity processControlEntity = processControlJpaRepository.findOne(processId);

    ProcessControl processControl = processControlFactoryForTest.newProcessControl();
    when(processControlServiceMapper.mapProcessControlEntityToProcessControl(processControlEntity))
        .thenReturn(processControl);

    // When
    ProcessControl processControlFound = processControlService.findById(processId);

    // Then
    assertEquals(processControl.getProcessId(), processControlFound.getProcessId());
  }
  @Test
  public void createKOExists() {
    // Given
    ProcessControl processControl = processControlFactoryForTest.newProcessControl();

    ProcessControlEntity processControlEntity =
        processControlEntityFactoryForTest.newProcessControlEntity();
    when(processControlJpaRepository.findOne(processControl.getProcessId()))
        .thenReturn(processControlEntity);

    // When
    Exception exception = null;
    try {
      processControlService.create(processControl);
    } catch (Exception e) {
      exception = e;
    }

    // Then
    assertTrue(exception instanceof IllegalStateException);
    assertEquals("already.exists", exception.getMessage());
  }