UserTagService mockUserTagService = mock(UserTagService.class);
when(mockUserTagService.addMultiplyTags(any(User.class), anyString(), anyBoolean())).thenCallRealMethod();
when(mockUserTagService.parseTags(anyString(), any(Errors.class))).thenCallRealMethod();
try{
doThrow(new TagNotFoundException()).when(mockUserTagService).favoriteAdd(eq(user), eq("uytutut"));
doThrow(new DuplicateKeyException("duplicate")).when(mockUserTagService).favoriteAdd(eq(user), eq("tag3"));
} catch (Exception e) {}
List<String> strErrors = mockUserTagService.addMultiplyTags(user, "tag1, tag2, tag3, uytutut, @#$%$#", true);
try{
verify(mockUserTagService).favoriteAdd(eq(user), eq("tag1"));
verify(mockUserTagService).favoriteAdd(eq(user), eq("tag2"));
verify(mockUserTagService).favoriteAdd(eq(user), eq("uytutut"));
verify(mockUserTagService, never()).favoriteAdd(eq(user), eq("@#$%$#"));
verify(mockUserTagService, never()).ignoreAdd(any(User.class), anyString());
} catch (Exception e) {}
Assert.assertEquals(3, strErrors.size());
reset(mockUserTagService);
when(mockUserTagService.addMultiplyTags(any(User.class), anyString(), anyBoolean())).thenCallRealMethod();
when(mockUserTagService.parseTags(anyString(), any(Errors.class))).thenCallRealMethod();
try{
doThrow(new TagNotFoundException()).when(mockUserTagService).ignoreAdd(eq(user), eq("uytutut"));
doThrow(new DuplicateKeyException("duplicate")).when(mockUserTagService).ignoreAdd(eq(user), eq("tag3"));
} catch (Exception e) {}
strErrors = mockUserTagService.addMultiplyTags(user, "tag1, tag2, tag3, uytutut, @#$%$#", false);
try{
verify(mockUserTagService).ignoreAdd(eq(user), eq("tag1"));