/** Save success */ @Test public void saveTagsInSameGroup() { Client client = createClient(); Group group1 = createGroup(client); Group group2 = createGroup(client); List<Tag> tagList = createTagList(group1, 2); List<Tag> tagList2 = createTagList(group2, 1); Tag tag1 = tagList.get(0); Tag tag2 = tagList.get(1); Tag tag3 = tagList2.get(0); Team team1 = createTeam(client); Team team2 = createTeam(client); Team team3 = createTeam(client); TeamTag afterSaveTeamTag1 = teamTagService.saveSingleTeamTag(team1, tag1); TeamTag afterSaveTeamTag2 = teamTagService.saveSingleTeamTag(team2, tag2); TeamTag afterSaveTeamTag3 = teamTagService.saveSingleTeamTag(team3, tag3); TeamTagSearchFilter searchFilter = new TeamTagSearchFilter(); HashSet<Tag> tagSet = new HashSet<>(); tagSet.add(tag1); tagSet.add(tag2); searchFilter.setTagSet(tagSet); Page<TeamTag> returnedTeamTags = teamTagService.findTeamsWithTag(null, searchFilter); assertThat("afterSaveTeamTag1 team is returned", returnedTeamTags, hasItem(afterSaveTeamTag1)); assertThat("afterSaveTeamTag2 team is returned", returnedTeamTags, hasItem(afterSaveTeamTag2)); assertThat( "afterSaveTeamTag3 team is not returned", returnedTeamTags, not(hasItem(afterSaveTeamTag3))); }
/** Save success */ @Test public void save() { Client client = createClient(); Group group = createGroup(client); Tag tag = createTagList(group, 1).get(0); Team team = createTeam(client); tag = tagService.reload(tag); TeamTag afterSaveTeamTag = teamTagService.saveSingleTeamTag(team, tag); assertThat("TeamTag was given an id", afterSaveTeamTag.getId(), is(notNullValue())); TeamTagSearchFilter searchFilter = new TeamTagSearchFilter(); HashSet<Tag> tagSet = new HashSet<>(); tagSet.add(tag); searchFilter.setTagSet(tagSet); Page<TeamTag> teamsWithTag = teamTagService.findTeamsWithTag(null, searchFilter); assertThat( "we can find the team tag by the team tag id", teamsWithTag, hasItem(afterSaveTeamTag)); }