コード例 #1
0
  @Test(expected = NotFoundException.class)
  public void shouldThrowNotFoundExceptionForNullLogEntry() {
    String logId = "some unknown id";

    given(repository.findOne(logId)).willReturn(null);

    service.getById(logId);
  }
コード例 #2
0
  @Test
  public void shouldAbleToGetById() {

    String logId = "some id";

    LogEntry logentry = new LogEntry();
    Event event = new Event();

    given(repository.findOne(logId)).willReturn(logentry);
    given(mapper.mapFrom(logentry)).willReturn(event);

    Event line = service.getById(logId);
    assertNotNull(line);
  }
コード例 #3
0
  @Test
  public void shouldInsert() {
    Event event = new Event();
    String insertId = "savedId";

    LogEntry logEntry = new LogEntry();

    LogEntry saved = new LogEntry();
    saved.setId(insertId);

    given(mapper.mapTo(event)).willReturn(logEntry);
    given(repository.save(logEntry)).willReturn(saved);

    InsertResponse insertResponse = service.insert(event);
    assertNotNull(insertResponse);
    assertEquals(insertId, insertResponse.getCreatedId());
  }