AssetVocabularyMetric { public List<String> getVocabularyNames() { if (_assetCategoryMetrics.isEmpty()) { return Collections.emptyList(); } Stream<AssetCategoryMetric> stream = _assetCategoryMetrics.stream(); return stream.findFirst( ).map( AssetCategoryMetric::getAssetVocabularyMetric ).filter( assetVocabularyMetric -> ListUtil.isNotEmpty( assetVocabularyMetric.getAssetCategoryMetrics()) ).map( AssetVocabularyMetric::getName ).map( name -> Collections.unmodifiableList(Arrays.asList(_name, name)) ).orElse( Collections.unmodifiableList(Collections.singletonList(_name)) ); } 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 testGetVocabularyNames() { AssetVocabularyMetric childAssetVocabularyMetric = new AssetVocabularyMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString(), Collections.singletonList( new AssetCategoryMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString(), RandomTestUtil.randomLong()))); AssetVocabularyMetric assetVocabularyMetric = new AssetVocabularyMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString(), Collections.singletonList( new AssetCategoryMetric( childAssetVocabularyMetric, RandomTestUtil.randomString(), RandomTestUtil.randomString(), RandomTestUtil.randomLong()))); Assert.assertEquals( Arrays.asList( assetVocabularyMetric.getName(), childAssetVocabularyMetric.getName()), assetVocabularyMetric.getVocabularyNames()); }
@Test public void testGetVocabularyNamesWithEmptyAssetCategoryMetrics() { AssetVocabularyMetric assetVocabularyMetric = new AssetVocabularyMetric( RandomTestUtil.randomString(), RandomTestUtil.randomString()); Assert.assertEquals( Collections.emptyList(), assetVocabularyMetric.getVocabularyNames()); }