AssetVocabularyMetric { public JSONArray toJSONArray() { Stream<AssetCategoryMetric> stream = _assetCategoryMetrics.stream(); return JSONUtil.putAll( stream.map( assetCategoryMetric -> assetCategoryMetric.toJSONObject(_name) ).toArray()); } AssetVocabularyMetric(String key, String name);  AssetVocabularyMetric(
		String key, String name,
		List<AssetCategoryMetric> assetCategoryMetrics); static AssetVocabularyMetric empty(); @Override boolean equals(Object object); List<AssetCategoryMetric> getAssetCategoryMetrics(); String getKey(); String getName(); List<String> getVocabularyNames(); @Override int hashCode(); JSONArray toJSONArray();  }
@Test public void testToJSONArray() { AssetCategoryMetric assetCategoryMetric1 = new AssetCategoryMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString(), RandomTestUtil.randomLong()); AssetCategoryMetric assetCategoryMetric2 = new AssetCategoryMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString(), RandomTestUtil.randomLong()); AssetVocabularyMetric assetVocabularyMetric = new AssetVocabularyMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString(), Arrays.asList(assetCategoryMetric1, assetCategoryMetric2)); Assert.assertEquals( JSONUtil.putAll( JSONUtil.put( "key", assetCategoryMetric1.getKey() ).put( "name", assetCategoryMetric1.getName() ).put( "value", assetCategoryMetric1.getValue() ).put( "vocabularyName", assetVocabularyMetric.getName() ), JSONUtil.put( "key", assetCategoryMetric2.getKey() ).put( "name", assetCategoryMetric2.getName() ).put( "value", assetCategoryMetric2.getValue() ).put( "vocabularyName", assetVocabularyMetric.getName() ) ).toString(), String.valueOf(assetVocabularyMetric.toJSONArray())); }
@Test public void testToJSONArrayWithEmptyAssetCategoryMetrics() { AssetVocabularyMetric assetVocabularyMetric = new AssetVocabularyMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString()); Assert.assertEquals( String.valueOf(JSONFactoryUtil.createJSONArray()), String.valueOf(assetVocabularyMetric.toJSONArray())); }