java serializable 源码_Java Serializable.toString方法代码示例

本文探讨了Java中的Serializable接口,并在assertVirtualNode方法中展示了如何检查虚拟节点的属性。内容包括确认节点具有VirtualContentModel.ASPECT_VIRTUAL和ASPECT_TITLED方面,验证必要的属性是否设置,并确保PROP_TITLE属性保持未设置状态。
摘要由CSDN通过智能技术生成

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());

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值