mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
Addressed review comments
This commit is contained in:
@@ -130,7 +130,8 @@ public class TagsImpl implements Tags
|
||||
for(Pair<String, NodeRef> pair : tagNodeRefs)
|
||||
{
|
||||
Tag createdTag=new Tag(pair.getSecond(), pair.getFirst());
|
||||
createdTag.setCount(Optional.ofNullable(tagsCountMap.get(createdTag.getTag())).map(cnt->cnt+1).orElse(1));
|
||||
// The new use of the tag will not be indexed yet, so add one to whatever count we get back
|
||||
createdTag.setCount(Optional.ofNullable(tagsCountMap.get(createdTag.getTag())).orElse(0) + 1);
|
||||
ret.add(createdTag);
|
||||
}
|
||||
return ret;
|
||||
|
@@ -35,7 +35,6 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -95,14 +94,6 @@ public class TagsImplTest
|
||||
given(createdNodeMock.getNodeId()).willReturn(NODE_ID);
|
||||
given(typeConstraint.matches(any())).willReturn(true);
|
||||
given(taggingServiceMock.getTagName(TAG_NODE_REF)).willReturn(TAG_NAME);
|
||||
given(taggingServiceMock.findTaggedNodesAndCountByTagName(any())).willReturn(createTagsCountPairList());
|
||||
}
|
||||
|
||||
public List<Pair<String,Integer>> createTagsCountPairList()
|
||||
{
|
||||
List<Pair<String,Integer>> tagsCountPairList = new ArrayList<>();
|
||||
tagsCountPairList.add(new Pair<>("tag-node-id",1));
|
||||
return tagsCountPairList;
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,7 +318,7 @@ public class TagsImplTest
|
||||
@Test
|
||||
public void testAddTagsToNode()
|
||||
{
|
||||
final List<String> tagNames = List.of("tag1");
|
||||
final List<String> tagNames = List.of("tag1","tag2");
|
||||
final List<Tag> tagsToCreate = createTags(tagNames);
|
||||
given(taggingServiceMock.addTags(any(), any())).willAnswer(invocation -> createTagAndNodeRefPairs(invocation.getArgument(1)));
|
||||
final List<Tag> actualCreatedTags = objectUnderTest.addTags(nodesMock.getNode(any()).getNodeId(),tagsToCreate);
|
||||
@@ -338,4 +329,19 @@ public class TagsImplTest
|
||||
.isEqualTo(expectedTags);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddTagsToNodeWithResponseNotIndexed()
|
||||
{
|
||||
final List<String> tagNames = List.of("tag1","tag2");
|
||||
final List<Tag> tagsToCreate = createTags(tagNames);
|
||||
given(taggingServiceMock.addTags(any(), any())).willAnswer(invocation -> createTagAndNodeRefPairs(invocation.getArgument(1)));
|
||||
given(taggingServiceMock.findTaggedNodesAndCountByTagName(any())).willReturn(Collections.emptyList());
|
||||
final List<Tag> actualCreatedTags = objectUnderTest.addTags(nodesMock.getNode(any()).getNodeId(),tagsToCreate);
|
||||
then(taggingServiceMock).should().addTags(TAG_NODE_REF, tagNames);
|
||||
final List<Tag> expectedTags = createTagsWithNodeRefs(tagNames);
|
||||
assertThat(actualCreatedTags)
|
||||
.isNotNull()
|
||||
.isEqualTo(expectedTags);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user