DefaultGroupService implements GroupService { @Override public Group createGroup(String name) { final Group group = new Group(); group.setName(name); return groupRepository.save(group); } DefaultGroupService(GroupRepository groupRepository, MembershipRepository membershipRepository); @Override Group createGroup(String name); @Override void deleteGroup(Group group); @Override void join(Group group, User user); @Override void leave(Group group, User user); @Override List<User> members(Group group); @Override List<Group> groups(User user);  }
@Test public void testCreatingAGroup() { assertThat(groupRepository.count(), is(0L)); final String name = "My Group"; final Group group = service.createGroup(name); assertThat(group, is(notNullValue())); assertThat(group.getName(), is(name)); assertThat(groupRepository.count(), is(1L)); final Group found = groupRepository.findById(group.getId()).orElse(null); assertThat(found, is(notNullValue())); assertThat(found.getName(), is(name)); }