@Test public void testReadFeature() throws IOException { BuilderFactory bf = Features.getBuilderFactory(); URL res = getClass().getResource("/features/test-feature.json"); try (Reader r = new InputStreamReader(res.openStream())) { Feature f = Features.readFeature(r); assertNull(f.getName()); assertEquals("The feature description", f.getDescription()); List<FeatureBundle> bundles = f.getBundles(); assertEquals(3, bundles.size()); FeatureBundle bundle = bf.newBundleBuilder(new ID("org.osgi", "osgi.promise", "7.0.1")) .addMetadata("hash", "4632463464363646436") .addMetadata("start-order", 1L) .build(); FeatureBundle ba = bundles.get(0); ba.equals(bundle); assertTrue(bundles.contains(bundle)); assertTrue(bundles.contains(bf.newBundleBuilder(new ID("org.slf4j", "slf4j-api", "1.7.29")).build())); assertTrue(bundles.contains(bf.newBundleBuilder(new ID("org.slf4j", "slf4j-simple", "1.7.29")).build())); } }
public Feature readFeature(Reader jsonReader) throws IOException { JsonObject json = Json.createReader(jsonReader).readObject(); String id = json.getString("id"); FeatureBuilder builder = builderFactory.newFeatureBuilder(ID.fromMavenID(id)); builder.setName(json.getString("title", null)); builder.setDescription(json.getString("description", null)); builder.setVendor(json.getString("vendor", null)); builder.setLicense(json.getString("license", null)); builder.setLocation(json.getString("location", null)); builder.setComplete(json.getBoolean("complete", false)); builder.setFinal(json.getBoolean("final", false)); builder.addBundles(getBundles(json)); builder.addConfigurations(getConfigurations(json)); builder.addExtensions(getExtensions(json)); return builder.build(); }
FeatureServiceImpl { public Feature readFeature(Reader jsonReader) throws IOException { JsonObject json = Json.createReader(jsonReader).readObject(); String id = json.getString("id"); FeatureBuilder builder = builderFactory.newFeatureBuilder(ID.fromMavenID(id)); builder.setName(json.getString("title", null)); builder.setDescription(json.getString("description", null)); builder.setVendor(json.getString("vendor", null)); builder.setLicense(json.getString("license", null)); builder.setLocation(json.getString("location", null)); builder.setComplete(json.getBoolean("complete", false)); builder.setFinal(json.getBoolean("final", false)); builder.addBundles(getBundles(json)); builder.addConfigurations(getConfigurations(json)); builder.addExtensions(getExtensions(json)); return builder.build(); } }
FeatureServiceImpl { public Feature readFeature(Reader jsonReader) throws IOException { JsonObject json = Json.createReader(jsonReader).readObject(); String id = json.getString("id"); FeatureBuilder builder = builderFactory.newFeatureBuilder(ID.fromMavenID(id)); builder.setName(json.getString("title", null)); builder.setDescription(json.getString("description", null)); builder.setVendor(json.getString("vendor", null)); builder.setLicense(json.getString("license", null)); builder.setLocation(json.getString("location", null)); builder.setComplete(json.getBoolean("complete", false)); builder.setFinal(json.getBoolean("final", false)); builder.addBundles(getBundles(json)); builder.addConfigurations(getConfigurations(json)); builder.addExtensions(getExtensions(json)); return builder.build(); }  }
FeatureServiceImpl { public Feature readFeature(Reader jsonReader) throws IOException { JsonObject json = Json.createReader(jsonReader).readObject(); String id = json.getString("id"); FeatureBuilder builder = builderFactory.newFeatureBuilder(ID.fromMavenID(id)); builder.setName(json.getString("title", null)); builder.setDescription(json.getString("description", null)); builder.setVendor(json.getString("vendor", null)); builder.setLicense(json.getString("license", null)); builder.setLocation(json.getString("location", null)); builder.setComplete(json.getBoolean("complete", false)); builder.setFinal(json.getBoolean("final", false)); builder.addBundles(getBundles(json)); builder.addConfigurations(getConfigurations(json)); builder.addExtensions(getExtensions(json)); return builder.build(); }  BuilderFactory getBuilderFactory(); Feature readFeature(Reader jsonReader); void writeFeature(Feature feature, Writer jsonWriter); Feature mergeFeatures(ID targetID, Feature f1, Feature f2, MergeContext ctx); }
FeatureServiceImpl { public Feature readFeature(Reader jsonReader) throws IOException { JsonObject json = Json.createReader(jsonReader).readObject(); String id = json.getString("id"); FeatureBuilder builder = builderFactory.newFeatureBuilder(ID.fromMavenID(id)); builder.setName(json.getString("title", null)); builder.setDescription(json.getString("description", null)); builder.setVendor(json.getString("vendor", null)); builder.setLicense(json.getString("license", null)); builder.setLocation(json.getString("location", null)); builder.setComplete(json.getBoolean("complete", false)); builder.setFinal(json.getBoolean("final", false)); builder.addBundles(getBundles(json)); builder.addConfigurations(getConfigurations(json)); builder.addExtensions(getExtensions(json)); return builder.build(); }  BuilderFactory getBuilderFactory(); Feature readFeature(Reader jsonReader); void writeFeature(Feature feature, Writer jsonWriter); Feature mergeFeatures(ID targetID, Feature f1, Feature f2, MergeContext ctx);  }