### Question:
DefaultTagService implements TagService { @Override public Tag getTagById(String entityId) { return repository.get(entityId); } @Autowired  DefaultTagService(TagRepository repository); @Override Tag getTagById(String entityId); @Override List<Tag> getAllTagsList(); @Override SearchResult<Tag> getAll(); @Override SearchResult<Tag> getLimitedList(int offset, int pageSize); @Override Tag getTagByKeyword(String keyword); @Override @Transactional Tag save(Tag tag);  }### Answer:
@Test public void getTagById() { Tag tag = createTag("test"); expect(repository.get("1")).andReturn(tag); replay(repository); Tag sTag = service.getTagById("1"); assertEquals(sTag, tag); verify(repository); }
@Test public void getTagById_NotFound() { final String entityId = "456"; expect(repository.get(entityId)).andReturn(null); replay(repository); Tag sTag = service.getTagById(entityId); assertNull(sTag); verify(repository); }