mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Addressed review comments
This commit is contained in:
@@ -446,16 +446,21 @@ public class TagsImplTest
|
|||||||
@Test
|
@Test
|
||||||
public void testAddTags()
|
public void testAddTags()
|
||||||
{
|
{
|
||||||
|
NodeRef tagNodeA = new NodeRef("tag://A/");
|
||||||
|
NodeRef tagNodeB = new NodeRef("tag://B/");
|
||||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willReturn(CONTENT_NODE_REF);
|
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willReturn(CONTENT_NODE_REF);
|
||||||
given(typeConstraintMock.matches(CONTENT_NODE_REF)).willReturn(true);
|
given(typeConstraintMock.matches(CONTENT_NODE_REF)).willReturn(true);
|
||||||
List<Pair<String, NodeRef>> pairs = List.of(new Pair<>("tagA", new NodeRef("tag://A/")), new Pair<>("tagB", new NodeRef("tag://B/")));
|
List<Pair<String, NodeRef>> pairs = List.of(new Pair<>("tagA", new NodeRef("tag://A/")), new Pair<>("tagB", new NodeRef("tag://B/")));
|
||||||
List<String> tagNames = pairs.stream().map(Pair::getFirst).collect(toList());
|
List<String> tagNames = pairs.stream().map(Pair::getFirst).collect(toList());
|
||||||
List<Tag> tags = tagNames.stream().map(name -> Tag.builder().tag(name).create()).collect(toList());
|
List<Tag> tags = tagNames.stream().map(name -> Tag.builder().tag(name).create()).collect(toList());
|
||||||
given(taggingServiceMock.addTags(CONTENT_NODE_REF, tagNames)).willReturn(pairs);
|
given(taggingServiceMock.addTags(CONTENT_NODE_REF, tagNames)).willReturn(pairs);
|
||||||
|
given(taggingServiceMock.findTaggedNodesAndCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE)).willReturn(List.of(new Pair<>("tagA", 4)));
|
||||||
|
given(parametersMock.getInclude()).willReturn(List.of("count"));
|
||||||
|
|
||||||
List<Tag> actual = objectUnderTest.addTags(CONTENT_NODE_ID, tags, parametersMock);
|
List<Tag> actual = objectUnderTest.addTags(CONTENT_NODE_ID, tags, parametersMock);
|
||||||
|
|
||||||
List<Tag> expected = pairs.stream().map(pair -> new Tag(pair.getSecond(), pair.getFirst())).collect(toList());
|
final List<Tag> expected = List.of(Tag.builder().tag("tagA").nodeRef(tagNodeA).count(5).create(),
|
||||||
|
Tag.builder().tag("tagB").nodeRef(tagNodeB).count(1).create());
|
||||||
assertEquals("Unexpected tags returned.", expected, actual);
|
assertEquals("Unexpected tags returned.", expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user