TypeDocumentConverter implements DocumentConverter<Type> { @Override public Document toDocument(final Type type) { requireNonNull(type); final Document doc = new Document(); doc.append(ID, type.getId().getData()); final List<String> propertyNames = new ArrayList<>(); type.getPropertyNames().forEach(field -> propertyNames.add(field.getData())); doc.append(PROPERTY_NAMES, propertyNames); return doc; }  @Override Document toDocument(final Type type); @Override Type fromDocument(final Document document); static final String ID; static final String PROPERTY_NAMES; }
@Test public void toDocument() { final Type type = new Type(new RyaIRI("urn:icecream"), ImmutableSet.<RyaIRI>builder() .add(new RyaIRI("urn:brand")) .add(new RyaIRI("urn:flavor")) .add(new RyaIRI("urn:cost")) .build()); final Document document = new TypeDocumentConverter().toDocument(type); final Document expected = new Document() .append(TypeDocumentConverter.ID, "urn:icecream") .append(TypeDocumentConverter.PROPERTY_NAMES, Lists.newArrayList("urn:brand", "urn:flavor", "urn:cost")); assertEquals(expected, document); }