AssetCategoryMetric { public JSONObject toJSONObject(String vocabularyName) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); if (!ListUtil.isEmpty( _assetVocabularyMetric.getAssetCategoryMetrics())) { jsonObject.put("categories", _assetVocabularyMetric.toJSONArray()); } return jsonObject.put( "key", _key ).put( "name", _name ).put( "value", _value ).put( "vocabularyName", vocabularyName ); } AssetCategoryMetric(
		AssetVocabularyMetric assetVocabularyMetric, String key, String name,
		long value);  AssetCategoryMetric(String key, String name, long value); @Override boolean equals(Object object); AssetVocabularyMetric getAssetVocabularyMetric(); String getKey(); String getName(); long getValue(); @Override int hashCode(); JSONObject toJSONObject(String vocabularyName);  }
@Test public void testToJSONObject() { AssetCategoryMetric childAssetCategoryMetric = new AssetCategoryMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString(), RandomTestUtil.randomLong()); AssetVocabularyMetric assetVocabularyMetric = new AssetVocabularyMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString(), Collections.singletonList(childAssetCategoryMetric)); AssetCategoryMetric assetCategoryMetric = new AssetCategoryMetric( assetVocabularyMetric, RandomTestUtil.randomString(), RandomTestUtil.randomString(), RandomTestUtil.randomLong()); String vocabularyName = RandomTestUtil.randomString(); Assert.assertEquals( JSONUtil.put( "categories", JSONUtil.put( JSONUtil.put( "key", childAssetCategoryMetric.getKey() ).put( "name", childAssetCategoryMetric.getName() ).put( "value", childAssetCategoryMetric.getValue() ).put( "vocabularyName", assetVocabularyMetric.getName() )) ).put( "key", assetCategoryMetric.getKey() ).put( "name", assetCategoryMetric.getName() ).put( "value", assetCategoryMetric.getValue() ).put( "vocabularyName", vocabularyName ).toString(), String.valueOf(assetCategoryMetric.toJSONObject(vocabularyName))); }