assertEquals(0L, v.get("free"));
}
@Test
public void testFs() throws Exception {
ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, NodeFsExpression.NAME);
SysObjectReference fs = (SysObjectReference) resolver.getImplementation(ident);
Joiner.MapJoiner mapJoiner = Joiner.on(", ").withKeyValueSeparator(":");
Map<String, Object> v = fs.value();
Map<String, Object> total = (Map<String, Object>) v.get("total");
assertThat(mapJoiner.join(total),
is("reads:84, bytes_written:84, bytes_read:84, available:86016, " +
"writes:84, used:84, size:86016"));
Object[] disks = (Object[]) v.get("disks");
assertThat(disks.length, is(2));
Map<String, Object> disk0 = (Map<String, Object>) disks[0];
assertThat((String)disk0.get("dev"), is("/dev/sda1"));
assertThat((Long)disk0.get("size"), is(42L*1024));
Map<String, Object> disk1 = (Map<String, Object>) disks[1];
assertThat((String)disk1.get("dev"), is("/dev/sda2"));
assertThat((Long)disk0.get("used"), is(42L*1024));
Object[] data = (Object[]) v.get("data");
assertThat(data.length, is(2));
assertThat((String)((Map<String, Object>)data[0]).get("dev"), is("/dev/sda1"));
assertThat((String)((Map<String, Object>)data[0]).get("path"), is("/foo"));
assertThat((String)((Map<String, Object>)data[1]).get("dev"), is("/dev/sda2"));
assertThat((String)((Map<String, Object>)data[1]).get("path"), is("/bar"));
ident = new ReferenceIdent(SysNodesTableInfo.IDENT, NodeFsExpression.NAME, ImmutableList.of(NodeFsDataExpression.NAME, "dev"));
SysExpression<Object[]> fsData = (SysExpression<Object[]>)resolver.getImplementation(ident);
for (Object arrayElement : fsData.value()) {
assertThat(arrayElement, instanceOf(BytesRef.class));
}