@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); }
@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()); }