ElasticsearchStoreConfig extends BaseSailConfig { @Override public void parse(Model graph, Resource implNode) throws SailConfigException { super.parse(graph, implNode); try { Models.objectLiteral(graph.getStatements(implNode, ElasticsearchStoreSchema.hostname, null)) .ifPresent(value -> { try { setHostname(value.stringValue()); } catch (IllegalArgumentException e) { throw new SailConfigException( "String value required for " + ElasticsearchStoreSchema.hostname + " property, found " + value); } }); Models.objectLiteral(graph.getStatements(implNode, ElasticsearchStoreSchema.index, null)) .ifPresent(value -> { try { setIndex(value.stringValue()); } catch (IllegalArgumentException e) { throw new SailConfigException( "String value required for " + ElasticsearchStoreSchema.index + " property, found " + value); } }); Models.objectLiteral(graph.getStatements(implNode, ElasticsearchStoreSchema.clusterName, null)) .ifPresent(value -> { try { setClusterName(value.stringValue()); } catch (IllegalArgumentException e) { throw new SailConfigException( "String value required for " + ElasticsearchStoreSchema.clusterName + " property, found " + value); } }); Models.objectLiteral(graph.getStatements(implNode, ElasticsearchStoreSchema.port, null)) .ifPresent(value -> { try { setPort(value.intValue()); } catch (IllegalArgumentException e) { throw new SailConfigException( "Integer value required for " + ElasticsearchStoreSchema.port + " property, found " + value); } }); } catch (ModelException e) { throw new SailConfigException(e.getMessage(), e); } } ElasticsearchStoreConfig(); @Override Resource export(Model graph); @Override void parse(Model graph, Resource implNode); String getHostname(); int getPort(); String getClusterName(); String getIndex(); void setHostname(String hostname); void setPort(int port); void setClusterName(String clusterName); void setIndex(String index); void assertRequiredValuesPresent();  }
@Test(expected = SailConfigException.class) public void parseInvalidModelGivesCorrectException() { mb .add(ElasticsearchStoreSchema.port, "port1"); subject.parse(mb.build(), implNode); }