OrientNpmGroupDataFacet extends FacetSupport { @VisibleForTesting protected boolean shouldServeFirstResult(final List<?> packages, final NpmPackageId packageId) { return packages.size() == 1 || (!mergeMetadata && isEmpty(packageId.scope())); } @Inject  OrientNpmGroupDataFacet(
      @Named("${nexus.npm.mergeGroupMetadata:-true}") final boolean mergeMetadata); @Nullable Content buildPackageRoot(final Map<Repository, Response> responses, final Context context); @Nullable NpmContent getFromCache(final Map<Repository, Response> responses, final Context context); @Nullable NpmContent getFromCache(final Context context); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetDeletedEvent deleted); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetUpdatedEvent updated); Iterable<Repository> members();  }
@Test public void whenSingleOrUnScopedResultShouldNotMerge() throws Exception { assertThat(underTest.shouldServeFirstResult(createRandomMaps(1), A), equalTo(true)); assertThat(underTest.shouldServeFirstResult(createRandomMaps(1), SCOPED), equalTo(true)); setupMergeDisabledNpmGroupFacet(); assertThat(underTest.shouldServeFirstResult(createRandomMaps(1), A), equalTo(true)); assertThat(underTest.shouldServeFirstResult(createRandomMaps(2), A), equalTo(true)); }
@Test public void whenMultipleResultShouldMerge() throws Exception { assertThat(underTest.shouldServeFirstResult(createRandomMaps(2), A), equalTo(false)); assertThat(underTest.shouldServeFirstResult(createRandomMaps(2), SCOPED), equalTo(false)); setupMergeDisabledNpmGroupFacet(); assertThat(underTest.shouldServeFirstResult(createRandomMaps(2), SCOPED), equalTo(false)); }