コード例 #1
0
  @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);
  }
コード例 #2
0
  @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());
  }
コード例 #3
0
  @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());
  }