Skip to content

Commit

Permalink
#80
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhrobbins committed Jan 6, 2014
1 parent 0def857 commit 3657433
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.robbins.flashcards.model.FlashCard;
import org.robbins.flashcards.model.Tag;
import org.robbins.flashcards.service.FlashCardService;
import org.robbins.flashcards.service.TagService;
import org.robbins.flashcards.service.util.DtoUtil;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Component;
Expand All @@ -33,9 +32,6 @@ public class DefaultFlashcardFacade extends AbstractCrudFacadeImpl<FlashCardDto,
@Inject
private TagFacade tagFacade;

@Inject
private TagService tagService;

@Override
public FlashCardService getService() {
return flashcardService;
Expand Down Expand Up @@ -114,11 +110,11 @@ private Set<Tag> configureTags(Set<TagDto> tags) {
// if we don't have the id of the Tag
if (tagDto.getId() == null || tagDto.getId() == 0) {
// try to get the existing Tag
Tag existingTag = tagService.findByName(tagDto.getName());
TagDto existingTag = tagFacade.findByName(tagDto.getName());

// does the Tag exist?
if (existingTag != null) {
results.add(existingTag);
results.add(tagFacade.getEntity(existingTag));
} else {
// tag doesn't exist, re-add the Tag as-as
results.add(tagFacade.getEntity(tagDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,19 @@ public void save() throws ServiceException {
when(mockService.save(any(FlashCard.class))).thenReturn(mockFlashcard);
when(mockMapper.map(mockFlashcardDto, FlashCard.class)).thenReturn(mockFlashcard);
when(mockMapper.map(mockFlashcard, FlashCardDto.class)).thenReturn(mockFlashcardDto);
when(mockFlashcardDto.getTags()).thenReturn(new HashSet<TagDto>(Arrays.asList(mockTagDto)));

FlashCardDto result = flashCardFacade.save(mockFlashcardDto);

verify(mockService).save(any(FlashCard.class));
assertThat(result, is(FlashCardDto.class));
}

@Test
public void getEntities() {
List<FlashCardDto> flashCardDtos = Arrays.asList(mockFlashcardDto);
List<FlashCard> results = flashCardFacade.getEtnties(flashCardDtos);

assertThat(results, is(List.class));
}
}

0 comments on commit 3657433

Please sign in to comment.