mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Acs 4400 multiple same categories can be linked from content or folder (#1675)
ACS-4400: Multiple same categories can be linked from content or folder
This commit is contained in:
@@ -193,6 +193,7 @@ public class CategoriesImpl implements Categories
|
||||
.filter(Objects::nonNull)
|
||||
.map(Category::getId)
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.distinct()
|
||||
.map(this::getCategoryNodeRef)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
@@ -1000,6 +1000,26 @@ public class CategoriesImplTest
|
||||
.hasMessageContaining(NOT_A_VALID_CATEGORY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkNodeToCategories_withTwoIdenticalCategories()
|
||||
{
|
||||
final List<Category> categoryLinks = List.of(CATEGORY, CATEGORY);
|
||||
final NodeRef categoryParentNodeRef = createNodeRefWithId(PARENT_ID);
|
||||
final ChildAssociationRef parentAssociation = createAssociationOf(categoryParentNodeRef, CATEGORY_NODE_REF);
|
||||
given(nodesMock.getNode(any())).willReturn(prepareCategoryNode());
|
||||
given(nodeServiceMock.getPrimaryParent(any())).willReturn(parentAssociation);
|
||||
|
||||
// when
|
||||
final List<Category> actualLinkedCategories = objectUnderTest.linkNodeToCategories(CONTENT_NODE_ID, categoryLinks);
|
||||
|
||||
final Map<QName, Serializable> expectedProperties = Map.of(ContentModel.PROP_CATEGORIES, (Serializable) List.of(CATEGORY_NODE_REF));
|
||||
then(nodeServiceMock).should().addAspect(CONTENT_NODE_REF, ContentModel.ASPECT_GEN_CLASSIFIABLE, expectedProperties);
|
||||
final List<Category> expectedLinkedCategories = List.of(CATEGORY);
|
||||
assertThat(actualLinkedCategories)
|
||||
.isNotNull().usingRecursiveComparison()
|
||||
.isEqualTo(expectedLinkedCategories);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListCategoriesForNode()
|
||||
{
|
||||
|
Reference in New Issue
Block a user