import java.io.Serializable; //导入方法依赖的package包/类
protected void assertVirtualNode(NodeRef nodeRef, Map expectedProperties)
{
assertNotNull(Reference.fromNodeRef(nodeRef));
assertTrue(nodeService.hasAspect(nodeRef,
VirtualContentModel.ASPECT_VIRTUAL));
Set aspects = nodeService.getAspects(nodeRef);
assertTrue("Smart virtual node missing virtual aspect",aspects.contains(VirtualContentModel.ASPECT_VIRTUAL));
//ACE-5303 injected properties title and description require the titled aspect
assertTrue("Smaft virtual node missing titled aspect",aspects.contains(ContentModel.ASPECT_TITLED));
Map nodeProperties = nodeService.getProperties(nodeRef);
List mandatoryProperties = Arrays.asList(ContentModel.PROP_STORE_IDENTIFIER,
ContentModel.PROP_STORE_PROTOCOL,
ContentModel.PROP_LOCALE,
ContentModel.PROP_MODIFIED,
ContentModel.PROP_MODIFIER,
ContentModel.PROP_CREATED,
ContentModel.PROP_CREATOR,
ContentModel.PROP_NODE_DBID,
ContentModel.PROP_DESCRIPTION);
Set missingPropreties = new HashSet<>(mandatoryProperties);
missingPropreties.removeAll(nodeProperties.keySet());
assertTrue("Mandatory properties are missing" + missingPropreties,
missingPropreties.isEmpty());
assertFalse("ACE-5303 : ContentModel.PROP_TITLE should remain unset",nodeProperties.containsKey(ContentModel.PROP_TITLE));
Set> epEntries = expectedProperties.entrySet();
StringBuilder unexpectedBuilder = new StringBuilder();
for (Entry entry : epEntries)
{
Serializable actualValue = nodeProperties.get(entry.getKey());
Serializable expectedValue = expectedProperties.get(entry.getKey());
boolean fail = false;
String expectedValueStr = null;
if (expectedValue != null)
{
expectedValueStr = expectedValue.toString();
if (!expectedValue.equals(actualValue))
{
fail = true;
}
}
else if (actualValue != null)
{
fail = true;
expectedValueStr = "";
}
if (fail)
{
unexpectedBuilder.append("\n");
unexpectedBuilder.append(entry.getKey());
unexpectedBuilder.append(" expected[");
unexpectedBuilder.append(expectedValueStr);
unexpectedBuilder.append("] != actua[");
unexpectedBuilder.append(actualValue);
unexpectedBuilder.append("]");
}
}
String unexpectedStr = unexpectedBuilder.toString();
assertTrue("Unexpected property values : " + unexpectedStr,
unexpectedStr.isEmpty());
}